Skill v1.0.0
currentAutomated scan100/100name: argocd-gitops description: Implement GitOps with ArgoCD for declarative Kubernetes deployments. Configure applications, manage sync policies, implement progressive delivery, and automate deployments from Git repositories. Use when implementing GitOps workflows or continuous deployment to Kubernetes. license: MIT metadata: author: devops-skills version: "1.0"
ArgoCD GitOps
Implement declarative continuous delivery for Kubernetes with ArgoCD.
When to Use This Skill
Use this skill when:
- Implementing GitOps workflows for Kubernetes
- Automating deployments from Git repositories
- Managing multiple environments declaratively
- Implementing progressive delivery strategies
- Synchronizing cluster state with Git
Prerequisites
- Kubernetes cluster with ArgoCD installed
- kubectl configured
- Git repository for manifests
- ArgoCD CLI (optional)
Installation
# Create namespacekubectl create namespace argocd# Install ArgoCDkubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml# Get admin passwordkubectl -n argocd get secret argocd-initial-admin-secret \-o jsonpath="{.data.password}" | base64 -d# Port forward to access UIkubectl port-forward svc/argocd-server -n argocd 8080:443# Login with CLIargocd login localhost:8080
Application Definition
Basic Application
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata:name: myappnamespace: argocdspec:project: defaultsource:repoURL: https://github.com/org/myapp-manifests.gittargetRevision: mainpath: environments/productiondestination:server: https://kubernetes.default.svcnamespace: myappsyncPolicy:automated:prune: trueselfHeal: truesyncOptions:- CreateNamespace=true
Helm Application
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata:name: myapp-helmnamespace: argocdspec:project: defaultsource:repoURL: https://github.com/org/myapp-chart.gittargetRevision: mainpath: charts/myapphelm:valueFiles:- values.yaml- values-production.yamlparameters:- name: replicaCountvalue: "3"- name: image.tagvalue: "2.0.0"destination:server: https://kubernetes.default.svcnamespace: myappsyncPolicy:automated:prune: trueselfHeal: true
Kustomize Application
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata:name: myapp-kustomizenamespace: argocdspec:project: defaultsource:repoURL: https://github.com/org/myapp-manifests.gittargetRevision: mainpath: overlays/productionkustomize:images:- myapp=myregistry/myapp:2.0.0destination:server: https://kubernetes.default.svcnamespace: myapp
Projects
apiVersion: argoproj.io/v1alpha1kind: AppProjectmetadata:name: myprojectnamespace: argocdspec:description: My ProjectsourceRepos:- https://github.com/org/*destinations:- namespace: myapp-*server: https://kubernetes.default.svcclusterResourceWhitelist:- group: ''kind: NamespacenamespaceResourceWhitelist:- group: '*'kind: '*'roles:- name: developerdescription: Developer rolepolicies:- p, proj:myproject:developer, applications, get, myproject/*, allow- p, proj:myproject:developer, applications, sync, myproject/*, allowgroups:- developers
Application Sets
Git Generator
apiVersion: argoproj.io/v1alpha1kind: ApplicationSetmetadata:name: myapp-environmentsnamespace: argocdspec:generators:- git:repoURL: https://github.com/org/myapp-manifests.gitrevision: maindirectories:- path: environments/*template:metadata:name: 'myapp-{{path.basename}}'spec:project: defaultsource:repoURL: https://github.com/org/myapp-manifests.gittargetRevision: mainpath: '{{path}}'destination:server: https://kubernetes.default.svcnamespace: 'myapp-{{path.basename}}'syncPolicy:automated:prune: trueselfHeal: true
List Generator
apiVersion: argoproj.io/v1alpha1kind: ApplicationSetmetadata:name: myapp-clustersnamespace: argocdspec:generators:- list:elements:- cluster: productionurl: https://prod-cluster.example.com- cluster: stagingurl: https://staging-cluster.example.comtemplate:metadata:name: 'myapp-{{cluster}}'spec:project: defaultsource:repoURL: https://github.com/org/myapp-manifests.gittargetRevision: mainpath: 'environments/{{cluster}}'destination:server: '{{url}}'namespace: myapp
Matrix Generator
apiVersion: argoproj.io/v1alpha1kind: ApplicationSetmetadata:name: myapp-matrixnamespace: argocdspec:generators:- matrix:generators:- git:repoURL: https://github.com/org/myapp-manifests.gitrevision: maindirectories:- path: apps/*- list:elements:- env: staging- env: productiontemplate:metadata:name: '{{path.basename}}-{{env}}'spec:project: defaultsource:repoURL: https://github.com/org/myapp-manifests.gittargetRevision: mainpath: '{{path}}/overlays/{{env}}'destination:server: https://kubernetes.default.svcnamespace: '{{path.basename}}-{{env}}'
Sync Policies
Automated Sync
syncPolicy:automated:prune: true # Delete resources not in GitselfHeal: true # Revert manual changesallowEmpty: false # Don't sync empty directoriessyncOptions:- CreateNamespace=true- PrunePropagationPolicy=foreground- PruneLast=trueretry:limit: 5backoff:duration: 5sfactor: 2maxDuration: 3m
Sync Waves
# In Kubernetes manifestsapiVersion: v1kind: ConfigMapmetadata:name: myconfigannotations:argocd.argoproj.io/sync-wave: "-1" # Sync first---apiVersion: apps/v1kind: Deploymentmetadata:name: myappannotations:argocd.argoproj.io/sync-wave: "0" # Sync second
Sync Hooks
apiVersion: batch/v1kind: Jobmetadata:name: migrationannotations:argocd.argoproj.io/hook: PreSyncargocd.argoproj.io/hook-delete-policy: HookSucceededspec:template:spec:containers:- name: migrateimage: myapp:latestcommand: ["./migrate.sh"]restartPolicy: Never
CLI Commands
# List applicationsargocd app list# Get application detailsargocd app get myapp# Sync applicationargocd app sync myapp# Force sync (ignore differences)argocd app sync myapp --force# View diffargocd app diff myapp# Rollbackargocd app rollback myapp# Delete applicationargocd app delete myapp# View logsargocd app logs myapp# Hard refresh (clear cache)argocd app get myapp --hard-refresh
Repository Configuration
apiVersion: v1kind: Secretmetadata:name: private-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:url: https://github.com/org/private-repo.gitusername: gitpassword: ghp_xxxx---# SSH keyapiVersion: v1kind: Secretmetadata:name: private-repo-sshnamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:url: git@github.com:org/private-repo.gitsshPrivateKey: |-----BEGIN OPENSSH PRIVATE KEY-----...-----END OPENSSH PRIVATE KEY-----
Notifications
apiVersion: v1kind: ConfigMapmetadata:name: argocd-notifications-cmnamespace: argocddata:service.slack: |token: $slack-tokentemplate.app-deployed: |message: Application {{.app.metadata.name}} is now {{.app.status.sync.status}}.trigger.on-deployed: |- when: app.status.operationState.phase in ['Succeeded']send: [app-deployed]
Common Issues
Issue: Sync Fails with Diff
Problem: Resources show differences but are correct Solution: Configure ignore differences
spec:ignoreDifferences:- group: appskind: DeploymentjsonPointers:- /spec/replicas
Issue: Repository Not Accessible
Problem: ArgoCD cannot clone repository Solution: Check repository secret, verify URL and credentials
Issue: Application Stuck OutOfSync
Problem: Application never becomes synced Solution: Check resource status, review events, verify manifests
Issue: Health Check Failing
Problem: Application shows degraded health Solution: Check custom health checks, verify probe configurations
Best Practices
- Use ApplicationSets for multi-environment deployments
- Implement sync waves for ordered deployments
- Use projects to isolate applications
- Configure notifications for deployment events
- Implement proper RBAC with projects
- Use health checks for deployment verification
- Enable auto-pruning to remove deleted resources
- Keep manifests in dedicated repositories
Related Skills
- kubernetes-ops - K8s fundamentals
- helm-charts - Helm deployments
- kustomize - Kustomize overlays