DYK… Helm can vastly improve your Kubernetes experience?
What is Helm?
Helm is a tool for managing Charts. Charts are packages of pre-configured Kubernetes resources. We can say that Helm is a package manager for Kubernetes.
But what is a package manager and what does it do?
A package manager is a set of tools that automates the process of installing, upgrading, configuring, and removing software in a consistent manner. It keeps track of the software that is installed and allows you to easily install, upgrade, or remove software.
Helm makes it easy to define, install, scale and upgrade applications running on Kubernetes. It takes applications and services that are either highly repeatable or used in multiple scenarios and deploy them to a typical K8s cluster.
It helps reduce human error and creates a more declarative configuration to enable workflows such as GitOps. This is especially useful for large, complex applications with many Kubernetes objects that need to be configured and changed during upgrades. It also comes in handy when deploying the same app multiple times (e.g., databases for microservices). Helm can make the process easy and repeatable avoiding the use of find-and-replace in multiple manifests, which is not recommendable.
It has grown in popularity along with Kubernetes and is a graduated CNCF project.
- Package any K8s applications as charts from scratch
- Package charts into chart archive (tgz) files
- Interact with chart repositories where charts are kept
- Install and uninstall charts onto an existing Kubernetes cluster
- Manage the release cycle of charts that have been installed with Helm
- Deploy software with dependencies to Kubernetes
- Upgrade the software versions
- Configure software deployments
- Perform pre-installation and post-installation actions
This functionality is provided using following components:
- The chart: a bundle of information necessary to create an instance of a Kubernetes application.
- The config: it contains configuration information that can be merged into a packaged chart to create a releasable object.
- A release: is a running instance of a chart, combined with a specific config.
Helm 3 architecture has some significant improvements compared to Helm 2. It has a new set of capabilities, as well as changes in its internal plumbing. Helm 3 has two main components written in Go, the Helm Client and the Helm Library (replacing Helm’s 2 Tiller Server). It has a completely client-only architecture (compared to the client-server architecture of Helm 2) and the in-cluster server part has been removed.
The client in Helm 3 works pretty much the same but interacts directly with the Kubernetes API server instead of the Tiller server as it was with Helm 2. This simplifies Helm’s architecture and allows it to improve the Kubernetes user cluster security.
Helm uses a client library to communicate with Kubernetes. Currently, that is based on REST API + JSON. It keeps the information in Secrets located inside of Kubernetes and does not require its own database.
Helm Client: a command-line client for end users.
The client allows to do the following:
- Local chart development
- Managing repositories
- Managing releases
- Interfacing with the Helm library:
- Sending charts to be installed
- Requesting upgrading or uninstalling of existing releases
Helm Library: provides the logic for executing all Helm operations.
It interfaces with the Kubernetes API server and provides the following capability:
- Combining a chart and application configuration to build a release
- Installing charts into Kubernetes, and providing the subsequent release object
- Upgrading and uninstalling charts by interacting with Kubernetes
The standalone Helm library encapsulates the Helm logic so that it can be leveraged by different clients.
Example Helm chart for node.js app
1. Let’s install the following:
2. Next create a simple ‘Hello-World’ node.js app:
Create package.json describing the application dependencies (npm init)
Create server.js file. You can use a Node.js framework like express.js to make the development easier and streamlined creating a simple web server listening on port 8080
- Run npm install and then npm start to install all the dependencies and test the app locally:
3. Build a Docker image with it:
- Running commands below creates a Docker image with the Node.js application we just created.
- Then it will be used in the Helm chart to deploy the application to the Kubernetes cluster.
- Next the image should be pushed to Docker hub:
- Here, the Docker Hub repository is being used to push the images.
4. Helm Chart
- Create Helm chart and value.yaml file, which is the foundation that allows the helm chart to build upon.
- Update image to be used in values.yaml:
- Update the service port configuration in values.yaml using NodePort to test running application on node:
- Use this port configuration in service.yaml file:
5. Deploy the Helm chart to the active Kubernetes context:
6. You can test the app via browser, and get the url of the application using the following commands if running minikube (For different Kubernetes setup use kubectl and service of type LoadBalancer):
Helm empowers organizations to navigate the intricacies of modern application deployment with confidence and efficiency.
It helps developers focus on innovation, system administrators can ensure reliable deployments, and businesses can deliver high-quality software to their users faster than ever before.
Helm proves to be a great tool for anyone striving for success in the ever-evolving world of technology as it us a key element in container orchestration and deployment.
If you need help with this or any other Kubernetes-related topics, do not hessitate to contact us!