AUTOMATED WEB APP DEPLOYMENT USING KUBERNETES
Nikhil G R
Senior Data Engineer (Apache Spark Developer) @ SAP Labs India, Ex TCS, 3x Microsoft Azure Cloud Certified, Python, Pyspark, Azure Databricks, SAP BDC, Datasphere, ADLs, Azure Data factory, MySQL, Delta Lake
ARCHITECTURE
This article helps you to automate Web deployment with Kubernetes. Generally, it is not an easy task to fetch the code of a developer from the Jenkins and make Operating System according to his/her need and upload it on the docker hub and from there we can pull the image to deploy it on Kubernetes and Kubernetes will launch the pod. Isn't it a very long and tired process to do it again and again ??
We always need to update the things frequently once its made right. Today in this article I am going to explain how to automate this long process.
We are going to see once the developer upload his/her dockerfile and webpages onto the GitHub, Jenkins will automatically pull the file from git hub to build the docker image. It will automatically upload it to the docker hub. After this Jenkins will run one more job to pull the image from the docker hub and create a deployment on Kubernetes cluster with Auto scaling feature. So if the traffic increases, pod will increase. If traffic reduces the pod will close automatically and it will also expose the service so that we can access our website. These all tedious process will be automated using the job chain in Jenkins.
The code of the docker file can be found on my github account which is attached at the last of this article.
JOB1- It will pull files from GitHub and build an image from Dockerfile and push it to the docker hub.
This job is done manually if we dont use jenkins for automating.
If we use jenkins the job will be automated. It can be automated as shown below.
So as of now job1 is been completed.Our image is been build and uploaded by Jenkins automatically.
JOB2
Lets get into job2.
If the deployment is created for the first time it will be successfully created and do auto-scaling according to the CPU load and expose the deployment.
But if the image is uploaded and job2 is runned again it will roll the update in the same deployment and will upload the content.
When the pod is not ready it looks like the image that's shown below.
When the pod not ready it looks like the image that's shown below.
This is the view when its run for the first time as we can see in IMAGES.
The IP which we get is local IP. It means who are connected to our network only, they can access but we want to expose this to the rest of the world so that they can also access it.
First of all download ngrok according to the Operating System and unzip it. Add the path of it into the system.
Replace IP with your IP and port with your respective port number.
In my case it looke like this.
Conclusion
Today we have created a beautiful pipeline to automate very hard and big things of deployment of web application using Kubernetes. We have created the deployment with auto-scaling feature enabling in Kubernetes so that if the traffic increases pods will scale up and the if traffic is low pod will scale down using job chain in Jenkins automatically.
GITHUB LINK FOR DOCKERFILE
I wanna thank Mr ADITYA GUPTA for helping me to complete this task.
Thank You guys for reading this article..