How to Create, Install & Upgrade Helm Chart | Nginx “Hello World” chart

Ticker

6/recent/ticker-posts

How to Create, Install & Upgrade Helm Chart | Nginx “Hello World” chart


In part 1 of this post, have explained how we can Install Helm package to a kubernetes cluster. 

In part 2, we will cover how to create Helm Chart, how to upgrade our Helm Chart.


Before to start with creation of Helm Chart  lets fixed warning  message  which might  seen in your enviornment 

thor@jump_host ~$ helm version

WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/thor/.kube/config

version.BuildInfo{Version:"v3.5.0", GitCommit:"32c22239423b3b4ba6706d450bd044baffdcf9e6", GitTreeState:"clean", GoVersion:"go1.15.6"}

thor@jump_host ~$


To fixed the warrning run below command 

thor@jump_host ~$ chmod o-r /home/thor/.kube/config


Verify again by running helm version 

thor@jump_host ~$ helm version

version.BuildInfo{Version:"v3.5.0", GitCommit:"32c22239423b3b4ba6706d450bd044baffdcf9e6", GitTreeState:"clean", GoVersion:"go1.15.6"}

thor@jump_host ~$



1. We are going to create our first  Nginx   helloworld Helm Chart using the following command

thor@jump_host ~$ helm create helloworld

Creating helloworld

thor@jump_host ~$


2. Verify the Chart created and tree stucture of files & there uses

thor@jump_host ~$ ll

total 4

drwxr-xr-x 4 thor thor 4096 Jan 14 15:26 helloworld

thor@jump_host ~$

thor@jump_host ~$ tree helloworld/

helloworld/

── charts

── Chart.yaml       >>> It containes all the information about the chart and the app version

── templates         >>> This directory contains templates which are passed through the template                                           engine. These templates incorporate the contents of the values.yaml file

│   ── deployment.yaml

│   ── _helpers.tpl

│   ── hpa.yaml

│   ── ingress.yaml

│   ── NOTES.txt   >>> This is plain text file is printed  out post-installation and when viewing                                              release status

│   ── serviceaccount.yaml

│   ── service.yaml

│   └── tests

│       └── test-connection.yaml

└── values.yaml   >>> It containes Predefine (default) values which will  be passed to the                                                    templates. Values in this file can be overridden by values passed on the                                            command line during installation.

 3 directories, 10 files

thor@jump_host ~$



We have created first Helm Chart . Next steps we are going to run the helloworld Helm Chart

 For that run  helm install command  with  two arguments -

    First argument - Release name what ever you want
    Second argument - Chart  which have created

thor@jump_host ~$ helm install myfirstchart helloworld

NAME: myfirstchart

LAST DEPLOYED: Fri Jan 14 15:29:19 2022

NAMESPACE: default

STATUS: deployed

REVISION: 1

NOTES:

1. Get the application URL by running these commands:

  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helloworld,app.kubernetes.io/instance=myfirstchart" -o jsonpath="{.items[0].metadata.name}")

  export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")

  echo "Visit http://127.0.0.1:8080 to use your application"

  kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT

thor@jump_host ~$



Great you created your first Helm Chart - helloworld successfully 

Verfify by running command

thor@jump_host ~$ helm list -a

NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION

myfirstchart    default         1               2022-01-14 15:29:19.611092128 +0000 UTC deployed        helloworld-0.1.0        1.16.0     

thor@jump_host ~$



thor@jump_host ~$ kubectl get all

NAME                                           READY   STATUS    RESTARTS   AGE

pod/myfirstchart-helloworld-648bc4c7f6-dzqlp   1/1     Running   0          29s

 

NAME                              TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE

service/kubernetes                ClusterIP   10.96.0.1      <none>        443/TCP   46m

service/myfirstchart-helloworld   ClusterIP   10.96.213.17   <none>        80/TCP    29s

 

NAME                                      READY   UP-TO-DATE   AVAILABLE   AGE

deployment.apps/myfirstchart-helloworld   1/1     1            1           29s

 

NAME                                                 DESIRED   CURRENT   READY   AGE

replicaset.apps/myfirstchart-helloworld-648bc4c7f6   1         1         1       29s

thor@jump_host ~$



Due to default values in value.yaml service type is set to ClusterIP

We need to update the service.type from ClusterIP to NodePort.

The reason for this change is to access the service outside of the kubernetes cluster. And if you do not change the service.type then you will only be able to access the service withing kubernetes cluster.

To update the values.yml, edit the file by vi editor 

thor@jump_host ~$ vi helloworld/values.yaml



Refer Below Video for further updating the helmchart 


Happy Learning!!!!

Apart from this if you need more clarity,  I have made a  tutorial video on this, please go through and share your comments. Like and share the knowledge 





Post a Comment

0 Comments

Latest Posts