ArgoCD: Fundamentals
ArgoCD Architecture and Components
ArgoCD is a GitOps continuous deployment tool that ensures your Kubernetes applications stay in sync with their declared Git state. Here’s a breakdown of its key components:
- API Server: The front desk of ArgoCD, handling user requests from CLI, UI, and API.
- Controller: The enforcer. It continuously monitors application states and syncs them with the Git repository.
- Repository Server: The librarian. It fetches, caches, and manages application manifests from Git.
- Application Controller: The babysitter. It ensures applications match their declared configurations and auto-fixes any unauthorized changes.
Want proof it’s working? Run:
kubectl get pods -n argocdIf things look good, congratulations—you’re one step closer to GitOps greatness.
Creating Applications and Syncing with Git Repositories
ArgoCD doesn’t do magic—it just makes Kubernetes deployments less painful. Let’s create an application and sync it with Git.
Creating an ArgoCD Application
argocd app create myapp \
--repo https://github.com/myrepo.git \
--path k8s-manifests \
--dest-server https://kubernetes.default.svc \
--dest-namespace default--repo: The Git repository storing Kubernetes manifests.--path: The subdirectory containing the application configs.--dest-server: The target Kubernetes cluster.--dest-namespace: Where the application will live.
Viewing Application Status
Need to check on your app’s life choices? Run:
argocd app get myappThis command tells you if it’s in sync or running wild.
Manual Synchronization
If auto-sync isn’t enabled (because why make life easy?), manually sync your app:
argocd app sync myappEnabling Automatic Synchronization
Want ArgoCD to act like a responsible adult and fix everything automatically? Add this to your app manifest:
spec:
syncPolicy:
automated:
prune: true
selfHeal: trueprune: true: Deletes cluster resources that don’t exist in Git.selfHeal: true: Reverts any sneaky manual changes.
Declarative Application Management
For full GitOps compliance (and fewer headaches), manage ArgoCD applications using YAML.
Example Application Manifest
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/myrepo.git
path: k8s-manifests
targetRevision: HEAD
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: truemetadata.name: Application name.source.repoURL: Git repository storing the manifests.destination.server: Kubernetes cluster API.syncPolicy: Auto-sync behavior (because we like automation).
Applying the Manifest
Deploy the app with:
kubectl apply -f myapp.yamlChecking Application Synchronization
See all ArgoCD-managed applications:
argocd app listHands-On Exercise
Let’s get practical! Follow these steps:
- Create an ArgoCD application using the CLI
- Use
argocd app createto deploy from Git.
- Use
- Deploy an application using a Git repository
- Ensure Kubernetes reflects the desired state.
- Enable and test automatic synchronization
- Modify the Git manifest and watch ArgoCD update your app automatically.
- Manage an ArgoCD application declaratively using YAML
- Define an
Applicationresource and apply it usingkubectl apply.
- Define an
By completing these exercises, you’ll master the basics of ArgoCD and GitOps—no more manually fixing broken Kubernetes deployments!