Updated on 2026-01-05 GMT+08:00

Installing and Deploying a 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, meaning Docker commands must run inside containers. Select the Docker container runtime for the node. Otherwise, you must install Docker directly on 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

  1. Log in to the CCE console. In the navigation pane, choose Workloads. In the right pane, click the Deployments tab and click Create Workload in the upper right corner.
  2. Configure basic workload parameters.

    • Workload Name: jenkins (or another name)
    • Namespace: Select the namespace where Jenkins will be deployed. You can create a namespace.
    • Pods: Set it to 1.

  3. Configure basic container parameters.

    • Image Name: Enter jenkinsci/blueocean. Select an image tag as required. If no tag is selected, latest will be used by default.
    • CPU Quota: Set Limit to 2 cores.
    • Memory Quota: Set Limit to 2048 MiB.
    • Privileged Container: If Jenkins with a single master is used, the privileged container must be enabled so that the container can perform operations on the node. Otherwise, you cannot run the Docker commands in the Jenkins master container.
    Retain the default values for other parameters.
    Figure 1 Basic container parameters

  4. Click Data Storage and add a persistent storage volume.

    Click Add Volume, select PVC from the drop-down list, and add a cloud storage volume. Enter /var/jenkins_home under Mount Path to mount the volume to /var/jenkins_home of the Jenkins container for persistent data storage.

    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 storage volume

  5. Add permissions to the Jenkins container so that related commands can be executed in it.

    1. Ensure that Privileged Container is enabled in 3.
    2. Click Data Storage, click Add Volume, select hostPath, and mount the hostPath to the corresponding container path.
      Table 1 Mount path

      Storage Type

      Host Path

      Mount 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.
      Figure 3 Mounting the hostPath volumes to the corresponding container paths

    3. In Security Context, set User ID to 0 (user root).
      Figure 4 Configuring the user

  6. Specify Services in the Service Settings area.

    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 over port 8080. You can also select NodePort for external access.

      Set Service Name to jenkins (or another name), Container Port to 8080, and Access Port to 8080. Retain the default values for other parameters.

    • ClusterIP: used by the agent to access 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 Service Name to agent (or another name), Container Port 1 to 8080, Access Port 1 to 8080, Container Port 2 to 50000, and Access Port 2 to 50000. Retain the default values for other parameters.

      In this example, the agent and master are deployed in the same cluster. Therefore, the agent can use the ClusterIP Service to access the master.

      If an agent needs to access the master from another cluster or through the Internet, select a proper Service type. The IP addresses of Jenkins-web and Jenkins-agent need to be the same. So, ports 8080 and 50000 must be enabled for the IP address connected to jenkins-agent. For IP addresses used only for web access, enable only the port 8080.

    Figure 5 Adding a Service

  7. Retain the default settings for Advanced Settings and click Create Workload.
  8. Go back to the workload list and see the workload status. If the workload is in the Running state, the Jenkins application is accessible.

Logging In and Initializing Jenkins

  1. On the CCE console, click the name of the cluster to access the cluster console. Choose Services & Ingresses in the navigation pane. On the Services tab, view the Jenkins access mode.

    Figure 6 Access mode corresponding to port 8080

  2. Enter EIP:8080 of the load balancer in the address bar of a browser 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 commands below, access 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

  3. Select the default recommended add-on and create an administrator upon the first login as instructed. After the initial configuration is complete, the Jenkins page is displayed.

Changing the Number of Concurrent Build Jobs

  1. 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 change the number of concurrent build jobs on both masters and agents. A master is used as an example.
    • If a master is used with agents, you are advised to set the number of concurrent build jobs of master to 0. This means that all build jobs are performed using agents. If a single master is used, you do not need to change the value to 0.

  2. Change the maximum number of concurrent build jobs. In this example, the value is changed to 2. You can change the value as required.