Skip to content

Run Pipelines on Specified Nodes

This article describes how to run the pipeline tasks on the specified nodes in Workbench.

Modify jenkins-casc-config

  1. Go to the Container Management module and enter the details page of the target cluster, such as the kpanda-global-cluster .

    Cluster Details

  2. Click ConfigMaps & Secrets -> ConfigMaps in the left navigation.

    ConfigMaps

  3. Search for jenkins-casc-config , choose Edit YAML in the list.

    Edit YAML

  4. Add nodeSelector: "ci=base" for a specific Agent under jenkins.cloud.kubernetes.templates in jenkins.yaml , and click OK to save the changes.

    Add Selector

Add labels to the specified nodes

  1. Enter the Container Management module, on the kpanda-global-cluster details page, click Nodes on the left navigation.

    Node Management

  2. Select the target worker node (for example, demo-dev-worker8), and click Edit Labels .

    Edit Labels

  3. Add the ci=base label and click OK to save the changes.

    Add Labels

Access Jenkins dashboard and reload configuration

First of all, it is necessary to expose the access address of Jenkins Dashbord through NodePort (other exposure methods are exposed according to the actual business situation).

  1. Enter Container Management module, on the kpanda-global-cluster page, click Container Network -> Services in the left navigation bar.

    Services

  2. Search amamba-jenkins and choose Update from the list.

    Update Jenkins

  3. Change the access type to NodePort , and the node port selection will be automatically generated.

    Change Access Type

  4. Click OK , then return to the details page and click the link to access the Jenkins Dashboard.

    Access Jenkins Dashboard

  5. Enter the account/password (the default is admin/Admin01 ) to enter the Jenkins Dashboard page.

    Login

  6. Choose Manage Jenkins in the left navigation bar.

    Manage Jenkins

  7. Click Configuration as Code .

    Config as code

  8. Click Reload existing configuration in Configuration as Code . If there is no prompt on the current page after clicking, it means that the configuration loading takes effect.

    Reload

Run pipelines and verify nodes

  1. Create a pipeline job in Workbench , and edit Jenkinsfile as follows:

    pipeline {
      agent {
        node {
          label 'base'
        }
    
      }
      stages {
        stage('Hello') {
          agent none
          steps {
            container('base') {
              echo 'Hello World'
              sh 'sleep 300'
            }
    
          }
        }
    
      }
    }
    

    Note

    It should be noted that the agent part needs to select label as base. Because the specified node is only set for the base in the configuration file, if it needs to be set for other agents. Repeat the above operation.

  2. Click Run Now for the pipeline, and go to Container Management to view the running node of the Pod that executes the task.

    Check Pods

  3. You can see that the Pod executing the pipeline task is running on the expected demo-dev-worker8 node.

Comments