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
- Docker installed
- Dockerhub Account
- Minikube installed
-
Create a sample node js web application
-
Dockerize your app
-
If there is any exist app already with the name first-app, delete the deployment plan
$ kubectl delete deployment first-app
- 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
- Start the minikube service for first-app
$ minikube service first-app
- Check on the k8 pods
kubectl get pods
-
Access the node js web app via http://localhost:28522
-
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
-
Wait for 2 mins and try accessing the app again
-
Let us now scale the app to 3 replicas
kubectl scale deployment/first-app --replicas=3
- 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
-
Let us make some changes to the node js web app "change the page para from version 3 to 4"
-
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
- Make sure the deployment plan is still up and running
kubecctl get deployments
- Update the deployment plan with the latest docker tag version
kubectl set image deployments/first-app kub-first=kenken64/kub-first-app:2
- Check whether is the deployment plab rollout with the updates
kubectl get deployments
kubectl rollout status deployment/first-app
-
Access the node js web app via http://localhost:28522
-
Let us try rollback the updates of the app
kubectl rollout undo deployment/first-app
- Check whether is the deployment plab rollout with the updates
kubectl rollout status deployment/first-app