GitOps with ArgoCD: Managing Kubernetes the Right Way
GitOps makes Kubernetes deployments predictable and auditable. Learn how to set up ArgoCD and implement GitOps practices for your clusters.
Why GitOps Changed How I Think About Deployments
Before GitOps, my Kubernetes deployments were a mess. Kubectl commands run from laptops, different versions in different clusters, no clear audit trail.
GitOps flips this around: Git becomes the single source of truth. What's in Git is what's running. No exceptions.
GitOps Principles
- Declarative: Describe what you want, not how to get there
- Versioned: All changes go through Git
- Automated: Changes in Git automatically apply to clusters
- Auditable: Git history shows who changed what and when
Setting Up ArgoCD
Installation
Create the argocd namespace and apply the installation manifest. Wait for pods to be ready, then get the initial admin password from the secret.
CLI Installation
Install the ArgoCD CLI using brew on macOS or download the binary for Linux.
Repository Structure
gitops-repo/
├── apps/ # Application definitions
│ ├── production/
│ ├── staging/
│ └── dev/
├── base/ # Base Kubernetes manifests
├── overlays/ # Environment-specific patches
└── projects/ # ArgoCD project definitionsCreating Your First Application
Create an Application resource that points to your Git repo, specifies the path to your manifests, and defines where to deploy.
Enable automated sync with prune (delete resources not in Git) and selfHeal (fix drift automatically).
Deployment Workflows
Standard Workflow
- Developer creates PR with manifest changes
- CI validates YAML and runs security scans
- PR review and approval
- Merge to main
- ArgoCD detects change and syncs
Image Updates
Use ArgoCD Image Updater to automatically update image tags in your Git repo when new images are pushed.
Multi-Cluster Management
App of Apps Pattern
Manage multiple applications with one parent Application.
ApplicationSet for Multi-Cluster
Deploy the same app to multiple clusters using ApplicationSet with cluster generators.
Security Best Practices
RBAC Configuration
Create AppProjects that restrict repos, clusters, and who can sync.
Sealed Secrets
Never store plain secrets in Git. Use Sealed Secrets or external secret managers.
Getting Started Checklist
- Install ArgoCD in your cluster
- Set up a GitOps repository
- Create your first Application resource
- Enable auto-sync on a non-production app
- Set up sealed secrets
- Configure RBAC
- Add monitoring and alerting
- Document your deployment process
GitOps takes some setup, but the payoff is huge: predictable deployments, easy rollbacks, and a complete audit trail.
Questions & Answers
Related Articles
Need Help with Your Security?
Our team of security experts can help you implement the strategies discussed in this article.
Contact Us