Helm Charts
Helm is the Kubernetes package manager. A chart bundles templates + default values; users install + upgrade with one command, override values per environment, and roll back to any prior release. Reach for it when the same workload ships to many environments, or when you consume third-party services (Postgres, ingress controllers, monitoring stacks).
Install, upgrade, values per env, write a chart
EXAMPLE
# 1) Install an off-the-shelf chart from a public repo
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
# Inspect available values
helm show values bitnami/redis > redis-defaults.yaml
# Install a release
helm install shop-redis bitnami/redis \
--namespace shop --create-namespace \
--set auth.password='strong-secret' \
--set master.persistence.size=10Gi \
--set replica.replicaCount=2
# 2) Per-environment values files
# values.staging.yaml -> small instance + no TLS
# values.prod.yaml -> bigger + multi-AZ + alerting on
helm upgrade --install shop-redis bitnami/redis \
--namespace shop --values values.prod.yaml
# 3) Inspect, diff, rollback
helm list -A
helm history shop-redis -n shop
helm get values shop-redis -n shop
helm rollback shop-redis 2 -n shop
helm uninstall shop-redis -n shop
# 4) Diff before applying (install the helm-diff plugin once)
helm plugin install https://github.com/databus23/helm-diff
helm diff upgrade shop-redis bitnami/redis -n shop --values values.prod.yaml
# ============================================================
# Write your own chart
# ============================================================
# helm create shop-api
# shop-api/
# ├── Chart.yaml # name, version, appVersion
# ├── values.yaml # defaults
# ├── templates/
# │ ├── deployment.yaml
# │ ├── service.yaml
# │ ├── ingress.yaml
# │ └── _helpers.tpl # shared template fragments
# └── charts/ # subcharts
# Chart.yaml
# apiVersion: v2
# name: shop-api
# description: Shop API
# type: application
# version: 0.1.0 # CHART version
# appVersion: '1.4.0' # APP version
# values.yaml
# replicaCount: 3
# image:
# repository: example.com/shop-api
# tag: '1.4.0'
# resources:
# requests: { cpu: 100m, memory: 256Mi }
# limits: { cpu: 500m, memory: 512Mi }
# ingress:
# enabled: true
# host: api.example.com
# env:
# NODE_ENV: production
# templates/deployment.yaml
# apiVersion: apps/v1
# kind: Deployment
# metadata:
# name: {{ include 'shop-api.fullname' . }}
# labels: {{- include 'shop-api.labels' . | nindent 4 }}
# spec:
# replicas: {{ .Values.replicaCount }}
# selector:
# matchLabels: {{- include 'shop-api.selectorLabels' . | nindent 6 }}
# template:
# metadata:
# labels: {{- include 'shop-api.selectorLabels' . | nindent 8 }}
# spec:
# containers:
# - name: api
# image: '{{ .Values.image.repository }}:{{ .Values.image.tag }}'
# resources: {{- toYaml .Values.resources | nindent 12 }}
# env:
# {{- range $k, $v := .Values.env }}
# - name: {{ $k }}
# value: {{ $v | quote }}
# {{- end }}
# Install YOUR chart
# helm install api ./shop-api -n shop --create-namespace
# helm upgrade api ./shop-api -n shop --values values.prod.yaml
# ============================================================
# Tips
# ============================================================
# - helm lint catch template errors before install
# - helm template <chart> render to stdout to inspect
# - helm test <release> runs test pods declared in templates/tests
# - chart-testing (CT) for CI verification of multiple value combinations
# - semver bump 'version' on EVERY chart change (CI lint enforces it)
# ============================================================
# Pitfalls
# ============================================================
# - Hardcoding cluster-specific values (storage class, ingress class) in the chart
# -> put them in values, default 'use the cluster default'
# - Massive _helpers.tpl with copy-paste from helm create -> trim it
# - 'helm upgrade --install ... --reuse-values' silently keeps OLD values; use
# --reset-values when you intend to start fresh
# - Storing secret values in version-controlled values files
# -> use sealed-secrets, Vault, or values-from-secret patterns
Why it matters
Helm is the cleanest path for shipping the same workload to many clusters and environments. Pair `helm diff` + `--values
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
helm repo add bitnami https://charts.bitnami.com/bitnami helm install pg bitnami/postgresqlTry it Yourself »
Exercise
Install a chart with Helm.
helm
pg bitnami/postgresql
Seven letters.
Discussion
Loading…