
Simplifying Kubernetes with ArgoCD: Your Go-To GitOps Solution
Managing Kubernetes deployments across multiple environments can feel like herding cats. That’s where ArgoCD, a fantastic GitOps tool, comes in, making life easier by syncing your Kubernetes clusters with Git repos. I’ve put together a GitHub repository, soodrajesh/argocd-setup, that’s packed with everything you need for a production-ready ArgoCD setup tailored for enterprise Kubernetes workflows. Let me walk you through what it offers, how to get started, and some handy code snippets to make it real. Plus, I’ll throw in some example commands and answer common questions at the end.
Why ArgoCD Rocks for GitOps
GitOps is a game-changer — using Git as the single source of truth for your infrastructure and apps. ArgoCD, a CNCF-graduated project, automates Kubernetes deployments, keeping things consistent and making rollbacks a breeze. My argocd-setup repo builds on that, adding enterprise-grade features like security, scalability, and monitoring to make your DevOps life smoother.
What’s in the Box?
- One-Click Install: Deploy ArgoCD with a single command, baked with best practices.
- Security Focus: RBAC, TLS, and integrations with tools like AWS Secrets Manager and HashiCorp Vault.
- Multi-Environment Ready: Handles dev, staging, and production like a pro.
- High Availability: Built for production with a scalable HA setup.
- Monitoring Goodies: Prometheus metrics, Grafana dashboards, and alerts for when things go sideways.
- Backup & Recovery: Automated scripts to save your bacon in a disaster.
Getting Up and Running
Setting up ArgoCD with this repo is pretty straightforward, even for complex setups. Here’s how to dive in, with some code snippets and example commands to keep it real.
What You’ll Need
Before you start, make sure you’ve got:
- A Kubernetes cluster (v1.20 or higher) with admin access.
kubectlset up for your cluster.- Helm 3.x installed.
- AWS CLI configured if you’re using EKS.
- A Git repo for your apps.
- (Optional) A domain name for ingress.
Quick Start Steps
- Clone and ConfigureGrab the repo and tweak the config to fit your setup:
git clone https://github.com/soodrajesh/argocd-setup.git cd argocd-setup cp config/config.example.yaml config/config.yaml
Open config/config.yaml in your favorite editor and add your cluster details.
Example Command:
nano config/config.yaml
Sample config.yaml Snippet:
cluster: name: “my-prod-cluster” region: “us-east-1”argocd: namespace: “argocd” version: “v2.8.4”
2. Deploy ArgoCDFire up the install script to get ArgoCD running
./scripts/install.sh
Want to use a custom config? Try this:
./scripts/install.sh --config config/production.yaml
Example Command:
./scripts/install.sh --config config/production.yaml --ha
Snippet from install.sh:
#!/bin/bash
CONFIG_FILE="config/config.yaml"
while [[ "$#" -gt 0 ]]; do
case $1 in
--config) CONFIG_FILE="$2"; shift ;;
--ha) HA_ENABLED="true" ;;
esac
shift
done
helm install argocd -n argocd --create-namespace -f "$CONFIG_FILE" .
3. Access the ArgoCD UIGet the admin password and port-forward to the UI:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d kubectl port-forward svc/argocd-server -n argocd 8080:443
Then, head to https://localhost:8080, log in with username admin and the password you got.
Example Command:
kubectl port-forward svc/argocd-server -n argocd 8080:443 &
Keeping Things Secure
Security is a big deal in this repo. Here’s what you get:
- RBAC: Roles for admins, developers, and viewers, with LDAP/OIDC group support.
- Network Security: TLS for all communications and network policies to lock down pod traffic.
- Secret Management: Works with AWS Secrets Manager, Sealed Secrets, or HashiCorp Vault.
Example RBAC Config Snippet:
security:
rbac:
enabled: true
policy: |
p, role:admin, applications, *, */*, allow
p, role:dev, applications, get, */*, allow
g, argocd-admins, role:admin
Example Command to Apply RBAC:
kubectl apply -f config/production.yaml
Deploying Your Apps
Deploying apps is a breeze with prebuilt manifests. Here’s an example Application manifest:
Sample Application Manifest:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-cool-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/your-org/my-cool-app
targetRevision: main
path: k8s
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true
Apply it with:
./scripts/deploy-apps.sh applications/
Example Command:
./scripts/deploy-apps.sh applications/my-cool-app.yaml
Snippet from deploy-apps.sh:
#!/bin/bash
for app in applications/*.yaml; do
kubectl apply -f "$app"
done
Monitoring Your Setup
The repo hooks up Prometheus for metrics and Grafana for slick dashboards, plus alerts for sync issues. It also supports structured JSON logging and ELK/EFK stack integration.
Example Prometheus Config Snippet:
prometheus:
enabled: true
serviceMonitor:
enabled: true
namespace: monitoring
Example Command to Check Metrics:
kubectl get servicemonitor -n monitoring
High Availability and Multi-Cluster
For production, enable HA:
./scripts/install.sh --ha --config config/production.yaml
Example HA Config Snippet:
argocd:
ha:
enabled: true
replicas: 3
Manage multiple clusters like this:
argocd cluster add my-prod-cluster
./scripts/deploy-multi-cluster.sh
Example Command:
argocd cluster list
Troubleshooting Tips
If something goes wrong, use these scripts:
- Check app status:
argocd app get my-cool-app - View logs:
argocd app logs my-cool-app - Force a sync:
argocd app sync my-cool-app --force
Example Troubleshooting Command:
argocd app sync my-cool-app --force
Snippet from health-check.sh:
#!/bin/bash
argocd app list | while read -r app; do
status=$(argocd app get "$app" --output json | jq -r '.status.health.status')
echo "Application $app health: $status"
done
Why This Repo?
The argocd-setup repo makes Kubernetes management feel less like a chore. It’s got everything you need—automation, security, and monitoring—to handle complex setups with ease. Whether you’re running one cluster or juggling multiple environments, this setup has your back.
FAQs
What’s ArgoCD, and why should I care?
ArgoCD is a GitOps tool that automates Kubernetes deployments by syncing with Git. It keeps things consistent and makes rollbacks super easy.
Does this work with non-AWS clusters?
Yup! It works with any Kubernetes cluster (v1.20+). Just tweak config.yaml for your environment.
How do I turn on high availability?
Set ha.enabled: true in your config and run ./scripts/install.sh --ha.
What if my app sync fails?
Run argocd app get my-cool-app to check status, argocd app logs my-cool-app for logs, or argocd app sync my-cool-app --force to force a sync.
How can I help improve this project?
Fork the repo, create a feature branch, make your changes, and submit a pull request. Check the Contributing section for more.
If this repo saves you time, give it a star on GitHub! Got questions? Hit up the repo’s issues page.
📢 Have questions or feedback? Drop a comment below or connect with me on Twitter/X@spysood!
Originally published on Medium.