This section demonstrates the deployment of Jenkins as a pod in a Kubernetes cluster. You can spawn a Jenkins deployment which will use OpenEBS as its persistent storage.
Deploying Jenkins as a Pod
Deploying Jenkins as a pod provides the following benefits.
- Isolates different jobs from one another
- Quickly cleans a job’s workspace.
- Dynamically deploys or schedules jobs with Kubernetes pods
- Allows increased resource utilization and efficiency
Deploying Jenkins Pod with Persistent Storage
Before getting started, check the status of the cluster using the following command.
ubuntu@kubemaster-01:~/openebs/k8s$ kubectl get nodes NAME STATUS ROLES AGE VERSION kubemaster-01 Ready master 16m v1.9.4 kubeminion-01 Ready <none> 12m v1.9.4 kubeminion-02 Ready <none> 9m v1.9.4 kubeminion-03 Ready <none> 7m v1.9.4
Also make sure that you have deployed OpenEBS in your cluster.
ubuntu@kubemaster-01:~/openebs/k8s$ kubectl get pods -n openebs NAME READY STATUS RESTARTS AGE maya-apiserver-84fd4f776d-lvxcp 1/1 Running 0 6m openebs-provisioner-74cb999586-268k7 1/1 Running 0 6m openebs-snapshot-controller-6449b4cdbb-24fz4 2/2 Running 0 6m
Download and apply the Jenkins YAML file from the OpenEBS repository using the following commands.
git clone https://github.com/openebs/openebs cd openebs/k8s/demo/jenkins kubectl apply -f jenkins.yml
Get the status of running pods using the following command. Application Pod and PVC pods are running in default namespace.
ubuntu@kubemaster-01:~/openebs/k8s/demo/jenkins$ kubectl get pods NAME READY STATUS RESTARTS AGE jenkins-6bc67f99d7-jpn62 1/1 Running 0 30m pvc-e4bcafe4-791c-11e8-ae41-02b983f0a4db-ctrl-dcbb9f74c-smvnl 2/2 Running 0 30m pvc-e4bcafe4-791c-11e8-ae41-02b983f0a4db-rep-5547d6bcd-8cw4z 1/1 Running 0 30m pvc-e4bcafe4-791c-11e8-ae41-02b983f0a4db-rep-5547d6bcd-fjj7d 1/1 Running 0 30m pvc-e4bcafe4-791c-11e8-ae41-02b983f0a4db-rep-5547d6bcd-q4tm8 1/1 Running 0 30m
Get the status of underlying persistent volumes used by Jenkins deployment using the following command.
ubuntu@kubemaster-01:~/openebs/k8s/demo/jenkins$ kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE jenkins-claim Bound pvc-e4bcafe4-791c-11e8-ae41-02b983f0a4db 5G RWO openebs-standard 21m
Get the status of Jenkins service using the following command.
ubuntu@kubemaster-01:~/openebs/k8s/demo/jenkins$ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE jenkins-svc NodePort 10.109.111.160 <none> 80:30577/TCP 21m kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h pvc-e4bcafe4-791c-11e8-ae41-02b983f0a4db-ctrl-svc ClusterIP 10.106.18.214 <none> 3260/TCP,9501/TCP 21m
The Jenkins deployment YAML, creates a NodePort service type to make Jenkins available outside the cluster.
The cluster is setup using vagrant VMs and the IP addresses are autogenerated by vagrant.
Get the node IP address that is running the Jenkins pod using the following command.
ubuntu@kubemaster-01:~/openebs/k8s/demo/jenkins$ kubectl describe pod jenkins-6bc67f99d7-r6hw7 | grep Node: Node: kubeminion-02/172.28.128.5
Get the port number from the Jenkins service using the following command.
ubuntu@kubemaster-01:~/openebs/k8s/demo/jenkins$ kubectl describe svc jenkins-svc | grep NodePort: NodePort: <unset> 30577/TCP
Open the http://172.28.128.5:30577 URL in your browser.
The NodePort is dynamically allocated and may vary in a different deployment.
Once you access the URL the Getting Started page is displayed. The following procedure helps you setup Jenkins.
It will ask for initialAdminPassword.
Get the password by executing below way.
kubectl exec -it jenkins-6bc67f99d7-l9p5h cat /var/jenkins_home/secrets/initialAdminPassword
Note: Replace jenkins-6bc67f99d7-l9p5h with your jenkin pod name.
Provide the initialAdminPassword in the Unlock Jenkins screen ..
In the Customize Jenkins screen click Install suggested plugins.
Configure the Administrator user in the Create First Admin User screen.
Click Continue as admin if you want to perform further administrator tasks or click Save and Continue.
Do final configuration by providing the required IP to access Jenkin application or go with the provided IP and click Save and Finish.
You can now start using Jenkins.