$npx -y skills add ancoleman/ai-design-components --skill implementing-gitopsImplement GitOps continuous delivery for Kubernetes using ArgoCD or Flux. Use for automated deployments with Git as single source of truth, pull-based delivery, drift detection, multi-cluster management, and progressive rollouts.
| 1 | # GitOps Workflows |
| 2 | |
| 3 | Implement GitOps continuous delivery for Kubernetes using declarative, pull-based deployment models where Git serves as the single source of truth for infrastructure and application configuration. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | Use GitOps workflows for: |
| 8 | |
| 9 | - **Kubernetes Deployments:** Automating application and infrastructure deployments to Kubernetes clusters |
| 10 | - **Multi-Cluster Management:** Managing deployments across development, staging, production, and edge clusters |
| 11 | - **Continuous Delivery:** Implementing pull-based CD pipelines with automated reconciliation |
| 12 | - **Drift Detection:** Automatically detecting and correcting configuration drift from desired state |
| 13 | - **Audit Requirements:** Maintaining complete audit trails via Git commits for compliance |
| 14 | - **Progressive Delivery:** Implementing canary, blue-green, or rolling deployment strategies |
| 15 | - **Disaster Recovery:** Enabling rapid cluster recovery with GitOps bootstrap processes |
| 16 | |
| 17 | Trigger keywords: "deploy to Kubernetes", "ArgoCD setup", "Flux bootstrap", "GitOps pipeline", "environment promotion", "multi-cluster deployment", "automated reconciliation" |
| 18 | |
| 19 | ## Core GitOps Principles |
| 20 | |
| 21 | ### 1. Git as Single Source of Truth |
| 22 | |
| 23 | All system configuration stored in Git repositories. No manual kubectl apply or cluster modifications. Declarative manifests (YAML) for all Kubernetes resources, environment-specific overlays, infrastructure configuration, and application deployments. |
| 24 | |
| 25 | ### 2. Pull-Based Deployment |
| 26 | |
| 27 | Operators running inside clusters pull changes from Git and apply them automatically. Benefits include no cluster credentials in CI/CD pipelines, support for air-gapped environments, self-healing through continuous reconciliation, and simplified CI/CD. |
| 28 | |
| 29 | ### 3. Automated Reconciliation |
| 30 | |
| 31 | GitOps operators continuously compare actual cluster state with desired state in Git and reconcile differences through a continuous loop: watch Git, compare live state, apply differences, report status, repeat. |
| 32 | |
| 33 | ### 4. Declarative Configuration |
| 34 | |
| 35 | Use declarative Kubernetes manifests (not imperative scripts) to define desired state. |
| 36 | |
| 37 | ## Tool Selection |
| 38 | |
| 39 | ### ArgoCD vs Flux |
| 40 | |
| 41 | | Decision Factor | Choose ArgoCD | Choose Flux | |
| 42 | |----------------|---------------|-------------| |
| 43 | | **Team Preference** | Visual management with web UI | CLI/API-first workflows | |
| 44 | | **Learning Curve** | Easier onboarding with UI | Steeper but more flexible | |
| 45 | | **Architecture** | Monolithic, stateful controller | Modular, stateless controllers | |
| 46 | | **Multi-Tenancy** | Built-in RBAC and projects | Kubernetes-native RBAC | |
| 47 | | **Resource Usage** | Higher (includes UI components) | Lower (minimal controllers) | |
| 48 | | **Best For** | Transitioning to GitOps | Platform engineering | |
| 49 | |
| 50 | **Hybrid Approach:** Some teams use Flux for infrastructure and ArgoCD for applications. |
| 51 | |
| 52 | For ArgoCD implementation patterns, see references/argocd-patterns.md |
| 53 | For Flux implementation patterns, see references/flux-patterns.md |
| 54 | For Kustomize overlay patterns, see references/kustomize-overlays.md |
| 55 | |
| 56 | ## Quick Start |
| 57 | |
| 58 | ### ArgoCD Installation |
| 59 | |
| 60 | ```bash |
| 61 | kubectl create namespace argocd |
| 62 | kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml |
| 63 | ``` |
| 64 | |
| 65 | **Basic Application:** |
| 66 | ```yaml |
| 67 | apiVersion: argoproj.io/v1alpha1 |
| 68 | kind: Application |
| 69 | metadata: |
| 70 | name: myapp |
| 71 | namespace: argocd |
| 72 | spec: |
| 73 | project: default |
| 74 | source: |
| 75 | repoURL: https://github.com/org/repo.git |
| 76 | targetRevision: HEAD |
| 77 | path: k8s/overlays/prod |
| 78 | destination: |
| 79 | server: https://kubernetes.default.svc |
| 80 | namespace: myapp |
| 81 | syncPolicy: |
| 82 | automated: |
| 83 | prune: true |
| 84 | selfHeal: true |
| 85 | ``` |
| 86 | |
| 87 | ### Flux Bootstrap |
| 88 | |
| 89 | ```bash |
| 90 | flux bootstrap github \ |
| 91 | --owner=myorg \ |
| 92 | --repository=fleet-infra \ |
| 93 | --branch=main \ |
| 94 | --path=clusters/production |
| 95 | ``` |
| 96 | |
| 97 | **Basic Kustomization:** |
| 98 | ```yaml |
| 99 | apiVersion: kustomize.toolkit.fluxcd.io/v1 |
| 100 | kind: Kustomization |
| 101 | metadata: |
| 102 | name: myapp |
| 103 | namespace: flux-system |
| 104 | spec: |
| 105 | interval: 10m |
| 106 | path: "./k8s/prod" |
| 107 | prune: true |
| 108 | sourceRef: |
| 109 | kind: GitRepository |
| 110 | name: myapp |
| 111 | ``` |
| 112 | |
| 113 | For complete examples, see examples/argocd/ and examples/flux/ |
| 114 | |
| 115 | ## Environment Promotion |
| 116 | |
| 117 | **Branch-Based Strategy:** dev branch → staging branch → main branch (prod) |
| 118 | **Kustomize-Based Strategy:** k8s/base/ → k8s/overlays/{dev,staging,prod}/ |
| 119 | |
| 120 | **Promotion Process:** |
| 121 | 1. Merge code changes to main branch |
| 122 | 2. CI builds container image with tag |
| 123 | 3. Update image tag in environment overlay (Git commit) |
| 124 | 4. GitOps operator detects change and deploys |
| 125 | 5. Test in environment |
| 126 | 6. Promote to next environment by updating Git |
| 127 | |
| 128 | For multi-environment ApplicationSet patterns, see references/argocd-patterns.md |
| 129 | |
| 130 | ## Multi-Cluster Management |
| 131 | |
| 132 | **ArgoCD:** Register external clusters with argocd CLI, use ApplicationSet |