Managing applications in Kubernetes can be complex, requiring multiple YAML files to define resources such as Deployments, Services, ConfigMaps, and Secrets. As applications scale, maintaining and updating these configurations manually becomes cumbersome and error-prone. This is where Helm comes in.
Helm is a package manager for Kubernetes that simplifies deployment by bundling application configurations into reusable, version-controlled Helm charts. With Helm, you can deploy applications with a single command, manage updates seamlessly, and roll back to previous versions if needed.
values.yaml
, making it easy to manage multiple environments (dev, staging, prod).In this blog, we’ll cover:
By the end of this guide, you'll have a strong foundation in Helm and be able to deploy, manage, and scale Kubernetes applications efficiently.
Helm is a package manager for Kubernetes that helps deploy, configure, and manage applications in a Kubernetes cluster. Instead of manually writing and applying multiple Kubernetes YAML manifests, Helm allows you to package them into reusable Helm Charts, simplifying deployment and maintenance.
Managing Kubernetes resources can become complex, especially when deploying applications with multiple components (Deployments, Services, ConfigMaps, Secrets, etc.). Helm provides several advantages:
values.yaml
) to customize deployments.
Feature |
Kubernetes YAML Manifests |
Helm Charts |
---|---|---|
Management |
Requires manually applying multiple YAML files |
Uses a single Helm command |
Configuration |
Static YAML definitions |
Dynamic templating via |
Version Control |
Difficult to track changes manually |
Built-in versioning & rollback |
Reusability |
Limited; each deployment needs its own YAML |
Reusable and configurable charts |
Dependencies |
Managed manually |
Handled via |
Helm follows a client-only architecture in Helm v3, where it directly interacts with the Kubernetes API server without requiring a backend component like Tiller (which was used in Helm v2). Below are the core components of Helm:
helm repo add
and helm search repo
.values.yaml
file before applying them.helm upgrade
) and rollbacks (helm rollback
).helm uninstall
.
Command |
Purpose |
---|---|
|
Adds a Helm chart repository |
|
Searches for a chart in repositories |
|
Installs a Helm chart and creates a release |
|
Lists all active Helm releases |
|
Shows details of a deployed release |
|
Upgrades an existing release to a new chart version |
|
Rolls back a release to a previous version |
|
Deletes a release and removes associated resources |
Let's say you want to deploy NGINX using Helm. You can do this with a single command:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-nginx bitnami/nginx
This command:
To check the status of the deployment:
helm list
helm status my-nginx
To uninstall the release:
helm uninstall my-nginx
Before using Helm, you need to install it on your local machine and configure it to work with your Kubernetes cluster. This section will walk through the installation process and initial setup.
kubectl
installed and configured to communicate with your cluster.Helm can be installed on macOS, Linux, and Windows using various package managers.
brew install helm
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
choco install kubernetes-helm
After installation, verify that Helm is installed correctly by running:
helm version
You should see output similar to:
version.BuildInfo{Version:"v3.x.x", GitCommit:"...", GitTreeState:"clean", GoVersion:"..."}
Helm uses repositories to store charts. You can add a popular repository, such as the Bitnami Helm charts, using:
helm repo add bitnami https://charts.bitnami.com/bitnami
To confirm the repository has been added:
helm repo list
To fetch the latest charts from all added repositories, run:
helm repo update
To search for a specific application within your configured repositories:
helm search repo nginx
Once Helm is set up, you can deploy an application. For example, to deploy NGINX using the Bitnami Helm chart:
helm install my-nginx bitnami/nginx
This will:
List all active Helm releases:
helm list
Check the status of a specific release:
helm status my-nginx
To remove the my-nginx release and all associated resources:
helm uninstall my-nginx
A Helm chart is a packaged application definition that contains Kubernetes resource templates and default configuration values. It allows you to deploy complex applications with a single command while keeping configurations modular and reusable.
Each chart defines:
values.yaml
).When you create a Helm chart, it follows a specific directory structure:
mychart/
│── charts/ # Directory for chart dependencies (other charts)
│── templates/ # Contains Kubernetes YAML templates
│ ├── deployment.yaml
│ ├── service.yaml
│ ├── ingress.yaml
│ ├── _helpers.tpl # Contains reusable template functions
│── Chart.yaml # Metadata about the chart (name, version, description)
│── values.yaml # Default configuration values for the chart
│── README.md # Documentation about the chart
Each file in this structure serves a specific purpose:
Chart.yaml
– Contains metadata such as chart name, version, and description.values.yaml
– Defines default values that can be overridden during installation.templates/
– Holds Kubernetes manifest templates using Helm’s templating syntax.charts/
– Stores dependencies (other charts required for deployment).README.md
– Documents how to use the chart.Chart.yaml
The Chart.yaml
file provides information about the chart:
apiVersion: v2
name: mychart
description: A sample Helm chart for Kubernetes
type: application
version: 1.0.0
appVersion: 1.16.0
name: The chart's name.
description: A brief description of what the chart does.
version: The chart version (used for versioning updates).
appVersion: The application version the chart deploys.
values.yaml
The values.yaml file defines default configuration values:
replicaCount: 2
image:
repository: nginx
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
These values can be overridden when installing the chart using the --set
flag or a custom values file.
templates/deployment.yaml
A sample Kubernetes Deployment template using Helm's templating syntax:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-nginx
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
In this template:
{{ .Release.Name }}
dynamically sets the release name.{{ .Values.replicaCount }}
pulls values from values.yaml.{{ .Values.image.repository }}:{{ .Values.image.tag }}
sets the container image dynamically.Before applying a Helm chart, you can preview how the templates will render using:
helm template mychart
Now that we understand Helm charts and their structure, let’s walk through the process of creating a custom Helm chart from scratch.
To generate a new Helm chart, use the following command:
helm create mychart
This command creates a new directory mychart/ with the standard Helm chart structure.
Open values.yaml
and update it with custom values. Let’s modify it to deploy an NGINX web server with a LoadBalancer service:
replicaCount: 3
image:
repository: nginx
tag: latest
pullPolicy: IfNotPresent
service:
type: LoadBalancer
port: 80
Edit templates/deployment.yaml
to use Helm’s templating syntax:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-nginx
labels:
app: nginx
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
{{ .Release.Name }} dynamically assigns the release name.
{{ .Values.replicaCount }} references values from values.yaml.
{{ .Values.image.repository }}:{{ .Values.image.tag }} configures the image dynamically.
Edit templates/service.yaml
to configure the service:
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-nginx
spec:
type: {{ .Values.service.type }}
selector:
app: nginx
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
Once you've modified the necessary files, package the chart:
helm package mychart
This creates a .tgz
archive of the chart, making it ready for distribution.
Deploy the chart to your Kubernetes cluster:
helm install my-nginx ./mychart
This:
Check the deployed resources:
helm list
kubectl get pods
kubectl get svc
To remove the deployment, use:
helm uninstall my-nginx
Once you've created or downloaded a Helm chart, you can use Helm to deploy and manage applications in your Kubernetes cluster. This section will walk through the deployment process, including installation, upgrades, rollbacks, and uninstallation.
To deploy an application using Helm, use the helm install
command:
helm install my-nginx ./mychart
my-nginx
is the release name (a unique identifier for this deployment)../mychart
is the path to the Helm chart.If you are installing a chart from a repository, such as Bitnami, use:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-nginx bitnami/nginx
This command:
Once the chart is installed, verify that the release is active:
helm list
This will output something like:
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
my-nginx default 1 2024-02-16 10:00:00 deployed nginx-1.2.3 1.21.6
You can check the detailed status of a release:
helm status my-nginx
To view the created Kubernetes resources:
kubectl get pods
kubectl get svc
Helm allows you to override default values using the --set
flag or a custom values file.
--set
FlagYou can override individual values like this:
helm install my-nginx bitnami/nginx --set replicaCount=3
To provide multiple custom values, create a my-values.yaml
file:
replicaCount: 3
service:
type: LoadBalancer
port: 8080
Then, deploy the chart with:
helm install my-nginx bitnami/nginx -f my-values.yaml
If you need to modify a running deployment, use the helm upgrade command:
helm upgrade my-nginx bitnami/nginx --set replicaCount=5
To upgrade using a modified values file:
helm upgrade my-nginx bitnami/nginx -f my-values.yaml
This updates the deployment while keeping existing resources intact.
Helm maintains a history of releases, allowing you to roll back if needed.
List the release history:
helm history my-nginx
Roll back to a specific revision:
helm rollback my-nginx 1
To remove a Helm deployment and all its associated resources, run:
helm uninstall my-nginx
To confirm deletion:
helm list
kubectl get all
Using Helm effectively requires following best practices to ensure maintainability, security, and scalability of deployments. This section outlines key strategies for optimizing Helm usage in production environments.
values.yaml
for ClarityA well-structured values.yaml
file improves readability and maintainability.
replicaCount: 3 # Number of replicas for high availability
image:
repository: nginx
tag: latest
pullPolicy: IfNotPresent # Pull policy to optimize image fetching
service:
type: LoadBalancer
port: 80 # Publicly exposed service port
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 250m
memory: 128Mi
replicaCount: 3
image: nginx:latest
serviceType: LoadBalancer
port: 80
cpu: 500m
memory: 256Mi
If your chart depends on other charts (e.g., a database), declare them in Chart.yaml:
dependencies:
- name: postgresql
version: "12.1.3"
repository: "https://charts.bitnami.com/bitnami"
Then, update dependencies before installing:
helm dependency update
This ensures that all required subcharts are installed and properly versioned.
Avoid storing credentials in values.yaml. Instead, use Helm Secrets to encrypt sensitive values.
Install the Helm Secrets plugin:
helm plugin install https://github.com/zachomedia/helm-secrets
Encrypt sensitive values using SOPS:
sops --encrypt --in-place my-values.yaml
Install a chart using encrypted values:
helm install my-app ./mychart -f my-values.yaml
This ensures secrets are not stored in plaintext inside version control.
Integrate Helm with CI/CD tools like GitHub Actions, GitLab CI/CD, or ArgoCD to automate deployments.
name: Deploy Helm Chart
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Helm
run: |
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Deploy to Kubernetes
run: |
helm upgrade --install my-app ./mychart --namespace prod
This automates deployments whenever code is pushed to the main branch.
Chart.yaml
(version: 1.2.0).README.md
. Maintain a CHANGELOG.md
to track modifications.Helm allows environment-specific values with separate values files:
helm install my-app ./mychart -f values-dev.yaml
helm install my-app ./mychart -f values-prod.yaml
This ensures different configurations for testing and production.
As organizations scale their Kubernetes deployments, managing Helm charts effectively in production becomes crucial. This section explores how Helm integrates with GitOps tools, supports multi-environment management, and follows best practices for high availability and security.
GitOps enables declarative infrastructure management, where Helm charts are stored in Git repositories and automatically deployed using tools like ArgoCD and Flux.
ArgoCD monitors a Git repository and applies changes automatically.
Install ArgoCD:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Deploy a Helm Chart with ArgoCD:
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-helm-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/my-org/helm-charts.git
targetRevision: main
path: mychart
helm:
valueFiles:
- values-prod.yaml
destination:
server: https://kubernetes.default.svc
namespace: prod
Apply the application manifest:
kubectl apply -f my-helm-app.yaml
ArgoCD will now continuously sync the Helm chart with the Kubernetes cluster.
FluxCD can also automate Helm deployments:
flux create source git my-helm-repo \
--url=https://github.com/my-org/helm-charts.git \
--branch=main
flux create helmrelease my-app \
--source=GitRepository/my-helm-repo \
--chart=mychart \
--namespace=prod
GitOps ensures:
For enterprises running multiple Kubernetes clusters (e.g., dev, staging, prod), Helm enables consistent deployments across environments.
kubectl config use-context dev-cluster
helm install my-app ./mychart --namespace dev
kubectl config use-context prod-cluster
helm install my-app ./mychart --namespace prod
Helmfile allows managing multiple Helm releases in a declarative format.
Example helmfile.yaml:
releases:
- name: my-app-dev
namespace: dev
chart: ./mychart
values:
- values-dev.yaml
- name: my-app-prod
namespace: prod
chart: ./mychart
values:
- values-prod.yaml
Deploy all environments at once:
helmfile apply
Use Helm Hooks: Automate pre-install and post-install tasks.
annotations:
"helm.sh/hook": pre-install
Enable Readiness and Liveness Probes to ensure application health:
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
Use Rolling Updates with strategy to prevent downtime:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
Restrict Helm Permissions using Role-Based Access Control (RBAC):
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: prod
name: helm-user
rules:
- apiGroups: ["*"]
resources: ["deployments", "services"]
verbs: ["get", "list", "create", "update", "delete"]
Track Helm Releases:
helm list --all-namespaces
Monitor Deployments with Prometheus & Grafana:
Install Prometheus using Helm:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/prometheus
Use Helm Logs to Debug Issues:
helm get manifest my-app
helm get values my-app
helm get notes my-app
Helm simplifies Kubernetes application deployment, making it easier to manage complex workloads with reusable, version-controlled charts. By leveraging Helm, teams can standardize configurations, automate deployments, and integrate with GitOps workflows to achieve reliable and scalable Kubernetes operations.
values.yaml
, teams can easily override configurations without modifying templates.helm list
, helm get
) to track deployments and troubleshoot issues.Now that you understand Helm’s capabilities, here are some next steps to deepen your knowledge and practical experience:
Explore Official Helm Documentation📌 Helm Docs
Try deploying WordPress, PostgreSQL, or Redis with Helm charts from Artifact Hub.
Example:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-wordpress bitnami/wordpress
values.yaml
files.Helm is an essential tool for Kubernetes administrators and DevOps teams looking to optimize deployment workflows. Whether you are deploying simple microservices or complex cloud-native applications, Helm provides the flexibility, automation, and reliability needed to scale efficiently.
Start experimenting with Helm today and take your Kubernetes skills to the next level!