Helm Basics: Packaging Kubernetes Applications
Helm is a package manager for Kubernetes. A chart is a bundle of templated manifests; a release is an installed copy of a chart with your settings (values).
Installing software
helm repo add bitnami https://charts.bitnami.com/bitnami
helm search repo redis
helm show values bitnami/redis > redis-values.yaml # see what you can configure
helm install cache bitnami/redis -n data --create-namespace -f redis-values.yaml
helm list -A
Many projects also publish charts as OCI artifacts: helm install x oci://registry.example.com/charts/x --version 1.2.3.
Creating a chart for your app
helm create api # scaffolds Chart.yaml, values.yaml and templates/
# values.yaml
image:
repository: ghcr.io/acme/api
tag: "1.4.2"
replicaCount: 3
resources:
requests: { cpu: 250m, memory: 256Mi }
limits: { memory: 512Mi }
# templates/deployment.yaml (excerpt)
spec:
replicas: {{ .Values.replicaCount }}
template:
spec:
containers:
- name: api
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
resources:
{{- toYaml .Values.resources | nindent 12 }}
Per-environment values
helm upgrade --install api ./api -f values.yaml -f values-prod.yaml --set image.tag=$GIT_SHA
helm template api ./api -f values-prod.yaml # render locally to review
helm history api
helm rollback api 3 # back to revision 3
Helm or Kustomize?
- Helm: templating, packaging, versioned releases and rollbacks. Ideal for distributing software and for complex parameterisation.
- Kustomize (built into kubectl): patches plain YAML with overlays, no templating language. Simple for your own apps with small per-environment differences.
- Many teams use Helm for third-party software and Kustomize (or Helm) for their own services, applied by a GitOps tool.
Was this article helpful?
Comments
No comments yet. Have a question or a tip? Be the first to share it.