How to integrate Jenkins and kubernetes

How to integrate Jenkins and kubernetes

Here I am show you how to integrate kubernetes with jenkins . You can read this comment for better

https://www.dhirubhai.net/feed/update/urn:li:activity:6668454677534908416/?commentUrn=urn%3Ali%3Acomment%3A(activity%3A6668196790988271616%2C6668454634)832719872

Before integration you have to do some settings. I have installed jenkins on RHEL 8 and to integrate with kubernetes cluster we first have to download the kubectl on RHEL 8 because kubectl is the one who manages the kubernetes cluster. Before downloading we first set up two network card on RHEL 8 one is NAT and other is Host only Adapter. We use Nat network card for internet connectivity and Host only network card to connect with kubernetes cluster. For integration it is to be kept in mind that kubectl and jenkins should be installed on same operating system. My kubernetes cluster is running on minikube vm .

No alt text provided for this image
No alt text provided for this image

After this we download kubectl for linux.

No alt text provided for this image

To activate kubectl we use chmod then we move this kubectl to /usr/bin so that we can use this from anywhere.Then we try to get information of pods but some error is coming up .This error is showing because to do connectivity with kubernetes cluster we have to specify the ip of kubernetes and on which port it is running after this we have to give client-key it is like a password, client-certificate it is like a user and a certificate for authentication purpose.We can copy all these files from below path

No alt text provided for this image
No alt text provided for this image

For copying these files from windows to RHEL we can use winscp. Now we can use kubectl on RHEL 8 to connect to kubernetes cluster. but we have to write this long command every time to get rid of this we can do one thing we create a config file and put all this server,clent,certificate information in that file.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

We copy this config file to a folder called kube and in kube to config file by doing this we can directly give the command like kubectl get pods .Now our setup is done is done we can interact with kubernetes cluster without any problem . Lets do some automation with jenkins.

What i am doing here is integrating the jenkins with kubernetes. As soon as the developer upload the yaml file of replica set the jenkins will download this file and create one replicaset . Let me first upload the replicaset file to github.

No alt text provided for this image

After developer upload the file jenkins will download the file .For this we created a job that will contact to github we can use any trigger herei use poll scm .

No alt text provided for this image

Now jenkins check the replicaset is already running or not ,if not then create one replicaset after this it will also check that the rs is exposed to outside world or not , if not then expose this. In this replica set we have set 2 replica for a pod.

No alt text provided for this image

we can see on RHEL 8 that the rs is running fine or not and also check the service

No alt text provided for this image

See all the pods are running fine and the services is also created .

The automation has been completed .

Thank you for reading this article.

Nikhil Suryawanshi

MLOps Engineer | 7x GCP | Kubernetes | Terraform | AWS | DevOps | Java | Python

4 年

Great Work ..!

回复

要查看或添加评论,请登录

Anurag Mittal的更多文章

  • GIT and Github

    GIT and Github

    1. The file in which we write the code is known as programming file and the file resides in some folder that folder is…

  • Deploying webserver on AWS by using Ansible-Dynamic inventory

    Deploying webserver on AWS by using Ansible-Dynamic inventory

    Task Details- Statement: Deploy Web Server on AWS through ANSIBLE! ??Provision EC2 instance through ansible. ??Retrieve…

  • Creating infrastructure in aws using Terraform.

    Creating infrastructure in aws using Terraform.

    Amazon AWS is a cloud service provider. It provides the services to the client what they want.

  • Automation of Machine learning With Devops

    Automation of Machine learning With Devops

    HYPERPARAMETER In the practice of machine and deep learning, Parameters are the properties of training data that will…

  • Transfer learning for Face Recognition

    Transfer learning for Face Recognition

    Our task is to create face recognition model using transfer learning. Transfer learning means by using pre trained…

社区洞察

其他会员也浏览了