CI CD with Kubernetes Automating Deployments using Helm and Argo CD
Learn how to implement automated Kubernetes deployments using Helm charts and Argo CD for efficient CI CD workflows
In the world of cloud-native development, continuous integration and continuous deployment (CI/CD) is no longer optional — it’s essential. Kubernetes, as the container orchestration leader, pairs seamlessly with modern CI/CD tools to deliver scalable, automated deployment pipelines. In this post, we’ll dive into how to build an advanced CI/CD pipeline using Helm and Argo CD, with a focus on GitOps principles for managing Kubernetes applications.
What is CI/CD in Kubernetes?
CI/CD is a development practice that enables developers to integrate code changes frequently (CI) and deploy them automatically (CD). In Kubernetes, this process must:
- Be declarative and reproducible
- Track application and infrastructure changes via Git
- Maintain environment consistency across clusters
Helm and Argo CD provide powerful abstractions for these goals, turning YAML hell into manageable, version-controlled deployment strategies.
Overview of Tools: Helm and Argo CD
Helm
: The Kubernetes Package Manager
- Helm simplifies Kubernetes deployments by using charts, which are collections of templated YAML files.
- Allows parameterized configurations using values.yaml
- Supports versioning, rollbacks, and dependency management
Argo CD
: Declarative GitOps for Kubernetes
- Argo CD watches a Git repository for changes to deployment manifests.
- Automatically applies those changes to the Kubernetes cluster.
- Provides visual dashboards, sync strategies, and automatic rollbacks.
- Ideal for managing multi-environment deployments (e.g., dev, staging, prod).
Setting Up CI/CD: A Step-by-Step Guide
1. Create a Helm Chart for Your Application
Start by creating a Helm chart that describes your application’s Kubernetes manifests:
helm create my-app
Customize the following files:
templates/deployment.yaml
templates/service.yaml
values.yaml
Use values like:
replicaCount: 2
image:
repository: my-registry/my-app
tag: "1.0.0"
2. Version Control with Git
Push your Helm chart to a Git repository. Use branches or folders for different environments:
/charts
/dev
/staging
/prod
Each environment can have its own values.yaml
.
3. Set Up Argo CD
Install Argo CD in your cluster:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Access Argo CD UI and CLI, then register your Git repository:
argocd repo add https://github.com/your-org/your-repo.git
Create an application definition:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/your-org/your-repo.git
path: charts/dev
targetRevision: HEAD
helm:
valueFiles:
- values.yaml
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true
Apply it:
kubectl apply -f my-app.yaml
4. Integrate with a CI Pipeline
Use GitHub Actions, GitLab CI, or Jenkins to automate Helm packaging and GitOps commits.
Example GitHub Action to update Helm image tag:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update image tag
run: |
sed -i 's/tag:.*/tag: "$"/' charts/dev/values.yaml
git config user.name "CI Bot"
git config user.email "ci@yourcompany.com"
git commit -am "Update image tag to $"
git push
This triggers Argo CD to detect the Git change and apply the new deployment.
Argo CD Sync Strategies
Argo CD supports multiple sync options:
- Manual: Human-triggered deployment
- Auto: Automatically syncs on every Git change
- Self-heal: Automatically reverts out-of-band changes
Use sync waves and hooks to manage complex deployments involving DB migrations or canary releases.
Multi-Environment Support
Structure your Git repository like:
environments/
dev/
values.yaml
staging/
values.yaml
prod/
values.yaml
Each Argo CD application points to the appropriate path and branch:
source:
repoURL: https://github.com/your-org/your-repo.git
path: environments/prod
targetRevision: main
This enables isolated deployment flows and team-level access control.
Monitoring and Rollbacks
Argo CD UI provides:
- Live diff between Git and cluster
- Rollback button to previous commit
- Application health status
- Deployment history logs
Combine this with Prometheus + Grafana for monitoring and Slack alerts for real-time notifications.
Security Best Practices
- Use Argo CD RBAC policies to restrict access
- Enable SSO (OAuth, LDAP) for authentication
- Use GPG-signed commits in Git
- Store Helm secrets with tools like Sealed Secrets or HashiCorp Vault
- Protect production branches with PR approvals and CI checks
Conclusion
Implementing CI/CD with Kubernetes using Helm and Argo CD enables faster, safer, and more reliable deployments. By leveraging GitOps principles, you can bring automation, auditability, and traceability into your Kubernetes workflows.
Whether you’re deploying a simple microservice or managing complex applications across multiple clusters, Helm and Argo CD are essential tools in your DevOps toolkit.