This is a sample Python flask hello world application to demonstrate the application containerisation and orchestration workflow.
- Clone the repostiory locally
$ git clone --recursive git@github.com:anrajme/k8s-demo.git- Building docker image
$ docker build -f Dockerfile -t hello-world:v1 .- Tag the new image
$ docker image tag hello-world:v1 anraj/hello-world:v1- Push the image to Docker hub
$ docker push anraj/hello-world:v1- Create kubernetes Deployment
$ kubernetes create -f deployment.yaml- Create the Kubernetes service
$ kubernetes create -f service.yaml- Verify the hello-world application by accessing it via the Node's public IP address. Its "localhost" in case if you are using docker-desktop
$ curl http://locahost:30000-
Edit main.py to print "Hello world V2!"
-
Follow the above steps to build a new image and tag it as hello-world:v2
$ docker build -f Dockerfile -t hello-world:v2 .$ docker image tag hello-world:v2 anraj/hello-world:v2$ docker push anraj/hello-world:v2- Update the Docker image to rollout the new version
$ kubectl set image deployment/hello-world hello-world=anraj/hello-world:v2- Verify the rollout status
$ kubectl rollout history deployment/hello-world- Verify the new application Version
$ curl http://locahost:30000- Rollback the application to the previous version and verify
$ kubectl rollout undo deployment/hello-world$ kubectl rollout status deployment/hello-world$ curl http://locahost:30000
