Overview
In this session, we will go through the basics of Kubernetes and Helm. We would be discussing the complexities of writing and managing Kubernetes Yaml’s and how we can overcome by Helm Charts. Next, a simple workflow demonstration of CICD involving Helm, Git, and Jenkins.
Goal
- To create
Deployment,ServiceandIngressusingkubectlcommands. - To leverage Helm charts over Kubernetes yamls.
- Continuously delivering applications to Kubernetes using Helm.
Using Kubectl Commands
Let’s set our namespace as a environment variable. Note: Replace {{ username }} with actual username provided to you to login to the system
export NAMESPACE={{ username }}
Example: export NAMESPACE=user1
Let’s verify if our environment variable is set as your login username
echo $NAMESPACE
Now lets create a kubernetes namespace.
kubectl create namespace $NAMESPACE
Let’s clone helm-meetup repo from github
git clone https://github.com/kvenkata986/helm-meetup.git
Now lets navigate to helm-meetup/kubectl directory. List the files in the directory and you will notice three files deployment.yaml, service.yaml and ingress.yaml
cd helm-meetup/kubectl
ls -l
Now lets create Deployment, Service and Ingress using kubectl commands.
kubectl create -f deployment.yaml --namespace $NAMESPACE
kubectl create -f service.yaml --namespace $NAMESPACE
kubectl create -f ingress.yaml --namespace $NAMESPACE
Now lets verify if our Deployment, Service and Ingress are actually created.
kubectl get deployments --namespace $NAMESPACE
kubectl get service --namespace $NAMESPACE
kubectl get ingress --namespace $NAMESPACE
Note: After creating an ingress in Google cloud, it will take approximately 25min to get a Public IP
To see our simple-web page, lets do curl on our deployment
ip=$(kubectl get service --namespace $NAMESPACE | grep myfirst-service | awk '{print $3}'); curl http://$ip:80
Now lets delete our Deployment, Service and Ingress.
kubectl delete deployment myfirst-deployment --namespace $NAMESPACE
kubectl delete service myfirst-service --namespace $NAMESPACE
kubectl delete ingress myfirst-ingress --namespace $NAMESPACE
Using helm Commands
Now lets navigate to helm directory. List the files in the directory and you will notice Chart.yaml, values.yaml files and templates/ directory.
cd ../helm
ls -l
Now lets see if any helm charts are installed in your namespace.
helm list --namespace $NAMESPACE
Now lets install helm-nginx chart.
helm install . --name my-first-helm-chart-$NAMESPACE --namespace $NAMESPACE
Now lets verify if helm chart was successfully installed in your namespace.
helm list --namespace $NAMESPACE
kubectl get deployments --namespace $NAMESPACE
kubectl get service --namespace $NAMESPACE
kubectl get ingress --namespace $NAMESPACE
To see our simple-web page, lets do curl on our deployment
ip=$(kubectl get service --namespace $NAMESPACE | grep myfirst-service | awk '{print $3}'); curl http://$ip:80
Now lets update some values in helm charts. lets scale our pod count to 9 and upgrade simple-web version to 1.1
helm upgrade --set replica=9,version="1.1" my-first-helm-chart-$NAMESPACE . --namespace $NAMESPACE
To see our upgraded simple-web page, lets do curl on our deployment
ip=$(kubectl get service --namespace $NAMESPACE | grep myfirst-service | awk '{print $3}'); curl http://$ip:80
Now lets delete of helm charts
helm delete my-first-helm-chart-$NAMESPACE

Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email