Jenkins

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:~kubectl get nodes
NAME            STATUS    AGE       VERSION
kubemaster      Ready     3d        v1.7.5
kubeminion-01   Ready     3d        v1.7.5
kubeminion-02   Ready     3d        v1.7.5

Download and apply the Jenkins YAML file from the OpenEBS repository using the following commands.

ubuntu@kubemaster:~wget https://raw.githubusercontent.com/openebs/openebs/master/k8s/demo/jenkins/jenkins.yml
ubuntu@kubemaster:~kubectl apply -f jenkins.yml

Get the status of running pods using the following command.

ubuntu@kubemaster:~kubectl get pods
NAME                                                             READY     STATUS    RESTARTS   AGE
jenkins-2748455067-85jv2                                         1/1       Running   0          9m
maya-apiserver-3416621614-r4821                                  1/1       Running   0          17m
openebs-provisioner-4230626287-7kjt4                             1/1       Running   0          17m
pvc-c52aa2d0-bcbc-11e7-a3ad-021c6f7dbe9d-ctrl-1457148150-v6ccz   1/1       Running   0          9m
pvc-c52aa2d0-bcbc-11e7-a3ad-021c6f7dbe9d-rep-2977732037-kqv6f    1/1       Running   0          9m
pvc-c52aa2d0-bcbc-11e7-a3ad-021c6f7dbe9d-rep-2977732037-s6g2s    1/1       Running   0          9m

Get the status of underlying persistent volumes used by Jenkins deployment using the following command.

ubuntu@kubemaster:~kubectl get pvc
NAME            STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS       AGE
jenkins-claim   Bound     pvc-c52aa2d0-bcbc-11e7-a3ad-021c6f7dbe9d   5G         RWO           openebs-standard   12m

Get the status of Jenkins service using the following command.

ubuntu@kubemaster:~kubectl get svc
NAME                                                CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
jenkins-svc                                         10.107.147.241   <nodes>       80:32540/TCP        25m
kubernetes                                          10.96.0.1        <none>        443/TCP             3d
maya-apiserver-service                              10.97.14.255     <none>        5656/TCP            33m
pvc-c52aa2d0-bcbc-11e7-a3ad-021c6f7dbe9d-ctrl-svc   10.110.186.186   <none>        3260/TCP,9501/TCP   25m

Launching Jenkins

The Jenkins deployment YAML, creates a NodePort service type to make Jenkins available outside the cluster.

Note:

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:~kubectl describe pod jenkins-2748455067-85jv2 | grep Node:
Node:               kubeminion-02/172.28.128.5

Get the port number from the Jenkins service using the following command.

ubuntu@kubemaster-01:~ kubectl describe svc jenkins-svc | grep NodePort:
NodePort:           <unset> 32540/TCP

Open the https://172.28.128.5:32540 URL in your browser.

Note:

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.

  1. Provide the initialAdminPassword in the Unlock Jenkins screen and copy the password in the Administrator password field.
  2. Click Continue.

3. Get the password using the following command:

ubuntu@kubemaster:~kubectl exec -it jenkins-2748455067-85jv2 cat /var/jenkins_home/secrets/initialAdminPassword
7d7aaedb5a2a441b99117b3bb55c1eff
  1. In the Customize Jenkins screen click Install suggested plugins.
  2. Configure the Administrator user in the Create First Admin User screen. Fill in the following fields.
    1. Username: - Key in the administrator username.
    2. Password: - Key in the password for the administrator.
    3. Confirm password - Key in the password again and confirm.
    4. Full name - Key in the administrator’s full name.
  3. Click Continue as admin if you want to perform further administrator tasks or click Save and Finish.

You can now start using Jenkins.