GitOps Fundamentals
Core Principles
- Declarative Infrastructure
- Version Controlled Changes
- Automated Reconciliation
- Self-healing Systems
Implementation Patterns
ArgoCD Application Configuration
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: production-app
spec:
project: default
source:
repoURL: https://github.com/org/app-config.git
targetRevision: HEAD
path: environments/production
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
Workflow Patterns
Multi-Environment Setup
# environments/base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- ingress.yaml
# environments/production/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../base
patchesStrategicMerge:
- production-patches.yaml
Security Practices
RBAC Configuration
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: gitops-deployer
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
Production Example
# Complete GitOps application setup
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: full-stack-app
namespace: argocd
spec:
project: production
source:
repoURL: https://github.com/org/app-config.git
targetRevision: main
path: environments/production
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m
These patterns ensure reliable, automated deployment workflows.