Kubernetes Helm Charts
Package manager for K8s — templated manifests, values, and releases.
ContainersAdvanced
Why
Helm packages K8s manifests into reusable charts with templating and values. One chart deploys to dev/staging/prod with different values, and helm rollback undoes releases.
Docker is used by 59% of professional developers per the Stack Overflow 2024 survey, and Kubernetes runs 60% of containerized workloads in production (CNCF 2024 survey). Container orchestration reduces deployment-related incidents by 35% through declarative rollouts.
When
Use Helm for any non-trivial K8s deployment. Avoid for simple single-manifest deploys.
How
1. Create — helm create mychart (scaffold)
2. Templates — templates/*.yaml with {{ .Values.* }}
3. Values — values.yaml for defaults
4. Install — helm install release mychart -f prod.yaml
5. Upgrade — helm upgrade release mychart -f prod.yaml
6. Rollback — helm rollback release 1
7. Repo — helm repo add, helm push
Example
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata: { name: {{ .Release.Name }} }
spec:
replicas: {{ .Values.replicas }}
template:
spec:
containers:
- name: app
image: {{ .Values.image }}
env:
- name: DB_URL
value: {{ .Values.dbUrl | quote }}
# values.yaml
replicas: 3
image: myapp:latest
dbUrl: postgres://...
# Install and upgrade
helm install myapp ./mychart -f values-prod.yaml
helm upgrade myapp ./mychart -f values-prod.yaml
helm rollback myapp 1 # rollback to revision 1
Common Problems
- ⚠Template syntax errors — helm lint mychart to validate before install
- ⚠Values not overriding — -f values-prod.yaml, check precedence with helm get values
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use helm lint before install — catches template errors early
- ✓Version charts with Chart.yaml — semver for safe upgrades and rollback
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit