Helm - Part I
Helm, what is it?
Helm is the package manager for Kubernetes . It works like apt for Ubuntu or yum for CentOS or like npm for javascript or nugget for .Net, but for deploying K8s applications .
What is it for?
Helm allows you to:
Deploy a complex application in a single command.
Dynamically configure (via values.yaml, which we'll see later) without modifying the YAML files, which increases the chance of reusability. Reusing your YAML templates as "roles" (Ansible) saves a huge amount of time.
Cleanly version , update , or delete a deployment. So reduces maintenance and versioning complexity.
Perfectly suited to agility and CI/CD processes
Better understanding with an example
Note : To follow the example correctly, you must have a Kubernetes cluster ready.
To better understand Helm let's try a basic scenario.
First we try to deploy a simple nginx application without Helm then we move on to a second alternative where we will use Helm to achieve the same end.
We'll cover the deployment steps using a standard Kubernetes file and then with Helm to see the difference.
1. Without Helm: Manual deployment on Kubernetes
Step 1: Create an Nginx application deployment file on Kubernetes
Let's create a file named nginx-deployment.yaml that defines an Nginx deployment with a service exposed via a NodePort.
Example deployment file:
We create a 3-replica deployment of an Nginx application with the nginx:latest image.
The container listens on port 80.
Step 2: Apply the YAML file
To apply the deployment file to Kubernetes, use the following command:
Step 3: Check the status of resources
Let's check that the pods and service have been created correctly:
This should show us something like this for the pods and the service:
This should show us something like this for the pods and the service:
Step 4: Access the application
Let's access the application using your Kubernetes node's IP address and port 30080 (as specified in the service file). We can get the node's IP with the following command:
Let's open a browser and go to:
2. With Helm: Creating a Custom Chart for the Nginx Application
Let's first delete the previous application (Deployment and Service)
Now, let's see how we'll accomplish the same thing with Helm . We'll create a custom chart to deploy Nginx.
Let's make sure Helm is installed first.
The result if Helm is installed correctly with vx.xx the current version of Helm like v3.14.0
If Helm is not installed , we should see a message like:
In this case you must execute the command
We should see a similar command prompt to confirm the installation of Helm
3: Create a custom chart with Helm
Check that a new nginx-chart folder is created under the current directory
To discover the structure of the Helm chart we use the Tree utility
Chart Root
Chart.yaml: Mandatory file that contains the chart metadata : name, version, description, etc.
values.yaml: Contains the default values injected into the templates (e.g. image, port, replicas). → Allows customization without modifying the templates .
templates/
deployment.yaml : Creates a Kubernetes Deployment object. → Describes how the application is deployed : number of replicas, image, containers, etc.
service.yaml: Creates a Service object to expose the deployment. → Uses the NodePort type here for external access.
serviceaccount.yaml: (Optional) Creates a custom ServiceAccount if enabled in values.yaml.
ingress.yaml : (Optional) Creates an Ingress for access via a domain name if enabled. → Manages paths, hosts, TLS, annotations.
hpa.yaml: (Optional) Creates a HorizontalPodAutoscaler if enabled. → Manages autoscaling based on CPU usage.
_helpers.tpl : Contains reusable functions (helpers) to simplify YAML code. → For example: fullname, name, serviceAccountName.
templates/tests/test-connection.yaml: in a Helm chart (automatically generated by helm create) allows for basic connectivity testing to verify that the deployment works after the chart is installed
Chart.yaml
values.yaml
templates/deployment.yaml
templates/service.yaml
templates/serviceaccount.yaml
templates/hpa.yaml
templates/ingress.yaml
templates/_helpers.tpl
templates/tests/test-connection.yaml
Let's deploy the application via Helm
We need to see such an exit
To test, just run the two commands offered at the end.
Try testing this first basic, very basic chart
Digest this and we will have feedback again on each of these files with details.
To get all the manifest files: