Skip to content

Latest commit

 

History

History
101 lines (64 loc) · 2.53 KB

k8.md

File metadata and controls

101 lines (64 loc) · 2.53 KB

S-DOEA - Workshop 8 - Kubernetes

Kubernetes is an open-source container orchestration system for automating software deployment, scaling, and management. Google originally designed Kubernetes, but the Cloud Native Computing Foundation

This workshop only works on Windows machine

Pre-requisites

  • Docker installed
  • Dockerhub Account
  • Minikube installed
  1. Create a sample node js web application

  2. Dockerize your app

  3. If there is any exist app already with the name first-app, delete the deployment plan

$ kubectl delete deployment first-app
  1. Recreate the k8 deployment plan where it will retrieve docker image from your dockerhub account. (Make sure you already published your docker image to the hub)
$ kubectl create deployment first-app --image=kenken64/kub-first-app
  1. Start the minikube service for first-app
$ minikube service first-app
  1. Check on the k8 pods
kubectl get pods
  1. Access the node js web app via http://localhost:28522

  2. Lets test out the self healing feature when application is deployed to k8, access this end point on your web browser http://localhost:28522/error. This will result in crashing your app , kubernetes will auto restart your app automatically

  3. Wait for 2 mins and try accessing the app again

  4. Let us now scale the app to 3 replicas

kubectl scale deployment/first-app --replicas=3
  1. Repeat step 8 and observe the behaviour of k8 in terms of how it will load balance to the exisitng runing pods. Check the status of the individual pos
$ kubectl get pods
  1. Let us make some changes to the node js web app "change the page para from version 3 to 4"

  2. Rebuild the docker image with a new tag and publish it

docker build -t kenken64/kub-first-app:2 .

docker push kenken64/kub-first-app:2
  1. Make sure the deployment plan is still up and running
kubecctl get deployments
  1. Update the deployment plan with the latest docker tag version
kubectl set image deployments/first-app kub-first=kenken64/kub-first-app:2

  1. Check whether is the deployment plab rollout with the updates
kubectl get deployments
kubectl rollout status deployment/first-app
  1. Access the node js web app via http://localhost:28522

  2. Let us try rollback the updates of the app

kubectl rollout undo deployment/first-app
  1. Check whether is the deployment plab rollout with the updates
kubectl rollout status deployment/first-app