Helm Package Manager
Pre-requisites
- A basic understanding of Kubernetes
- Experience in deploying Kubernetes resources
Helm
Helm is the Kubernetes package manager that simplifies package installation and manages dependencies. In a typical 3-tier architecture, each tier consists of a Deployment, ConfigMap, and Service, as shown below:
Before Helm, each of these components required running separate manifests:
kubectl apply -f frontend-deployment.yml
kubectl apply -f frontend-configmap.yml
kubectl apply -f frontend-service.yml
kubectl apply -f app-deployment.yml
kubectl apply -f app-configmap.yml
kubectl apply -f app-service.yml
kubectl apply -f data-deployment.yml
kubectl apply -f data-configmap.yml
kubectl apply -f data-service.yml
This process can be tedious and raises questions like:
- How to parameterize?
- How to add application lifecycle hooks?
- How to manage versions of related resources?
This is where Helm helps. Helm uses charts (similar to Linux packages) to bundle all the necessary parts for a Kubernetes deployment. With Helm, you can deploy multiple resources with a single command.
Benefits of Helm:
- Simplifies deployments by running everything in one go
- Tracks versioned history of changes
- Easy to create and share charts
- Charts can be stored in a repository
To learn more, visit the official Helm website.
Concepts
Concept | Description |
---|---|
Chart | Contains all components needed to deploy a Kubernetes cluster. |
Templates | Components that make up a chart. |
Config | Optional configurations to override default settings. |
Release | A running instance of a chart. |
Chart Repository | A centralized location for storing and sharing charts. |
Helm 2 vs. Helm 3
Helm 3 introduces several differences from Helm 2:
- Helm 2 uses a different architecture and CLI command structure.
- Helm 2 charts are compatible with Helm 3.
- Helm 2 relies on a "Tiller" component for authentication.
- Helm 3 communicates directly with the Kubernetes API server.
- Helm 3 uses the same credentials as those in the
.kube/config
file.
Architecture
-
Helm Client:
- Manages charts and releases.
- Sends requests to the Kubernetes API server.
- Handles install, upgrade, and uninstall commands.
-
Helm Library:
- Manages operations with the Kubernetes API server.
- Handles communication between Helm client and Kubernetes.
- Handles chart installations and upgrades.
- Executes Helm operations within Kubernetes.
Setting up Helm
Helm can be installed from source or pre-built binaries. Here's how to set it up:
Install Helm
For Windows with WSL2 (Ubuntu), run these commands:
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
For auto-completion, use:
source <(helm completion bash)
echo "source <(helm completion bash)" >> ~/.bash_profile
Initialize a Repository
With Helm v3, no repositories are installed by default. Add a repository with:
helm repo add stable https://charts.helm.sh/stable
Add another repo (e.g., Bitnami):
helm repo add bitnami https://charts.bitnami.com/bitnami
To list added repositories:
helm repo list
Update the repositories:
helm repo update
Search for charts in the repositories:
helm search repo
Deploy a Sample Chart
Install a Redis chart:
helm install my-test-redis1 bitnami/redis
Check running pods:
kubectl get pods
List deployed charts:
helm ls
Delete the Chart
Uninstall a chart:
helm uninstall my-test-redis1