$npx -y skills add BagelHole/DevOps-Security-Agent-Skills --skill argocd-gitopsImplement 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.
| 1 | # ArgoCD GitOps |
| 2 | |
| 3 | Implement declarative continuous delivery for Kubernetes with ArgoCD. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when: |
| 8 | - Implementing GitOps workflows for Kubernetes |
| 9 | - Automating deployments from Git repositories |
| 10 | - Managing multiple environments declaratively |
| 11 | - Implementing progressive delivery strategies |
| 12 | - Synchronizing cluster state with Git |
| 13 | |
| 14 | ## Prerequisites |
| 15 | |
| 16 | - Kubernetes cluster with ArgoCD installed |
| 17 | - kubectl configured |
| 18 | - Git repository for manifests |
| 19 | - ArgoCD CLI (optional) |
| 20 | |
| 21 | ## Installation |
| 22 | |
| 23 | ```bash |
| 24 | # Create namespace |
| 25 | kubectl create namespace argocd |
| 26 | |
| 27 | # Install ArgoCD |
| 28 | kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml |
| 29 | |
| 30 | # Get admin password |
| 31 | kubectl -n argocd get secret argocd-initial-admin-secret \ |
| 32 | -o jsonpath="{.data.password}" | base64 -d |
| 33 | |
| 34 | # Port forward to access UI |
| 35 | kubectl port-forward svc/argocd-server -n argocd 8080:443 |
| 36 | |
| 37 | # Login with CLI |
| 38 | argocd login localhost:8080 |
| 39 | ``` |
| 40 | |
| 41 | ## Application Definition |
| 42 | |
| 43 | ### Basic Application |
| 44 | |
| 45 | ```yaml |
| 46 | apiVersion: argoproj.io/v1alpha1 |
| 47 | kind: Application |
| 48 | metadata: |
| 49 | name: myapp |
| 50 | namespace: argocd |
| 51 | spec: |
| 52 | project: default |
| 53 | source: |
| 54 | repoURL: https://github.com/org/myapp-manifests.git |
| 55 | targetRevision: main |
| 56 | path: environments/production |
| 57 | destination: |
| 58 | server: https://kubernetes.default.svc |
| 59 | namespace: myapp |
| 60 | syncPolicy: |
| 61 | automated: |
| 62 | prune: true |
| 63 | selfHeal: true |
| 64 | syncOptions: |
| 65 | - CreateNamespace=true |
| 66 | ``` |
| 67 | |
| 68 | ### Helm Application |
| 69 | |
| 70 | ```yaml |
| 71 | apiVersion: argoproj.io/v1alpha1 |
| 72 | kind: Application |
| 73 | metadata: |
| 74 | name: myapp-helm |
| 75 | namespace: argocd |
| 76 | spec: |
| 77 | project: default |
| 78 | source: |
| 79 | repoURL: https://github.com/org/myapp-chart.git |
| 80 | targetRevision: main |
| 81 | path: charts/myapp |
| 82 | helm: |
| 83 | valueFiles: |
| 84 | - values.yaml |
| 85 | - values-production.yaml |
| 86 | parameters: |
| 87 | - name: replicaCount |
| 88 | value: "3" |
| 89 | - name: image.tag |
| 90 | value: "2.0.0" |
| 91 | destination: |
| 92 | server: https://kubernetes.default.svc |
| 93 | namespace: myapp |
| 94 | syncPolicy: |
| 95 | automated: |
| 96 | prune: true |
| 97 | selfHeal: true |
| 98 | ``` |
| 99 | |
| 100 | ### Kustomize Application |
| 101 | |
| 102 | ```yaml |
| 103 | apiVersion: argoproj.io/v1alpha1 |
| 104 | kind: Application |
| 105 | metadata: |
| 106 | name: myapp-kustomize |
| 107 | namespace: argocd |
| 108 | spec: |
| 109 | project: default |
| 110 | source: |
| 111 | repoURL: https://github.com/org/myapp-manifests.git |
| 112 | targetRevision: main |
| 113 | path: overlays/production |
| 114 | kustomize: |
| 115 | images: |
| 116 | - myapp=myregistry/myapp:2.0.0 |
| 117 | destination: |
| 118 | server: https://kubernetes.default.svc |
| 119 | namespace: myapp |
| 120 | ``` |
| 121 | |
| 122 | ## Projects |
| 123 | |
| 124 | ```yaml |
| 125 | apiVersion: argoproj.io/v1alpha1 |
| 126 | kind: AppProject |
| 127 | metadata: |
| 128 | name: myproject |
| 129 | namespace: argocd |
| 130 | spec: |
| 131 | description: My Project |
| 132 | sourceRepos: |
| 133 | - https://github.com/org/* |
| 134 | destinations: |
| 135 | - namespace: myapp-* |
| 136 | server: https://kubernetes.default.svc |
| 137 | clusterResourceWhitelist: |
| 138 | - group: '' |
| 139 | kind: Namespace |
| 140 | namespaceResourceWhitelist: |
| 141 | - group: '*' |
| 142 | kind: '*' |
| 143 | roles: |
| 144 | - name: developer |
| 145 | description: Developer role |
| 146 | policies: |
| 147 | - p, proj:myproject:developer, applications, get, myproject/*, allow |
| 148 | - p, proj:myproject:developer, applications, sync, myproject/*, allow |
| 149 | groups: |
| 150 | - developers |
| 151 | ``` |
| 152 | |
| 153 | ## Application Sets |
| 154 | |
| 155 | ### Git Generator |
| 156 | |
| 157 | ```yaml |
| 158 | apiVersion: argoproj.io/v1alpha1 |
| 159 | kind: ApplicationSet |
| 160 | metadata: |
| 161 | name: myapp-environments |
| 162 | namespace: argocd |
| 163 | spec: |
| 164 | generators: |
| 165 | - git: |
| 166 | repoURL: https://github.com/org/myapp-manifests.git |
| 167 | revision: main |
| 168 | directories: |
| 169 | - path: environments/* |
| 170 | template: |
| 171 | metadata: |
| 172 | name: 'myapp-{{path.basename}}' |
| 173 | spec: |
| 174 | project: default |
| 175 | source: |
| 176 | repoURL: https://github.com/org/myapp-manifests.git |
| 177 | targetRevision: main |
| 178 | path: '{{path}}' |
| 179 | destination: |
| 180 | server: https://kubernetes.default.svc |
| 181 | namespace: 'myapp-{{path.basename}}' |
| 182 | syncPolicy: |
| 183 | automated: |
| 184 | prune: true |
| 185 | selfHeal: true |
| 186 | ``` |
| 187 | |
| 188 | ### List Generator |
| 189 | |
| 190 | ```yaml |
| 191 | apiVersion: argoproj.io/v1alpha1 |
| 192 | kind: ApplicationSet |
| 193 | metadata: |
| 194 | name: myapp-clusters |
| 195 | namespace: argocd |
| 196 | spec: |
| 197 | generators: |
| 198 | - list: |
| 199 | elements: |
| 200 | - cluster: production |
| 201 | url: https://prod-cluster.example.com |
| 202 | - cluster: staging |
| 203 | url: https://staging-cluster.example.com |
| 204 | template: |
| 205 | metadata: |
| 206 | name: 'myapp-{{cluster}}' |
| 207 | spec: |
| 208 | project: default |
| 209 | source: |
| 210 | repoURL: https://github.com/org/myapp-manifests.git |
| 211 | targetRevision: main |
| 212 | path: 'environments/{{cluster}}' |
| 213 | destination: |
| 214 | server: '{{url}}' |
| 215 | namespace: myapp |