The main motive of this article is to solve real-world problems. Can you imagine the loss of Instagram, not only loss but also hate of a million users it receives if it is even down by a few seconds, so nobody would want that, right?

It can be solved by using automatic rollout of updates using Kubernetes and managing the build triggers by Jenkins.

So let us get going, on how to solve this major issue in this easy way.

Our system requirements:

  • **2 RHEL 8 VM’s **(1 as docker server with Jenkins configured and the other as docker client)
  • Jenkins(it should be updated as some plugins might not work with the outdated version)should have the following plugins installed

1. Build Pipeline Plugin

2. Docker Plugin

3.GitHub Plugin

  • We need to create a Dockerfile with** kubectl** configured so that this image will run as a slave for Jenkins as well as** SSH configured**
  • Minikube configured and it is running( to start do minikube start )

First of all, we need to set up socket binding so as to allow the docker services of this VM to be used by others also. For this, we need to enable TCP support also. This is done by adding _-H tcp://0.0.0.0:1234 in /usr/lib/systemd/system/docker.service _file in the docker server.

vim /usr/lib/systemd/system/docker.service

Image for post

change configuration of the docker services

Now restart your docker services using:

systemctl daemon-reload
systemctl restart docker

Now, a container image is created that has Linux and other basic configuration required to run Slave for Jenkins.

Step by step explanation of the Dockerfile are:

  1. Use centos as the BaseOS
  2. Install java
  3. Install ssh
  4. Install sudo command so as there are no issues in permissions
  5. Set both the password and username as root, which will help in connect using ssh
  6. Install the kubectl command
  7. Make the kubectl command executable
  8. Move the kubectl command to the /usr/local/bin location,so as to make it accessible from anywhere
  9. Create .kube directory in the /root folder
  10. Copy the config file, client.key,client.crt,ca.crt file to the /root/.kube directory. (The permission files are those of kubectl configured of your HostOS)

#dockerfiles #jenkins #kubernetes #rolling-updates #docker

Web-Server With Live Rolling Updates Using Dynamic Jenkins Slave Node
1.45 GEEK