Skip to main content

Helm

Helm is the package manager for Kubernetes that bundles manifests into versioned, parameterised charts so one chart can deploy to many environments with different values.

Understanding Helm in CI/CD

What Is Helm and Why Use It in a Pipeline

Helm packages the Deployment, Service, Ingress, ConfigMap, and other manifests of an application into one chart, and fills in values at install time. A release is one installed instance of a chart, and Helm records its history so you can roll back. In CI/CD the same chart deploys to dev, staging, and production with different values files.

Chart Layout and Values Layering

flowchart TD A[Chart: templates and defaults] --> D[helm upgrade --install] B[values-staging.yaml] --> D C[values-production.yaml] --> D D --> E[Rendered manifests] E --> F[Release in cluster] classDef src fill:#8B5CF6,color:#FFFFFF classDef tool fill:#326CE5,color:#FFFFFF classDef out fill:#10B981,color:#FFFFFF class A,B,C src class D,E tool class F out

Later -f files and --set flags override earlier ones, so defaults live in values.yaml and environment differences live in small override files.

Deploying from a Pipeline

YAML
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789:role/github-deploy
aws-region: ap-south-1
- name: Connect to cluster
run: aws eks update-kubeconfig --name mumbai-prod-cluster --region ap-south-1
- name: Deploy with Helm
run: |
helm upgrade --install payment-api ./charts/payment-api \
--namespace payment-api-production \
--values ./charts/payment-api/values-production.yaml \
--set image.repository=${{ env.ECR_REGISTRY }}/payment-api \
--set image.tag=${{ github.sha }} \
--atomic \
--timeout 5m

The --atomic flag waits for readiness and rolls back automatically if the upgrade fails or times out.

Default values.yaml

YAML
replicaCount: 2
image:
repository: payment-api
tag: "" # set by CI to the Git SHA
pullPolicy: IfNotPresent
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
autoscaling:
enabled: false
minReplicas: 2
maxReplicas: 20
targetCPUUtilizationPercentage: 70

Practical Commands

Bash
# Install or upgrade (idempotent)
helm upgrade --install payment-api ./charts/payment-api -n payments --create-namespace
# Preview rendered output and a diff-like dry run
helm template payment-api ./charts/payment-api -f values-production.yaml
helm upgrade --install payment-api ./charts/payment-api --dry-run --debug
# Inspect and roll back
helm list -A
helm history payment-api -n payments
helm rollback payment-api 2 -n payments

Troubleshooting

Symptom Check What to Look For
Release stuck pending-upgrade helm history A failed upgrade left a lock
Template error helm template Syntax error in a template
Values not applied helm get values Wrong file order or key name
Pods will not start kubectl describe pod Image pull or resource issue
Tip

Run helm lint and helm template in the pull request pipeline so broken charts fail before they reach a cluster.

Remember

helm upgrade --install is the idempotent command. It installs on the first run and upgrades afterwards, so the pipeline never needs two code paths.

Security

Do not commit secrets in values files. Inject them with External Secrets Operator, Sealed Secrets, or Vault, and keep Git values non-sensitive.

Common Mistake

Using helm install in CI. It fails on the second run because the release already exists. Use helm upgrade --install.

Frequently Asked Questions

Why use Helm instead of plain Kubernetes manifests in a pipeline?

Plain manifests need a duplicated YAML tree per environment. Helm uses one chart plus values files, and it keeps release history so helm rollback can revert a bad deploy without rebuilding old manifests.

What does the --atomic flag do?

It makes Helm wait for resources to become ready and automatically roll back the release if the upgrade fails or times out. Without it a failed upgrade can leave a broken release marked as deployed or pending.

How do I pass the image tag from CI to Helm?

Use --set image.tag with the commit SHA, or a digest value if the chart supports it. Avoid hardcoding tags in templates, which breaks reproducible pipeline-driven deploys.

Found a mistake, an outdated step or a broken link?