Helm Chart App in Kubernetes using AWS ec2 instances

What is Helm? In simple terms, Helm is a package manager for Kubernetes. Helm is the K8s equivalent of yum or apt. Helm deploys charts, which you can think of as a packaged application. It is a collection of all your versioned, pre-configured application resources which can be deployed as one unit.

What is my plan?

My plan is to create my own customize chart App in kubernetes. And as helm is a package manager tool used to install chart( packages) in kubernetes, so i will first install helm in Master Node (currently my workspace) and then create chart app.

Let’s follow below steps to achieve our plan.

Launch four instances of ec2, one for Master and 3 for worker nodes:

AMI image containing default kubernetes config.

Ec2-instances launched successfully:

Ec2-instances launched

Login to Master Node :

logon Master node

Initialize the Master Node:

kubeadm init — pod-network-cidr= — ignore-preflight-errors=all

Refer to official documentation of Node Initialization: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/

Or you can use of one of my brother write-up on Multi-node Cluster setup here: https://florientdogbe.medium.com/setting-up-kubernetes-multi-node-cluster-on-the-top-of-amazon-ec2-instance-7d3e11336381?source=follow_footer---------0----------------------------

Three workers node joining the Master Node with:

kubeadm join — token <token generated from Master Node> — node-name node1

Same thing with others nodes

Node1 joining the Master Node .
Nodes are ready

Install helm Package Manager in my Master Node:

i haven’t install it so let’s do that.

“ To install Helm know that i will go for the binary for more cmds practical😁. Also know that Helm is a client program which come with 2 differents versions if you want to install it . The Version 2 older one run a program call Tiller which manage client/server access to your kubernetes cluster. And the new version3 remove that functionality with client/library.”

I will so go for the latest version 3 of Helm .

Doc for helm installation=> https://helm.sh/docs/intro/install/

Decompress the file with : tar -xvzf <download_helm_file>

cp linux-amd64/helm /usr/bin

helm version => to check the setup is successfull

helm installed

Now the main party comes here how to create custom package/ chart in kubernetes ?

Let’s do it now 😊

  • For example you can create 3 folders, one for each package/chart:
  • One Chart “myweb” related to all my web program files, “mysql-db” for all the files required to my database mysql and one folder for integration development “jenkins”.
  • Time to write web chart file:

Note: The chart file name start with Capital “C” and has “yaml” extension like: Chart.yaml

After creating the Chart config file you have install it with helm like: helm install <app_name> <folder_of _your_Chart>


To check the successfully installed app do: helm list

  • One thing before continue is, we have to create a folder “templates” which will contains all the resources, pods, pv.yaml files we have to launch: To do it “mkdir templates”
  • Now Inside this template folder, create a deployment file like:

Link to the docker repository for deployment image: https://hub.docker.com/repository/docker/tcdocker2021/ubuntu-nginx-server

I dont’ know if you understand my plan till here ? I want the package manger will handle all pods or deployments i would like to deploy or launch , so for that apart the fact of creating the Chart file i have also to create a template folder in which all resources, pods, deployments will reside. So now the Chart app will launch for us the deployment , let’s do it:

We haven’t any deployment lauched.
  • Now install the app by helm like:

And now you can see that our Chart app by helm launched a deployment for us.

Let’s create a service file for our Chart app in templates folder with : kubectl expose deploy mydeploy — port=80 — type=NodePort — dry-run -o yaml > service.yaml

  • And from the above output, you can see that we only have kubernetes services launched, so let’s launch loadbalancer service through Chart App:
  • Now as we have already created the app and now we want to add more resources, we have to update the version of our app like:

Change the version of app and upgrade with :

helm upgrade <app_name> <mypackage_name>

Helm list => And now our app has been upgraded

app version updated

And load Balancer service launched also:

  • let’s practice more😁 by updating our deployment by increasing the replicas to three:
  • And upgrade the version of our app to 0.3:
Updating app version after update our deployment

helm upgrade web-app myweb/ : to update the Chart app

kubectl get pods and you can see that 3 copies of our deployment launched successfully through our App
  • Now let’s see the case we want to parametrize our deployment so that instead of writing every time in deployment file, we can set a file in which we set the count value of our replicas:
  • For that let’s create a variable file called “values.yaml” in app folder like:
  • Inside this file we set the number of replicas of our deployment pods like:
  • After now go to deployment file to add this values.yaml file as a parameter of replicas:
replicas is set for key our values.yaml file
  • Again install the app through helm: helm install <app_name> <package_folder>:
Again helm launch successfully the 3 copies of our pods with the help of file values.yaml

Note: You can set the replicas also while installing the app like: helm install <web-app_name> <folder_package>/ — set replicaCount=<no_of_replicas_you_want>

For more hands on practice, we can play do the same thing with service type of our pods by setting it in a variable file and go to the services file in template folder and parametrize the type of our service there.

So that is the way we can create our own Chart App in kubernetes with help of Helm Manager tool.

Keep Learning and see you in another story 👻

3rd Year CSE Student, Technology Passionate(Docker, AWS, K8s,Rhel Linux,...), Aspiring Security Expert😁