How To Create Jenkins On Kubernetes Cluster
In this article, I’ll explain the step-by-step jenkins installation on Kubernetes. I’am assuming at this point you know a little bit about kubernetes and containers.
Kubernetes has container orchestration capability so Jenkins always has the right amount of resources available. Jenkins agent is a great way of reducing the cost of the CI environment.
For setting up a Jenkins cluster on Kubernetes, we will do the following steps.
- Create a namespace
2. Create a deployment YAML file and deploy it.
3. Create a service YAML file and deploy it.
4. We will access jenkins application via node port.
Setup Jenkins on Kubernetes Cluster
- You create a new kubernetes namespace to store all Jenkins deployment resources. Namespace provides virtual isolation of resource groups within a single cluster.
kubectl create namespace jenkins
2. After you create the Jenkins namespace, you can now create a kubernetes deployment yaml file. A deployment is an object in Kubernetes. It is responsible for creating the pods.
kubectl apply -f deployment.yaml — namespace jenkins
3. Yes, you need a service file. Service enables network access to a set of Pods in Kubernetes. Services select Pods based on their labels. When a network request is made to the service, it selects all Pods in the cluster matching the service’s selector, chooses one of them.
kubectl apply -f service.yaml — namespace jenkins
After running the service yaml file, you can access our application via port 32000. You can able to access the Jenkins dashboard.
You can check the status of jenkins pod.
Jenkins ask for the initial Admin password when you access the for the first time.
kubectl logs jenkins-7dcc9f96d8-t74c9 -n jenkins
you can get the logs as shown below, The password can be found at the end of the log as shown below.
you can paste this password. In the next step, you select “Install suggested plugin” and expect plugins to be uploaded to jenkins and then after completing the username and password determination steps, you access the jenkins home page.
Thank you.