ArgoCD — GitOps for Kubernetes

Sanjeev SharmaSanjeev Sharma
1 min read

Advertisement

ArgoCD — GitOps for Kubernetes

ArgoCD brings GitOps principles to Kubernetes, enabling declarative, version-controlled deployments.

Introduction

ArgoCD synchronizes Kubernetes cluster state with Git repositories, making Git the single source of truth.

Installation

# Install ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

# Get password
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

# Port forward
kubectl port-forward -n argocd svc/argocd-server 8080:443

Applications

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/example/myapp
    path: k8s/
    targetRevision: main
  destination:
    server: https://kubernetes.default.svc
    namespace: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Sync Strategies

syncPolicy:
  # Auto-sync when Git changes
  automated:
    prune: true
    selfHeal: true
  # Manual sync
  syncOptions:
  - CreateNamespace=true

FAQ

Q: What's GitOps? A: Git repository is source of truth. ArgoCD synchronizes cluster to match Git state.

Q: What if cluster drifts from Git? A: With selfHeal enabled, ArgoCD automatically reconciles cluster back to Git state.

Advertisement

Sanjeev Sharma

Written by

Sanjeev Sharma

Full Stack Engineer · E-mopro