anrajme / k8s-demo

Hello World Flask Application Deployment on Kubernetes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python flask hello-world application deployment on Kubernetes!

This is a sample Python flask hello world application to demonstrate the application containerisation and orchestration workflow.

image

Setup the workspace

  1. Clone the repostiory locally
$ git clone --recursive git@github.com:anrajme/k8s-demo.git

Build the container and upload to the registry

  1. Building docker image
$ docker build -f Dockerfile -t hello-world:v1 .
  1. Tag the new image
$ docker image tag hello-world:v1 anraj/hello-world:v1
  1. Push the image to Docker hub
$ docker push anraj/hello-world:v1

Create the Kubernetes objects

  1. Create kubernetes Deployment
$ kubernetes create -f deployment.yaml
  1. Create the Kubernetes service
$ kubernetes create -f service.yaml

Verify the application

  1. 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

Upgrade the application and test the deployment rollout

  1. Edit main.py to print "Hello world V2!"

  2. 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
  1. Update the Docker image to rollout the new version
$ kubectl set image deployment/hello-world hello-world=anraj/hello-world:v2
  1. Verify the rollout status
$ kubectl rollout history deployment/hello-world
  1. Verify the new application Version
$ curl http://locahost:30000
  1. 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

About

Hello World Flask Application Deployment on Kubernetes


Languages

Language:Python 54.2%Language:Dockerfile 45.8%