skip to content
Astro Cactus

Managing Applications with ArgoCD

/ 2 min read

Series Navigation

Managing Applications with ArgoCD

In this second part of our ArgoCD series, we’ll dive deep into application management, covering everything from creating applications to advanced sync strategies.

Creating Applications

Via CLI

Terminal window
argocd app create guestbook \
--repo https://github.com/argoproj/argocd-example-apps.git \
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default

Via YAML

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: guestbook
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
targetRevision: HEAD
path: guestbook
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true

Sync Strategies

Manual Sync

  • Requires explicit approval
  • Good for production environments
  • Allows review before deployment

Automated Sync

syncPolicy:
automated:
prune: true # Remove resources that no longer exist in Git
selfHeal: true # Revert manual changes

Health Checks

ArgoCD provides built-in health assessments for:

  • Kubernetes resources
  • Custom resources
  • Helm releases
  • Custom health checks

Custom Health Checks

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
spec:
ignoreDifferences:
- group: apps
kind: Deployment
jsonPointers:
- /spec/replicas
health:
- check:
command: ["/scripts/health-check.sh"]
args: ["myapp"]

Resource Hooks

Pre-sync and post-sync hooks for tasks like:

  • Database migrations
  • Resource validation
  • Notifications
apiVersion: batch/v1
kind: Job
metadata:
annotations:
argocd.argoproj.io/hook: PreSync

Best Practices

  1. Application Structure

    • Use Helm charts or Kustomize for templating
    • Maintain separate configs for different environments
    • Version your manifests
  2. Sync Policies

    • Use automated sync for dev/staging
    • Manual sync for production
    • Enable pruning with caution
  3. Resource Management

    • Set resource limits
    • Use namespaces for isolation
    • Implement RBAC

Advanced Features

App of Apps Pattern

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: apps
spec:
source:
path: apps
repoURL: https://github.com/org/apps.git
destination:
namespace: argocd
server: https://kubernetes.default.svc

Sync Windows

apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: myproject
spec:
syncWindows:
- kind: allow
schedule: "10 1 * * *"
duration: 1h

Monitoring and Troubleshooting

  1. Sync Status

    Terminal window
    argocd app get myapp
    argocd app sync myapp
  2. Logs

    Terminal window
    argocd app logs myapp
    kubectl logs deployment/argocd-application-controller -n argocd
  3. Diff

    Terminal window
    argocd app diff myapp

Conclusion

Effective application management in ArgoCD requires understanding:

  • Application creation and configuration
  • Sync strategies and policies
  • Health checks and monitoring
  • Resource hooks and advanced patterns

In the next part, we’ll explore advanced topics including:

  • Multi-cluster management
  • SSO integration
  • Custom resource management
  • Notification systems