Installing and Deploying Jenkins Master
On the Jenkins page, the UI strings in Chinese and English are different. The screenshots in this section are for your reference only.
Selecting an Image
Select a relatively new, stable image from Docker Hub. For this test, select jenkinsci/blueocean, which is bound with all Blue Ocean add-ons and functions. There is no need to install Blue Ocean add-ons separately. For details, see Installing Jenkins.
Preparations
- Before creating a containerized workload, buy a cluster (the cluster must contain at least one node with four vCPUs and 8 GiB memory). For details, see Buying a CCE Cluster.
The Docker in Docker scenario is required, which is, running the Docker commands in the container. Select the Docker container engine for the node.
- To enable external networks to access the workload, ensure that an elastic IP address (EIP) has been bound to or a load balancer has been configured for at least one node in the cluster.
Installing and Deploying Jenkins on CCE
- Log in to the CCE console, choose Workloads > Deployments and click Create Workload on the upper right corner.
- Configure basic workload parameters.
- Workload Name: jenkins (customizable)
- Namespace: Select the namespace where Jenkins will be deployed. You can create a namespace.
- Pods: Set it to 1.
- Configure basic container parameters.
- Image Name: Enter jenkinsci/blueocean. Select an image version as required. If no version is selected, the latest version will be used by default.
- CPU Quota: Set Limit to 2 cores.
- Memory Quota: Set Limit to 2048 MiB.
- Privileged Container: If Jenkins is deployed with a single Master, enable Privileged Container so that the container can perform operations on the host. Otherwise, Docker commands cannot be executed in the Jenkins Master container.
Retain the default values for other parameters.Figure 1 Basic container parameters
- Choose Data Storage > PersistentVolumeClaims (PVCs) and add a persistent volume.
In the displayed dialog box, select a cloud volume and enter /var/jenkins_home in the mount path to mount a cloud volume for Jenkins to store data persistently.
The cloud storage type can be EVS or SFS. If no cloud storage is available, click Create PVC.
If you select EVS, the AZ of the EVS disk must be the same as that of the node.
Figure 2 Adding a cloud volume
- Add permissions to the Jenkins container so that related commands can be executed in it.
- Ensure that Privileged Container is enabled in 3.
- Choose Data Storage > Local Volumes, add a local volume, and mount the host path to the corresponding container path.
Table 1 Mounting path Storage Type
Host Path
Mounting Path
hostPath
/var/run/docker.sock
/var/run/docker.sock
hostPath
/usr/bin/docker
/usr/bin/docker
hostPath
/usr/lib64/libltdl.so.7
/usr/lib/x86_64-linux-gnu/libltdl.so.7
hostPath
/usr/bin/kubectl
/usr/local/bin/kubectl
After the mounting is complete, the page shown in Figure 3 is displayed. - In Security Context, set User ID to 0 (user root).
Figure 4 Configuring the user
- Specify the access mode in Service Configuration.
The Jenkins container image has two ports: 8080 and 50000. Configure them separately. Port 8080 is used for web login, and port 50000 is used for the connection between Master and Agent.
In this example, two Services are created:
- LoadBalancer: provides external web access using port 8080. You can also select NodePort to provide external access.
Set the Service name to jenkins (customizable), the container port to 8080, the access port to 8080, and retain the default values for other parameters.
- ClusterIP: used by the Agent to connect to the Master. The IP addresses of jenkins-web and jenkins-agent need to be the same. Therefore, port 8080 for web access and port 50000 for agent access are included.
Set the Service name to agent (customizable), the container port 1 to 8080, the access port 1 to 8080, the container port 2 to 50000, the access port 2 to 50000, and retain the default values for other parameters.
In this example, Agents and the Master are deployed in the same cluster. Therefore, the Agents can use the ClusterIP Service to connect to the Master.
If Agents need to connect to the Master across clusters or through the public network, select a proper Service type. Note that the IP addresses of Jenkins-web and Jenkins-agent need to be the same. Therefore, ports 8080 and 50000 must be enabled for the IP address connected to jenkins-agent. For addresses used only for web access, enable only the port 8080.
Figure 5 Adding a Service
- LoadBalancer: provides external web access using port 8080. You can also select NodePort to provide external access.
- Retain the default settings for Advanced Settings and click Create Workload.
- Click Back to Deployment List to view the Deployment status. If the workload is in the Running status, the Jenkins application is accessible.
Figure 6 Viewing the workload status
Logging In and Initializing Jenkins
- On the CCE console, click the target cluster. Choose Networking in the navigation pane. On the Services tab page, view the Jenkins access mode.
Figure 7 Access mode corresponding to port 8080
- Enter EIP:8080 of the load balancer in the browser address box to visit the Jenkins configuration page.
When you visit the page for the first time, you are prompted to obtain the initial administrator password. You can obtain the password from the Jenkins pod. Before running the following commands, connect to the cluster using kubectl. For details, see Connecting to a Cluster Using kubectl.
# kubectl get pod -n cicd NAME READY STATUS RESTARTS AGE jenkins-7c69b6947c-5gvlm 1/1 Running 0 17m # kubectl exec -it jenkins-7c69b6947c-5gvlm -n cicd -- /bin/sh # cat /var/jenkins_home/secrets/initialAdminPassword b10eabe29a9f427c9b54c01a9c3383ae
- The system prompts you to select the default recommended add-on and create an administrator upon the first login. After the initial configuration is complete, the Jenkins page is displayed.
Modifying the Number of Concurrent Build Jobs
- On the Jenkins dashboard page, click Manage Jenkins on the left, choose System Configuration > Manage nodes and clouds, and select Configure from the drop-down list of the target node.
- You can modify the number of concurrent build jobs on both Master and Agent. The following uses Master as an example.
- If the Master is used with Agents, you are advised to set the number of concurrent build jobs of Master to 0. That is, all build jobs are performed using Agents. If a single Master is used, you do not need to change the value to 0.
- Modify the maximum number of concurrent build jobs. In this example, the value is changed to 2. You can change the value as required.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot