9 Essential Helm Commands for DevOps Engineers
In the world of Kubernetes and DevOps, managing application deployments can be a daunting task. Helm, a Kubernetes package manager, has emerged as a lifesaver for DevOps engineers, simplifying the management of Kubernetes applications and resources.
In this blog post, we'll provide you with a concise cheat sheet of 9 essential Helm commands to empower DevOps engineers in their Kubernetes journey. These commands are the building blocks for efficient deployment, updates, and management of applications in Kubernetes, making your DevOps tasks more automated and repeatable.
What is Helm?
Helm is a package manager for Kubernetes that streamlines the installation, management, and deployment of applications. It allows you to define, install, and upgrade even the most complex Kubernetes applications, referred to as "charts," with ease. Helm's structure is based on two primary components: the Helm client and the Tiller server (though Tiller has been replaced with a more secure architecture in Helm 3).
Why Helm is Essential for DevOps Engineers
Helm plays a crucial role in modern DevOps for several reasons:
- Consistency: Helm ensures that your application deployments are consistent, reducing configuration errors and discrepancies.
- Automation: Helm automates the deployment process, saving time and reducing the risk of human error.
- Versioning: Helm allows you to version and package your applications, making it easier to manage different releases.
- Repeatability: Helm makes it easy to replicate deployments across different environments, from development to production.
Installing Helm
Before we dive into the essential Helm commands, you need to set up Helm on your local development machine. Here's a quick guide on how to do that:
You can install Helm on your local machine by following the instructions for your specific OS on the Helm website, below given are short versions for your required VM
Linux: On Debian/Ubuntu systems, you can easily install Helm with a single command:
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
Mac: You can install Helm on a Mac using Homebrew by running the following command:
brew install helm
Windows: You can install Helm on a Windows system by utilizing the Chocolatey package manager.
choco install kubernetes-helm
Helm terminologies
Before diving into Helm commands, it's essential to grasp the significance of important Helm terminologies. Understanding these terms is crucial for effectively utilizing Helm in a DevOps or Kubernetes environment.
- Chart: A Helm chart is a package that contains pre-configured Kubernetes resources, templates, and application definitions. It provides a convenient way to manage and deploy applications in a Kubernetes cluster by bundling all the required resources together.
- Repository: Helm charts can be stored in a Helm chart repository, which is a centralized location for distributing and sharing charts. Helm users can search, access, and install charts from these repositories, making it easier to collaborate and distribute applications.
- Release: A release in Helm represents an instance of an application installation on a Kubernetes cluster. Helm manages each release separately, allowing for versioning and multiple installations of the same chart with different configurations.
- Values File: The values file in Helm is used to customize the configuration of a chart. It allows users to specify custom variables and settings for their specific environment, which Helm uses to render templates and generate Kubernetes manifests tailored to the desired configuration.
- Template: A template is a file within a Helm chart that defines how to generate Kubernetes manifests based on the values provided in the values file. Templates use Go templating to transform variables and configurations into valid Kubernetes resource definitions.
- Revision: When changes are made to a release, such as updates or rollbacks, Helm creates a revision to track these modifications. This versioning system ensures that you can revert to a previous state if needed and maintains a history of changes made to a release for auditing and troubleshooting purposes.
Helm Commands
Explore the following critical Helm commands that will simplify your Helm experience and enhance your efficiency.
helm repo
The helm repo
command offers a range of repository operations, allowing you to interact with repositories by listing available charts, adding new repositories, updating existing ones, and even removing repositories from your references.
helm search
The helm search
command serves as a powerful command for discovering existing charts within ArtifactHub or any other added repository. This command enables you to find charts effectively, as demonstrated in the example of searching for Nginx charts within the bitnami repository using helm search repo
In addition, you can perform a chart search on ArtifactHub using the helm search hub
command.
helm install
This command deploys a Helm release from a designated chart into a specific environment and namespace. The fundamental syntax for a Helm installation is as follows: helm install <release-name> <chart>
.
In below example we are installing nginx
chart from bitnami
repository, rest of the parameters like namespace and kubeconfig are similar as of kubectl command
helm upgrade
This command is used to update an existing release that has been previously installed in a Kubernetes cluster using Helm.
helm list
You can view a comprehensive list of all installed releases by using the helm list
command within a specific namespace. Alternatively, you can use the -A
flag to display all releases across the entire cluster.
~$ helm list -n nginx
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
my-nginx nginx 2 2023-10-19 18:28:37.449563855 +0000 UTC deployed nginx-15.3.4 1.25.2
helm rollback
Reverting changes in a release with a specified revision number is possible since a new revision is generated with every upgrade. In the previous example, after upgrading the my-nginx
release, the revision was incremented to version 2.
You can utilize the helm rollback
command to roll back to a previous release using the following command: helm rollback <release> <revision>
. It's important to note that even the rollback command will generate a new revision for the release.
~$ helm rollback my-nginx 1 -n nginx --kubeconfig ~/.kube/dev_admin
Rollback was a success! Happy Helming!
~$ helm list -n nginx
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
my-nginx nginx 3 2023-10-19 18:29:55.990495354 +0000 UTC deployed nginx-15.3.4 1.25.2
helm uninstall
To remove an existing release from a specific namespace or the entire cluster, you can employ the helm uninstall
command. This command effectively removes all components installed as part of the release.
~$ helm uninstall my-nginx -n nginx
release "my-nginx" uninstalled
helm create
Creating Helm charts is essential in DevOps for application deployments. The helm create
command simplifies this process by generating the chart structure, including templates and a values.yaml
file that you can tailor to your application's specific requirements.
helm create my-chart
Once you've created your Helm chart, the next step is to make adjustments to the Chart.yaml
file to configure chart details to accurately represent your application.
helm lint
When developing a chart, it's essential to validate its integrity, and this can be done using the helm lint
command. This command specifically checks for template syntax and ensures the chart is structured correctly. You can use it as follows:
helm lint <chart-directory>
Conclusion
In conclusion, Helm commands are indispensable for DevOps engineers navigating Kubernetes deployments. They provide the flexibility, efficiency, and precision needed to manage the Kubernetes environment. Mastering these commands empowers you to seamlessly orchestrate complex applications, ensuring the success of your projects.
Member discussion