Docs
/
Docker Kubernetes
Chapter 14
14 — Helm
What is Helm?
Package manager for Kubernetes — bundle K8s manifests into reusable, configurable charts.
apt install nginx → installs package on Linux
helm install nginx → installs app on Kubernetes
Key Concepts
| Concept | Description |
|---|---|
| Chart | Package of K8s templates + default values |
| Release | An installed instance of a chart |
| Repository | Collection of charts (like npm registry) |
| Values | Configuration that customizes a chart |
Essential Commands
# Add repositories
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
# Search
helm search repo nginx
helm search hub postgres # Search Artifact Hub
# Install
helm install my-release bitnami/nginx
helm install my-db bitnami/postgresql -f values.yaml
helm install my-db bitnami/postgresql --set auth.postgresPassword=secret
# List releases
helm list
helm list -A # All namespaces
# Upgrade
helm upgrade my-release bitnami/nginx -f values.yaml
# Rollback
helm rollout history my-release
helm rollback my-release 1 # Rollback to revision 1
# Uninstall
helm uninstall my-release
# Debug
helm template my-release bitnami/nginx -f values.yaml # Render templates
helm install --dry-run --debug my-release ./my-chart # Dry run
Chart Structure
my-chart/
├── Chart.yaml # Chart metadata (name, version, dependencies)
├── values.yaml # Default configuration values
├── templates/
│ ├── deployment.yaml
│ ├── service.yaml
│ ├── ingress.yaml
│ ├── configmap.yaml
│ ├── _helpers.tpl # Template helpers
│ └── NOTES.txt # Post-install message
└── charts/ # Dependencies (sub-charts)
Chart.yaml
apiVersion: v2
name: my-app
description: My application Helm chart
version: 1.0.0 # Chart version
appVersion: "2.0.0" # App version
dependencies:
- name: postgresql
version: 12.x.x
repository: https://charts.bitnami.com/bitnami
values.yaml
replicaCount: 3
image:
repository: my-app
tag: "1.0.0"
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
ingress:
enabled: true
host: myapp.com
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "1"
env:
NODE_ENV: production
Template Example
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "my-chart.fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ include "my-chart.name" . }}
template:
metadata:
labels:
app: {{ include "my-chart.name" . }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: {{ .Values.service.port }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
Overriding Values
# File (recommended)
helm install my-app ./my-chart -f production-values.yaml
# Command line
helm install my-app ./my-chart --set replicaCount=5 --set image.tag=2.0.0
# Multiple files (later files override earlier)
helm install my-app ./my-chart -f values.yaml -f production.yaml
Common Helm Charts
# PostgreSQL
helm install db bitnami/postgresql --set auth.postgresPassword=secret
# Redis
helm install cache bitnami/redis
# Nginx Ingress Controller
helm install ingress-nginx ingress-nginx/ingress-nginx
# Prometheus + Grafana
helm install monitoring prometheus-community/kube-prometheus-stack
# Cert-Manager (TLS certificates)
helm install cert-manager jetstack/cert-manager --set installCRDs=true
Key Takeaways
- Helm = package manager for K8s — install complex apps with one command
- Charts bundle K8s manifests; values.yaml configures them
- Use
helm install -f values.yamlfor environment-specific config - Use
helm templateto preview rendered manifests before installing - Use
helm rollbackfor easy rollbacks - Bitnami and Artifact Hub have charts for most popular software