Helm demo
Helm demo
This demo will user the ingress on bare-metal using the Nginx Ingress Controller and metalLB.
In my helm-demo folder, I have the templates directory and the Chart and values YAML files :
Now inside the templates directory :
The depoyment.yaml file contains a simple nginx deployment :apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 3
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: my-nginx-service
spec:
selector:
app: nginx
ports:
- name: main
protocol: TCP
port: 80
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-nginx-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
http.port: "443"
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: my-nginx-service
port:
number: 80
Next is helm install:
k8s-master@master:~$ helm install --generate-name helm-demo/
NAME: helm-demo-1660310990
LAST DEPLOYED: Fri Aug 12 06:29:50 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
helm install, we were able to deploy our app very easily and very fast.
k8s-master@master:~$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/my-nginx-deployment-9456bbbf9-c74rs 0/1 ContainerCreating 0 11s
pod/my-nginx-deployment-9456bbbf9-k4cdb 0/1 ContainerCreating 0 11s
pod/my-nginx-deployment-9456bbbf9-mm7dm 0/1 ContainerCreating 0 11s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 22m
service/my-nginx-service ClusterIP 10.100.146.193 <none> 80/TCP 11s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/my-nginx-deployment 0/3 3 0 11s
NAME DESIRED CURRENT READY AGE
replicaset.apps/my-nginx-deployment-9456bbbf9 3 3 0 11s
192.168.1.240 and specifying the path /testpath:

The usual way to do this with kubectl is by executing the kubectl apply command line for every resource.
Another important feature in Helm are placeholders! so if we look at another deployment.yaml file for example :
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: {{.Values.scale}}
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
{{.Values.scale}}placeholder makes it possible to modify the configuration without having to edit the actual manifest file every time.
So whatever the value of scale is in values.yaml file is going to be the value of the configuration file.
The values.yaml file :
And now let's install our app again :
k8s-master@master:~$ helm install another-demo helming-once-more/
NAME: another-demo
LAST DEPLOYED: Fri Aug 12 11:48:53 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
k8s-master@master:~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-nginx-deployment-9456bbbf9-mx45n 1/1 Running 0 3m9s
my-nginx-deployment-9456bbbf9-rqkmw 1/1 Running 0 3m9s
my-nginx-deployment-9456bbbf9-tl4wj 1/1 Running 0 3m9s
For some reason or another, we needed to scale up our up :
k8s-master@master:~$ helm upgrade --set scale=5 another-demo ./helming-once-more/
Release "another-demo" has been upgraded. Happy Helming!
NAME: another-demo
LAST DEPLOYED: Fri Aug 12 11:55:14 2022
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
k8s-master@master:~$ kubectl get pod
NAME READY STATUS RESTARTS AGE
my-nginx-deployment-9456bbbf9-7ddlm 1/1 Running 0 95s
my-nginx-deployment-9456bbbf9-mx45n 1/1 Running 0 8m9s
my-nginx-deployment-9456bbbf9-rqkmw 1/1 Running 0 8m9s
my-nginx-deployment-9456bbbf9-tl4wj 1/1 Running 0 8m9s
my-nginx-deployment-9456bbbf9-tpsqv 1/1 Running 0 96s
To finish off, we will delete our app :