Helm Documentation
🎯 Prerequisites
- Kubernetes cluster
kubectl
configured to communicate with your cluster- Helm installed on your local machine
📥 Installing Helm
Download and install Helm from the official Helm GitHub repository:
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
Verify the installation:helm version
📚 Helm Basics
📁 Helm Repositories
Helm uses repositories to distribute charts. The default repository is https://charts.helm.sh/stable.
Add a repository: helm repo add my-repo https://example.com/repo
Update your repository to get the latest charts: helm repo update
Searching for Charts
Search for available charts: helm search repo nginx
Installing a Chart : helm install my-release my-repo/my-chart
Listing Installed Releases helm list
Upgrading a Release
To upgrade an existing release: helm upgrade my-release my-repo/my-chart
Uninstall a release:helm uninstall my-release
📜 Helm Charts
Creating a New Chart
Create a new Helm chart: helm create my-chart
This command creates a directory structure for your chart:
graphql
my-chart/
Chart.yaml # A YAML file containing information about the chart
values.yaml # The default configuration values for this chart
charts/ # A directory containing any dependencies
templates/ # A directory of templates that generate Kubernetes manifests
The Chart.yaml file contains metadata about the chart:
apiVersion: v2
name: my-chart
description: A Helm chart for Kubernetes
version: 0.1.0
appVersion: "1.16.0"
Customizing Templates
Helm templates use the Go templating language. For example, a basic deployment template might look like this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.app.name }}
spec:
replicas: {{ .Values.app.replicaCount }}
template:
metadata:
labels:
app: {{ .Values.app.name }}
spec:
containers:
- name: {{ .Values.app.name }}
image: "{{ .Values.app.image }}"
ports:
- containerPort: {{ .Values.app.port }}
Using values.yaml
The values.yaml file contains default configuration values:
app:
name: my-app
replicaCount: 3
image: my-app:latest
port: 80
Override values at installation using --set or a custom values.yaml file:
helm install my-release my-chart --set app.replicaCount=5
#or
helm install my-release my-chart -f my-values.yaml
🪝 Helm Hooks
Helm hooks allow you to perform actions at various points in a release lifecycle. Define hooks in your templates:
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-test"
annotations:
"helm.sh/hook": test-success
spec:
template:
spec:
containers:
- name: test
image: busybox
command: ['sh', '-c', 'echo The test is successful!']
restartPolicy: Never