This topic describes how to deploy Jenkins, a continuous integration environment, in a serverless Kubernetes cluster, and provides step-by-step examples on how to build an application delivery pipeline that includes source code compilation, image build and push, and application deployment.


You have created a serverless Kubernetes cluster. For more information, see Create a serverless Kubernetes cluster.

Deploy Jenkins

  1. Run the following command to download the Jenkins package.
    $ git clone
    $ cd jenkins-on-serverless
  2. Mount a persistent volume to the jenkins_home directory.
    Currently, serverless Kubernetes clusters do not support cloud disks. You can mount an NFS volume to the jenkins_home directory. You need to modify the serverless-k8s-jenkins-deploy.yaml file to add the following fields and set NFS parameters:
            #  - mountPath: /var/jenkins_home
            #    name: jenkins-home
          #  - name: jenkins-home
          #    nfs:
          #      path: /
          #      server:
  3. Run the following command to deploy Jenkins:
    $ kubectl apply -f serverless-k8s-jenkins-deploy.yaml
  4. Log on to Jenkins.
    1. Log on to the .
    2. In the left-side navigation pane, choose Ingresses and Load Balancing > Services.
    3. Select Jenkins and click its external endpoint to log on.
      Jenkins service
    4. On the Jenkins logon page, enter the username and password. The default username and password are both admin. We recommend that you change the username and password after logon.
      Jenkins login

Create a cluster certificate and an image repository certificate, and build and deploy an application

  1. Set Kubernetes Cloud parameters to dynamically create a slave pod.
    1. In the left-side navigation pane, click Manage Jenkins.
    2. On the right-side Manage Jenkins page, click Configure System.
    3. In the Cloud section, enter the API server URL in KubeConfig as the Kubernetes URL.
      Kubernetes URL
    4. Click Add on the right of Credentials.
      Before you add a credential, find KubeConfig in the Configure the cluster credentials section on Basic Information page of the target cluster.KubeConfig
      In the Add Credentials dialog box that appears, set the following parameters:
      • Kind: Select Docker Host Certificate Authentication.
      • Client Key: Paste the value of client-key-data from KubeConfig.
      • Client Certificate: Paste the value of client-certificate-data from KubeConfig.
      • ID: Enter the certificate ID. In this example, k8sCertAuth is entered.
      • Description: Enter the description.
    5. Click Add.
    6. Test the connectivity.
      In the Credentials drop-down list, select the newly added credential in the preceding step and click Test Connection.Test Connection
    7. Enter the external endpoint of the Jenkins service as Jenkins URL, and enter the external endpoint of the jenkins-agent service as Jenkins tunnel.
      Jenkins URL
    8. Click Save.
  2. To set image repository permissions, use kubectl to create a jenkins-docker-cfg secret in the target cluster.
    In this example, an image repository provided by Alibaba Cloud in the China (Beijing) region is used.
    $ docker login -u xxx -p xxx
    Login Succeeded
    $ kubectl create secret generic jenkins-docker-cfg  --from-file=/root/.docker/config.json
  3. Build demo-pipeline and access the application.
    1. On the Jenkins home page, click demo-pipeline.
    2. In the left-side navigation pane, click Build with Parameters.
    3. Modify the parameters according to your image repository information. Enter the API server URL in KubeConfig as api_server_url. In this example, the source code repository branch is serverless, and the image is
    4. Click Build.
    5. Click Build History to check the result. The following figure indicates that the build was successful.
      Build History
    6. Log on to the to view the IP addresses of the services provided by the application.

Source code repository

The source code used in this topic can be found code repository.