Support Online
Skip to main content

Jenkins Installation

What Will You Learn in This Guide?

In this guide, you will learn how to run Jenkins on a Kubernetes cluster.
You will make a declarative installation with YAML files, open Jenkins and run your first CI/CD pipeline.

At the end of the guide, you will have a scalable and centralized Jenkins environment.

Technical Summary

Subject: Jenkins installation on Kubernetes
Solved Problem: Jenkins working on a single server and not scalable
Approach: Publishing Jenkins on the cluster using Deployment and Service
Steps: Namespace → Deployment → Service → UI access → Pipeline run


Prerequisites

The following is required before continuing:

  • A running Kubernetes cluster
  • Configured kubectl
  • Authorized access on the cluster

Note: The examples assume GenixNode Kubernetes infrastructure.


Creating Jenkins Deployment

In Kubernetes, applications are defined with YAML files.

kubectl create namespace jenkins
  • This command creates an isolated namespace for Jenkins.


nano jenkins.yaml


apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins/jenkins:lts
ports:
- containerPort: 8080
- containerPort: 50000
volumeMounts:
- name: jenkins-vol
mountPath: /var/jenkins_vol
volumes:
- name: jenkins-vol
emptyDir: {}
  • This build runs the Jenkins LTS image and opens the necessary ports.


kubectl apply -f jenkins.yaml -n jenkins
  • This command starts the Jenkins Pod.


kubectl get pods -n jenkins
  • The pod must be in Running state.

Exporting Jenkins Service

  1. Service is defined to access the Jenkins interface.

nano jenkins-service.yaml


apiVersion: v1
kind: Service
metadata:
name: jenkins
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
nodePort: 30000
selector:
app: jenkins
---
apiVersion: v1
kind: Service
metadata:
name: jenkins-jnlp
spec:
type: ClusterIP
ports:
- port: 50000
targetPort: 50000
selector:
app: jenkins
  • This structure makes Jenkins accessible via port 30000.


kubectl apply -f jenkins-service.yaml -n jenkins


kubectl get services -n jenkins
  • Verifies that the services are active.

Accessing Jenkins Interface and Obtaining Password

  1. First find out the node IP address.

kubectl get nodes -o wide
  1. From the browser, go to:

http://node_ip_adresi:30000

  1. Admin Password

kubectl get pods -n jenkins


kubectl logs pod_adi -n jenkins
  • This command shows the Jenkins startup password.

In the interface:

  1. Install suggested plugins

  2. Creating an admin user

  3. Continue with default settings

Follow steps 4.


First Pipeline Run

  1. On the Jenkins home page, click New Item.

  2. Select the Pipeline type and continue.

  3. In the Pipeline section, select the Hello World instance.

  4. Run the pipeline with Build Now.

  • This process verifies that the Jenkins CI/CD engine is running.

Frequently Asked Questions (FAQ)

1. Will data be lost if Jenkins Pod is deleted? Yes. Since emptyDir is used, the data is temporary.

2. How to ensure permanence? PersistentVolume and PVC should be used in production environments.

3. Can LoadBalancer be used instead of NodePort? Yes. Recommended if your cloud provider supports it.

4. I am getting CrashLoopBackOff error, why does it happen? It is usually caused by insufficient resources or misconfiguration. Examine the details with kubectl describe pod pod_adi -n jenkins.


Result

With this guide, you have made Jenkins running on Kubernetes. You now have a scalable, centralized and modern CI/CD infrastructure.

You can safely automate your projects by using this setup on the GenixNode Kubernetes infrastructure.