Working with Helm Charts
1. Installing Helm CLI
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
brew install helm # macOS
helm version
2. Adding Helm Repositories
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo list
3. Updating Helm Repositories
helm repo update
helm repo update bitnami
4. Searching Helm Charts
helm search repo nginx
helm search hub postgres --max-col-width 100
5. Installing Helm Chart
helm install web bitnami/nginx \
-n web --create-namespace \
--set service.type=LoadBalancer \
-f values.yaml
| Flag | Use |
--set k=v | Override value |
-f values.yaml | Values file |
--version | Pin chart version |
--atomic | Rollback on failure |
6. Upgrading Helm Release
helm upgrade web bitnami/nginx --version 18.2.0 -n web --reuse-values
7. Rolling Back Release
helm history web -n web
helm rollback web 3 -n web
8. Listing Helm Releases
helm list -A
helm list -n web -o yaml
9. Viewing Release Values
helm get values web -n web
helm get manifest web -n web
10. Uninstalling Helm Release
helm uninstall web -n web --keep-history
11. Creating Custom Chart
helm create mychart
helm lint mychart
helm package mychart # produces mychart-0.1.0.tgz
| File | Purpose |
| Chart.yaml | Metadata, version |
| values.yaml | Defaults |
| templates/ | Go-templated manifests |
| charts/ | Sub-charts |
| _helpers.tpl | Reusable template snippets |
12. Using Helm Templating
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mychart.fullname" . }}
data:
env: {{ .Values.env | quote }}
replicas: {{ .Values.replicas | default 3 }}
{{- range .Values.flags }}
{{ . }}: "true"
{{- end }}