Loading...
Loading...
Comprehensive GitOps methodology and principles skill for cloud-native operations. Use when (1) Designing GitOps architecture for Kubernetes deployments, (2) Implementing declarative infrastructure with Git as single source of truth, (3) Setting up continuous deployment pipelines with ArgoCD/Flux/Kargo, (4) Establishing branching strategies and repository structures, (5) Troubleshooting drift, sync failures, or reconciliation issues, (6) Evaluating GitOps tooling decisions, (7) Teaching or explaining GitOps concepts and best practices, (8) Deploying ArgoCD on Azure Arc-enabled Kubernetes or AKS with workload identity. Covers the 4 pillars of GitOps (OpenGitOps), patterns, anti-patterns, tooling ecosystem, Azure Arc integration, and operational guidance.
npx skill4agent add julianobarbosa/claude-code-skills gitops-principles-skill| Principle | Description |
|---|---|
| 1. Declarative | The entire system must be described declaratively |
| 2. Versioned and Immutable | Desired state is stored in a way that enforces immutability, versioning, and retention |
| 3. Pulled Automatically | Software agents automatically pull desired state from the source |
| 4. Continuously Reconciled | Agents continuously observe and attempt to apply desired state |
┌─────────────────────────────────────────────────────────────────┐
│ GIT REPOSITORY │
│ (Single Source of Truth for Desired State) │
├─────────────────────────────────────────────────────────────────┤
│ manifests/ │
│ ├── base/ # Base configurations │
│ │ ├── deployment.yaml │
│ │ ├── service.yaml │
│ │ └── kustomization.yaml │
│ └── overlays/ # Environment-specific │
│ ├── dev/ │
│ ├── staging/ │
│ └── production/ │
└─────────────────────────────────────────────────────────────────┘
│
▼ Pull (not Push)
┌─────────────────────────────────────────────────────────────────┐
│ GITOPS CONTROLLER │
│ (ArgoCD / Flux / Kargo) │
│ - Continuously watches Git repository │
│ - Compares desired state vs actual state │
│ - Reconciles differences automatically │
└─────────────────────────────────────────────────────────────────┘
│
▼ Apply
┌─────────────────────────────────────────────────────────────────┐
│ KUBERNETES CLUSTER │
│ (Actual State / Runtime Environment) │
└─────────────────────────────────────────────────────────────────┘| Push Model (Traditional CI/CD) | Pull Model (GitOps) |
|---|---|
| CI system pushes changes to cluster | Agent pulls changes from Git |
| Requires cluster credentials in CI | Credentials stay within cluster |
| Point-in-time deployment | Continuous reconciliation |
| Drift goes undetected | Drift automatically corrected |
| Manual rollback process | Rollback = |
git revertgitops-repo/
├── apps/
│ ├── app-a/
│ │ ├── base/
│ │ └── overlays/
│ │ ├── dev/
│ │ ├── staging/
│ │ └── prod/
│ └── app-b/
└── infrastructure/
├── monitoring/
└── networking/# Repository per concern
app-a-config/ # App A manifests
app-b-config/ # App B manifests
infrastructure/ # Shared infrastructure
cluster-bootstrap/ # Cluster setupinfra-team/ # Base configurations, ApplicationSets
├── applications/ # ArgoCD Application definitions
└── helm-base-values/ # Default Helm values
argo-cd-helm-values/ # Environment-specific overrides
├── dev/ # Development values
├── stg/ # Staging values
└── prd/ # Production valuesmain ────────────────────────────────────► Production
│
└──► staging ──────────────────────────► Staging cluster
│
└──► develop ───────────────────► Development clustermain ────────────────────────────────────► All environments
│
├── overlays/dev/ → Dev cluster
├── overlays/staging/ → Staging cluster
└── overlays/prod/ → Prod clustermain
│
├── release/v1.0 ──────► Production (v1.0)
├── release/v1.1 ──────► Production (v1.1)
└── release/v2.0 ──────► Production (v2.0)syncPolicy:
automated:
prune: true # Delete resources not in Git
selfHeal: true # Revert manual changessyncPolicy:
automated: null # Require explicit sync| Option | Use Case |
|---|---|
| Auto-create missing namespaces |
| Delete after successful sync |
| Handle large CRDs |
| Performance optimization |
| Force resource replacement |
# base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
# overlays/prod/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
patchesStrategicMerge:
- replica-patch.yaml
images:
- name: myapp
newTag: v1.2.3# Application pointing to Helm chart
spec:
source:
repoURL: https://charts.example.com
chart: my-app
targetRevision: 1.2.3
helm:
releaseName: my-app
valueFiles:
- values.yaml
- values-prod.yamlspec:
sources:
- repoURL: https://charts.bitnami.com/bitnami
chart: nginx
targetRevision: 15.0.0
helm:
valueFiles:
- $values/nginx/values-prod.yaml
- repoURL: https://github.com/org/values.git
targetRevision: main
ref: values# Two applications, traffic shift via Ingress/Service
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-blue
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-greenapiVersion: argoproj.io/v1alpha1
kind: Rollout
spec:
strategy:
canary:
steps:
- setWeight: 10
- pause: {duration: 5m}
- setWeight: 50
- pause: {duration: 10m}Warehouse → Dev Stage → Staging Stage → Production Stage
│ │ │ │
└── Freight promotion through environments ───┘# Simple installation (single node)
az k8s-extension create \
--resource-group <rg> --cluster-name <cluster> \
--cluster-type managedClusters \
--name argocd \
--extension-type Microsoft.ArgoCD \
--release-train preview \
--config deployWithHighAvailability=false
# Production with workload identity (recommended)
# Use Bicep template - see references/azure-arc-integration.md| Feature | Description |
|---|---|
| Managed Installation | Azure handles deployment and upgrades |
| Workload Identity | Azure AD authentication without secrets |
| Multi-Cluster | Consistent GitOps across hybrid environments |
| Azure Integration | Native ACR, Key Vault, Azure AD support |
Microsoft.KubernetesConfigurationk8s-extensionreferences/azure-arc-integration.md| Approach | Tool |
|---|---|
| External Secrets | External Secrets Operator |
| Sealed Secrets | Bitnami Sealed Secrets |
| SOPS | Mozilla SOPS encryption |
| Vault | HashiCorp Vault + CSI |
| Cloud KMS | AWS/Azure/GCP Key Management |
# Limit ArgoCD to specific namespaces
apiVersion: argoproj.io/v1alpha1
kind: AppProject
spec:
destinations:
- namespace: 'team-a-*'
server: https://kubernetes.default.svc
sourceRepos:
- 'https://github.com/org/team-a-*'| Status | Meaning | Action |
|---|---|---|
| Healthy | All resources running | None |
| Progressing | Deployment in progress | Wait |
| Degraded | Health check failed | Investigate |
| Suspended | Manually paused | Resume when ready |
| Missing | Resource not found | Check manifests |
# Check application diff
argocd app diff myapp
# Force refresh from Git
argocd app get myapp --refreshreferences/core-principles.mdreferences/patterns-and-practices.mdreferences/tooling-ecosystem.mdreferences/anti-patterns.mdreferences/troubleshooting.mdreferences/azure-arc-integration.mdtemplates/application.yamlapplicationset.yamlkustomization.yamlscripts/gitops-health-check.sh