How To Setup Jenkins On Kubernetes Cluster – Beginners Guide

This guide explains the step by step process for setting up Jenkins on a Kubernetes cluster.

Setup Jenkins On Kubernetes Cluster

For setting up a Jenkins cluster on Kubernetes, we will do the following.

  1. Create a Namespace
  2. Create a deployment yaml and deploy it.
  3. Create a service yaml and deploy it.
  4. Access the Jenkins application on a Node Port.

Note: This tutorial doesn’t use persistent volume as this is a generic guide. For using persistent volume for your Jenkins data, you need to create volumes of relevant cloud or on-prem data center and configure it.

Create a Jenkins Deployment

1. Create a Namespace for Jenkins. So that we will have an isolation for the CI/CD environment.

2. Create a Deployment file named jenkins-deployment.yaml the latest Jenkins Docker Image.

3. Create the jenkins deployment in jenkins namespace using the following command.

4. Now, you can get the deployment details using the following command.

Also, You can get the details from the kubernetes dashboard as shown below.

Create a Jenkins Service

We have created a deployment. However is not accessible to the outside world. For accessing the Jenkins container from outside world, we should create a service and map it to the deployment.

1. Create a jenkins-service.yaml file with the following contents.

Note: In this, we are using the type as NodePort which will expose Jenkins on all kubernetes node IP’s. Also, we have mentioned the nodeport as 30000. So you can access the application on port 30000. If you are on Google Cloud or AWS, you can use the type as Loadbalancer which will launch create a Load balancer and points to the jenkins deployment.

READ  List of DevOps Blogs and Resources for Learning

2. Create the jenkins service using the following command.

Now if you browse to any one of the Node IP on port 30000, you will be able to access the Jenkins dashboard.

3. Jenkins will ask for initial Admin password. You can get that from the pod logs either from kubernetes dashboard or  CLI. You can get the pod details using the following CLI command.

And with the pod name, you can get the logs as shown below. replace the pod name with your pod name.

The password can be found at the end of the log as shown below.


ONLINE COURSE: The Complete Kubernetes Course

Learn how you can run, deploy, manage and maintain containerized Docker applications on Kubernetes

  • Learn to launch kubernetes cluster
  • Get started with Containerization of apps
  • Deploy applications on kubernetes cluster
  • Run stateful and stateless applications on containers

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.

Leave a Reply

Your email address will not be published. Required fields are marked *