Helm
It is a packaging manager, we can install, upgrade and uninstall packages. Some examples of packaging manager:-
- Windows:- Windows Installer
- Linux/Unix:- apt and yum
- Node JS:- npm (node package manager)
- Helm is a package manager for kubernetes.
- It works with Charts
Charts: Charts are like packages in Helm, it will have all the templates files and configuration required to create kubernetes resources.
By using a single command we can pull any chart we want:
helm install <name of release> <repository from where to pull> — — namespace=<name of namespace>
for eg: helm install apache bitnami/apache — — namespace=web
Repository of Chart:- With the repository the chart will pull all the templates , values and create resources, send those resources file to kubernetes, which will eventually create resources under that namespace.
Some commands for upgrade, rollback and uninstall:
helm upgrade <name of release> <repository from where to pull> — — namespace=<name of namespace>
helm rollback <name of release> <repository from where to pull> — — namespace=<name of namespace>
helm uninstall <name of release> <repository from where to pull> — — namespace=<name of namespace>
ADVANTAGES OF HELM:
- Less Complexity: It simplifies the kubernetes deployment process by abstracting out all the complexity. For eg. If a user needed to install mongodb application, then he need to write all the configuration, networking, volumes and then it will hand over to kube API server which will create resources for the user. But, by using helm we user can do it by only one command, it will pull a mongodb chart from a centralized repository, then it will install the packages.
- Revision History: In kubernetes when we scale up or down our containers it does store a backup for our containers but in Helm, it maintains a Revision history which will store all the templates and values so when we upgrade a template it will create a backup for it and we can easily do a rollback.
- Dynamic Configuration: By using helm, as it gives files as templates when we create a chart, all these files will be generated( Configmap.yml, Service.yml, deployment.yml, secret.yml) and they will have a place holders for parameters. It uses another file called values.yml using which we can pass parameters to the template files.
- Consistency: When we use packaging manager we do install, upgrade through packaging manager we need not to change anything directly.
- Intelligent Deployment: Hel knows the order in which kubernetes resources should be created and it will automatically do it. (Configmap.yml → Secret.yml → deployment.yml → Service.yml)
- Life Cycle Hooks: If any package that is not related directly to kubernetes but it is needed at the time of installation and upgradation, then helm allows us to write hooks. For eg. data to database, backing up a database
- Security: Helm have an in-built support to ensure the charts that are download from the central repository are secured. Charts can be signed using cryptography and hashes that can be generated.
LAB EXERCISE
TO CREATE HELM CHARTAND DEPLOY APPLICATION USING HELM
Create Helm Chart
In order to create a Helm chart, you must first create the chart itself, then configure the image pull policy, and then define extra details in the values.yaml file.
Step 1: Create a New Helm Chart
- helm create <chart name>: To Create a chart
- ls <chart name>: To list the chart files
The Helm chart directory contains:
Directory charts :Used for adding dependent charts. Empty by default.
Directory templates :Configuration files that deploy in the cluster.
YAML file :Outline of the Helm chart structure.
YAML file: Formatting data for the chart’s configuration.
for eg:
→ helm create falco
→ ls falco
Step 2: Configure Helm Chart Image Pull Policy
- Open the values.yaml file in a text editor. Locate the image values:
There are three possible values for the PullPolicy:
- IfNotPresent: Downloads a new version of the image if one does not exist in the cluster.
- Always :Pulls the image on every restart or deployment.
- Latest – Pulls the most up-to-date version available.
2. Change the image PullPolicy from IfNotPresent to Always:
Step 3: Helm Chart Name Override
To override the chart name in the values.yaml file, add values to the name Override and fullnameOverride:
Step 4: Specify Service Account Name
When you launch the cluster, the service account name for the Helm chart is generated. However, manually setting it is a smart idea.
The service account name ensures that the application is immediately linked to a chart controlled user.
- Locate the serviceAccount value in the values.yaml file:
2. Specify the name of the service account:
Step 5: Change Networking Service Type
The recommended networking service type for Minikube is NodePort.
- To change the networking service type, locate the service value:
2. Change the type from ClusterIP to NodePort:
Deploy Helm Chart
After configuring the values.yaml file, check the status of your Minikube cluster and deploy the application using Helm commands.
Step 1: Check minikube Status
- minikube status
- minikube start
Step 2: Install the Helm Chart
helm install <full name override> <chart name>/ — — values <chart name>/values.yaml
Step 3: Export the Pod Node Port and IP Address
- Copy the two export commands from the helm install output.
- Use “set” in-place of “expose” if you are using windows.
2. Run the commands to get the Pod node port and IP address:
3. Run:- kubectl get pod (To know the pods running)
4. Run:- minikube service list
- Copy URL and run on the chrome to view the deployed application
5. Deployed Application
GitHub Repository: https://github.com/XI3391-asingh/helm-Falco.git