Saturday, 11 October 2025

Deploy Jenkins CI Server on Kubernetes: Step-by-Step Guide for DevOps Engineers

Our course you can check :-   Udemy course 


Ques:-     

DevOps team is planning to set up a Jenkins CI server to create/manage some deployment pipelines for some of the projects. They want to set up the Jenkins server on Kubernetes cluster. Below you can find more details about the task:

1) Create a namespace jenkins

2) Create a Service for jenkins deployment. Service name should be jenkins-service under jenkins namespace, type should be NodePort, nodePort should be 30008

3) Create a Jenkins Deployment under jenkins namespace, It should be name as jenkins-deployment , labels app should be jenkins , container name should be jenkins-container , use jenkins/jenkins image , containerPort should be 8080 and replicas count should be 1.

Make sure to wait for the pods to be in running state and make sure you are able to access the Jenkins login screen in the browser.

Ans:-

Here’s how you can complete the Jenkins CI server setup on a Kubernetes cluster as per your requirements:

raj@jumphost ~$ cat pod.yaml 

---

apiVersion: v1

kind: Namespace

metadata:

  name: jenkins


---

apiVersion: apps/v1

kind: Deployment

metadata:

  name: jenkins-deployment

  namespace: jenkins

  labels:

    app: jenkins

spec:

  replicas: 1

  selector:

    matchLabels:

      app: jenkins

  template:

    metadata:

      labels:

        app: jenkins

    spec:

      containers:

        - name: jenkins-container

          image: jenkins/jenkins

          ports:

            - containerPort: 8080


---

apiVersion: v1

kind: Service

metadata:

  name: jenkins-service

  namespace: jenkins

spec:

  type: NodePort

  selector:

    app: jenkins

  ports:

    - port: 8080

      targetPort: 8080

      nodePort: 30008


raj@jumphost ~$ kubectl apply -f pod.yaml 

namespace/jenkins created

deployment.apps/jenkins-deployment created

service/jenkins-service created


raj@jumphost ~$ kubectl get all -n jenkins

NAME                                      READY   STATUS    RESTARTS   AGE

pod/jenkins-deployment-667887d68c-wcz9b   1/1     Running   0          36s


NAME                      TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE

service/jenkins-service   NodePort   10.96.192.186   <none>        8080:30008/TCP   36s


NAME                                 READY   UP-TO-DATE   AVAILABLE   AGE

deployment.apps/jenkins-deployment   1/1     1            1           36s


NAME                                            DESIRED   CURRENT   READY   AGE

replicaset.apps/jenkins-deployment-667887d68c   1         1         1       36s

raj@jumphost ~$ 


Access Jenkins UI: Open your browser and go to:

http://<NodeIP>:30008

Replace <NodeIP> with the IP of your Kubernetes node.

No comments:

Post a Comment