Implement GitOps workflows with ArgoCD and Flux for automated, declarative Kubernetes deployments with continuous reconciliation. Use when implementing GitOps practices, automating Kubernetes deployments, or setting up declarative infrastructure management.
Add this skill
npx mdskills install sickn33/gitops-workflowComprehensive GitOps guide with detailed ArgoCD/Flux setup and progressive delivery patterns
1---2name: gitops-workflow3description: Implement GitOps workflows with ArgoCD and Flux for automated, declarative Kubernetes deployments with continuous reconciliation. Use when implementing GitOps practices, automating Kubernetes deployments, or setting up declarative infrastructure management.4---56# GitOps Workflow78Complete guide to implementing GitOps workflows with ArgoCD and Flux for automated Kubernetes deployments.910## Purpose1112Implement declarative, Git-based continuous delivery for Kubernetes using ArgoCD or Flux CD, following OpenGitOps principles.1314## Use this skill when1516- Set up GitOps for Kubernetes clusters17- Automate application deployments from Git18- Implement progressive delivery strategies19- Manage multi-cluster deployments20- Configure automated sync policies21- Set up secret management in GitOps2223## Do not use this skill when2425- You need a one-off manual deployment26- You cannot manage cluster access or repo permissions27- You are not deploying to Kubernetes2829## Instructions30311. Define repo layout and desired-state conventions.322. Install ArgoCD or Flux and connect clusters.333. Configure sync policies, environments, and promotion flow.344. Validate rollbacks and secret handling.3536## Safety3738- Avoid auto-sync to production without approvals.39- Keep secrets out of Git and use sealed or external secret managers.4041## OpenGitOps Principles42431. **Declarative** - Entire system described declaratively442. **Versioned and Immutable** - Desired state stored in Git453. **Pulled Automatically** - Software agents pull desired state464. **Continuously Reconciled** - Agents reconcile actual vs desired state4748## ArgoCD Setup4950### 1. Installation5152```bash53# Create namespace54kubectl create namespace argocd5556# Install ArgoCD57kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml5859# Get admin password60kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d61```6263**Reference:** See `references/argocd-setup.md` for detailed setup6465### 2. Repository Structure6667```68gitops-repo/69├── apps/70│ ├── production/71│ │ ├── app1/72│ │ │ ├── kustomization.yaml73│ │ │ └── deployment.yaml74│ │ └── app2/75│ └── staging/76├── infrastructure/77│ ├── ingress-nginx/78│ ├── cert-manager/79│ └── monitoring/80└── argocd/81 ├── applications/82 └── projects/83```8485### 3. Create Application8687```yaml88# argocd/applications/my-app.yaml89apiVersion: argoproj.io/v1alpha190kind: Application91metadata:92 name: my-app93 namespace: argocd94spec:95 project: default96 source:97 repoURL: https://github.com/org/gitops-repo98 targetRevision: main99 path: apps/production/my-app100 destination:101 server: https://kubernetes.default.svc102 namespace: production103 syncPolicy:104 automated:105 prune: true106 selfHeal: true107 syncOptions:108 - CreateNamespace=true109```110111### 4. App of Apps Pattern112113```yaml114apiVersion: argoproj.io/v1alpha1115kind: Application116metadata:117 name: applications118 namespace: argocd119spec:120 project: default121 source:122 repoURL: https://github.com/org/gitops-repo123 targetRevision: main124 path: argocd/applications125 destination:126 server: https://kubernetes.default.svc127 namespace: argocd128 syncPolicy:129 automated: {}130```131132## Flux CD Setup133134### 1. Installation135136```bash137# Install Flux CLI138curl -s https://fluxcd.io/install.sh | sudo bash139140# Bootstrap Flux141flux bootstrap github \142 --owner=org \143 --repository=gitops-repo \144 --branch=main \145 --path=clusters/production \146 --personal147```148149### 2. Create GitRepository150151```yaml152apiVersion: source.toolkit.fluxcd.io/v1153kind: GitRepository154metadata:155 name: my-app156 namespace: flux-system157spec:158 interval: 1m159 url: https://github.com/org/my-app160 ref:161 branch: main162```163164### 3. Create Kustomization165166```yaml167apiVersion: kustomize.toolkit.fluxcd.io/v1168kind: Kustomization169metadata:170 name: my-app171 namespace: flux-system172spec:173 interval: 5m174 path: ./deploy175 prune: true176 sourceRef:177 kind: GitRepository178 name: my-app179```180181## Sync Policies182183### Auto-Sync Configuration184185**ArgoCD:**186```yaml187syncPolicy:188 automated:189 prune: true # Delete resources not in Git190 selfHeal: true # Reconcile manual changes191 allowEmpty: false192 retry:193 limit: 5194 backoff:195 duration: 5s196 factor: 2197 maxDuration: 3m198```199200**Flux:**201```yaml202spec:203 interval: 1m204 prune: true205 wait: true206 timeout: 5m207```208209**Reference:** See `references/sync-policies.md`210211## Progressive Delivery212213### Canary Deployment with ArgoCD Rollouts214215```yaml216apiVersion: argoproj.io/v1alpha1217kind: Rollout218metadata:219 name: my-app220spec:221 replicas: 5222 strategy:223 canary:224 steps:225 - setWeight: 20226 - pause: {duration: 1m}227 - setWeight: 50228 - pause: {duration: 2m}229 - setWeight: 100230```231232### Blue-Green Deployment233234```yaml235strategy:236 blueGreen:237 activeService: my-app238 previewService: my-app-preview239 autoPromotionEnabled: false240```241242## Secret Management243244### External Secrets Operator245246```yaml247apiVersion: external-secrets.io/v1beta1248kind: ExternalSecret249metadata:250 name: db-credentials251spec:252 refreshInterval: 1h253 secretStoreRef:254 name: aws-secrets-manager255 kind: SecretStore256 target:257 name: db-credentials258 data:259 - secretKey: password260 remoteRef:261 key: prod/db/password262```263264### Sealed Secrets265266```bash267# Encrypt secret268kubeseal --format yaml < secret.yaml > sealed-secret.yaml269270# Commit sealed-secret.yaml to Git271```272273## Best Practices2742751. **Use separate repos or branches** for different environments2762. **Implement RBAC** for Git repositories2773. **Enable notifications** for sync failures2784. **Use health checks** for custom resources2795. **Implement approval gates** for production2806. **Keep secrets out of Git** (use External Secrets)2817. **Use App of Apps pattern** for organization2828. **Tag releases** for easy rollback2839. **Monitor sync status** with alerts28410. **Test changes** in staging first285286## Troubleshooting287288**Sync failures:**289```bash290argocd app get my-app291argocd app sync my-app --prune292```293294**Out of sync status:**295```bash296argocd app diff my-app297argocd app sync my-app --force298```299300## Related Skills301302- `k8s-manifest-generator` - For creating manifests303- `helm-chart-scaffolding` - For packaging applications304
Full transparency — inspect the skill content before installing.