What is Helm
Helm is a powerful templating tool and package manager designed for Kubernetes. It simplifies the process of deploying, updating, and managing the lifecycle of applications by packaging them into "charts." These charts encapsulate all the configuration files and settings needed, enabling seamless deployment of even the most complex applications with ease.
As a widely adopted CLI tool, Helm has undergone significant evolution, with Helm v3 being the latest major version. A notable improvement in Helm v3 is the removal of "Tiller," the server-side component present in Helm v2, which posed significant security concerns. By eliminating Tiller, Helm v3 operates solely as a client-side CLI tool, offering a more secure and streamlined experience for Kubernetes application management.
Helm Architecture
Helm v3 consists of two key components:
The Helm Client
The Helm Client is the user-facing component, accessed through the CLI. It is responsible for:Managing Charts Locally: Packaging, managing, and working with Helm charts on your system.
Finding Charts: Discovering and retrieving pre-built charts (applications) from Helm repositories.
Application Lifecycle: Installing, updating, and uninstalling applications in a Kubernetes cluster.
Managing Repositories: Adding, removing, or updating local Helm repositories.
The Helm Library
The Helm Library is the behind-the-scenes component that handles the complex operations required for deploying applications on Kubernetes. It is responsible for:Kubernetes API Integration: Communicating with the Kubernetes API to deploy and manage your applications.
Template Rendering: Combining Helm chart templates with user-defined configurations from the
values.yaml
file to generate and deploy Kubernetes resources.State Management: Storing application state information directly within Kubernetes, removing the need for an external database.
In essence, the Helm Client serves as the interface for users to manage Kubernetes applications, while the Helm Library performs the technical work to deploy and manage these applications within the cluster.
What is a Helm chart?
A Helm chart is a package format for deploying applications on Kubernetes. It acts like a blueprint that contains all the necessary configurations, dependencies, and instructions needed to deploy and manage your application effectively.
How it works?
Lets say if you want to deploy an application called paytm. It contains multiple services. So we need to deploy each service, for that we have to write 2 manifest(deployment & service) files for each service.
At the end we can see multiple YAML files which makes more confusion and messy.
Instead of maintaining those multiple YAML files we can do this by implementing HELM. It will deploy our entire application.
HELM is a package manager for kubernetes which makes deployment simple.
Key Components of a Helm Chart
Helm charts are structured collections of files that define the Kubernetes resources and configurations needed for an application. Here’s an overview of the key components:
1. Templates
Purpose: Templates define the Kubernetes resources required for your application, such as Deployments, Services, ConfigMaps, etc.
Dynamic Configuration:
Templates use the Go templating language, enabling dynamic customization of Kubernetes objects.
For instance, you can dynamically specify the number of replicas, container images, and resource limits based on input values.
This flexibility allows specific configurations to be injected at the time of installation.
2. Values
Purpose: The
values.yaml
file serves as the default configuration for your application.Centralized Configuration:
It acts as a single source of truth for all configurable parameters.
These values can be injected into templates to customize deployments.
Overrides:
- At installation, you can override these defaults to tailor the deployment for different environments or requirements.
3. Chart.yaml
Purpose: This is the metadata file for the chart.
Information Included:
Name: The name of the chart.
Version: Helps in version control and tracking updates.
Description: A brief explanation of what the chart does.
Dependencies: Specifies other charts required for this chart to function properly.
Role: Ensures compatibility and helps manage chart dependencies effectively.
4. values.schema.json (Optional)
Purpose: Provides a validation schema for the
values.yaml
file.Validation:
Ensures that the structure and types of values provided (via
values.yaml
or command-line overrides) are correct.Helps prevent errors during deployment by validating input parameters.Advantages of HEML:
It will save the time
Helps to automate the application deployment
Better scalability
Perform rollback at anytime
Increase the speed of deployment.
Install HEML:
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
helm version
Deploy an application using HELM:
Create a helm chart :
helm create devops
Now we can see devops folder will gets created.
Enter into the folder and open values.yml file
Change the service type from ClusterIP to NodePort on line 55
Change the image name from nginx to our-docker-image (shaikmustafa/dm)
Change the appVersion: “1.16.0” to “latest” on Chart.yaml file (this represents that image tag")
Now install helm :
helm install devops .
here dot(.) represents that pwd where our Chart.yaml present and devops is release name
Now we can see pods, deployments, services will be created automatically.
Now we can access those application page using slaveip:node-port
To get helm release list :
helm list (or) helm ls
Now lets scale up the replicas in values.yml (change value from 1 to 4)
To update those changes we will use :
helm upgrade devops .
Now lets see the pods count, it will gets increased from 1 to 4. Now we can see the release using the command helm list then revision(version) will gets increased from 1 to 2
To rollback to prev revision :
helm rollback devops 1
The above command will rollback to 1st version
Once we perform the above command we can see the pods count will be scale down from 4 to 1 again.
Now update the image:
Change the image name on values.yaml and upgrade the helm
helm upgrade devops .
When you update the helm, helm will create new RS and create the new pods.
General commands about HELM:
To uninstall helm :
helm uninstall devops
If you want to dry-run the chart before installation :
helm install devops --debug --dry-run .
To get template of our helm :
helm template .
To see the history of a release :
helm history mustafa
Essential Helm Commands and Their Usage
Here’s a simplified guide to common Helm commands, with practical explanations to help you get started.
1. Installing a Helm Chart
Use the following command to install a Helm chart:
helm install [RELEASE_NAME] [CHART] [flags]
Some useful flags:
--atomic
: Automatically rolls back the installation if any part fails, preventing partial installations.--dependency-update
: Updates chart dependencies before installation.--dry-run
: Simulates the installation without deploying, showing what will happen.--namespace <namespace>
: Installs the chart into a specified namespace.--set <key>=<value>
: Overrides a specific value in thevalues.yaml
file.--values <values.yaml>
: Uses an alternative values file for the installation.
To explore more options, run:
helm install -h
2. Upgrading a Helm Release
Upgrade an existing release with:
helm upgrade [RELEASE_NAME] [CHART] [flags]
In addition to the install flags, you can use:
--cleanup-on-fail
: Cleans up resources created during a failed upgrade.--force
: Forces the upgrade even if there are no changes.--reset-values
: Resets overridden values to their defaults.--reuse-values
: Retains existing values and merges new ones.--version <version-number>
: Specifies the chart version for the upgrade.
3. Uninstalling a Helm Release
Remove a release with:
helm uninstall [RELEASE_NAME] [flags]
Key flags:
--keep-history
: Retains the release history for future reference.--no-hooks
: Skips hooks during uninstallation.
4. Viewing Installed Releases
List all installed releases using:
helm list [flags]
Handy flags:
--all-namespaces
: Lists releases from all namespaces.--output <format>
: Formats output (e.g., JSON, YAML, or table).
5. Checking Release History
View a release’s history to track changes:
helm history [RELEASE_NAME] [flags]
6. Rollback a Release
Rollback to a previous revision with:
helm rollback [RELEASE_NAME] [REVISION] [flags]
Useful flags:
--cleanup-on-fail
: Cleans up resources created during a failed rollback.--recreate-pods
: Restarts all pods in the release.
7. Adding and Updating Helm Repositories
To add a repository:
helm repo add [REPO_NAME] [REPO_URL]
To update repositories:
helm repo update
8. Managing Dependencies
Helm charts may rely on other charts. Use the following commands for dependency management:
Build dependencies:
helm dependency build [CHART]
Update dependencies:
helm dependency update [CHART]
9. Debugging Helm Charts
Debugging issues in Helm deployments can be done through these methods:
Simulate and Debug Installation:
helm install my-release ./my-chart --debug --dry-run
--debug
: Provides detailed output.--dry-run
: Renders templates without deploying.
Inspect Rendered Templates:
helm template my-release ./my-chart
This outputs the Kubernetes manifests generated from templates for review.
Check Logs and Status:
Use Kubernetes tools likekubectl logs
andhelm status my-release
to troubleshoot deployed resources.View Manifest and Values:
helm get manifest my-release helm get values my-release
10. Linting and Packaging Helm Charts
Lint Charts:
helm lint [CHART_DIRECTORY]
Use
--strict
for stricter checks.Package Charts:
helm package [CHART_DIRECTORY] --destination <path>
With these commands and tips, you’ll have a solid foundation for managing Helm charts and troubleshooting Kubernetes deployments effectively.
Conclusion
Helm simplifies the deployment and management of Kubernetes applications by providing a powerful package manager that streamlines repetitive tasks. From installing charts to managing dependencies and rolling back releases, Helm commands offer flexibility and control to handle complex Kubernetes environments with ease. By leveraging features like templating, versioning, and debugging tools, Helm not only enhances operational efficiency but also reduces the potential for errors in your deployment pipelines.
Whether you're a beginner exploring Kubernetes or a seasoned DevOps professional, mastering Helm commands and understanding its architecture will empower you to deploy and manage applications with confidence. Start small, experiment with Helm charts, and gradually unlock its full potential to streamline your Kubernetes workflows.
If you love stories that inspire learning, growth, and productivity, consider subscribing for more! If this article added value to your journey, your support would mean the world to me — only if it’s within your means. Let’s stay connected on LinkedIn too. Thank you for reading!