How it works...

Now we start to configure Jenkins to build your application. However, to access the WebUI of your custom Jenkins, you need to access the Kubernetes service that binds to your Jenkins pod. It is easier to use kubectl port-forward to access remotely to configure Jenkins:

//check pod name
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-jenkins-cbdd6446d-ttxj5 1/1 Running 0 1m

//port forward from your machine :58080 to Jenkins :8080
$ kubectl port-forward my-jenkins-cbdd6446d-ttxj5 58080:8080
Forwarding from 127.0.0.1:58080 -> 8080

The initial configuration of Jenkins is done via the following steps:

  1. Access the http://127.0.0.1:58080 Jenkins WebUI; it asks you to input initialAdminPassword.
  2. Use kubectl exec to acquire the initialAdminPassword. Then copy and paste to the Jenkins WebUI to proceed with the initial configuration to install the suggested plugin and create an admin user:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-jenkins-cbdd6446d-ttxj5 1/1 Running 0 1m

//now you see initialAdminPassword
$ kubectl exec my-jenkins-cbdd6446d-ttxj5 -- /bin/bash -c 'cat /var/jenkins_home/secrets/initialAdminPassword'
47e236f0bf334f838c33f80aac206c22
  1. You will see a Jenkins top page. Then click Manage Jenkins, then Configure System:
Navigate to Jenkins configuration
  1. Scroll to the bottom and find a Cloud section. Click Add a new cloud to select Docker:
Adding a Docker setting
  1. Put Name as your desired name (example: my-docker) and specify the Docker Host URI and Docker domain socket as unix:///var/run/docker.sock:
Configure Docker on Jenkins
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.115.154