Run Pipelines on Specified Nodes¶
This article describes how to run the pipeline tasks on the specified nodes in Workbench.
Modify jenkins-casc-config¶
-
Go to the Container Management module and enter the details page of the target cluster, such as the kpanda-global-cluster .
-
Click ConfigMaps & Secrets -> ConfigMaps in the left navigation.
-
Search for jenkins-casc-config , choose Edit YAML in the list.
-
Add nodeSelector: "ci=base" for a specific Agent under jenkins.cloud.kubernetes.templates in jenkins.yaml , and click OK to save the changes.
Add labels to the specified nodes¶
-
Enter the Container Management module, on the kpanda-global-cluster details page, click Nodes on the left navigation.
-
Select the target worker node (for example, demo-dev-worker8), and click Edit Labels .
-
Add the ci=base label and click OK to save the changes.
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).
-
Enter Container Management module, on the kpanda-global-cluster page, click Container Network -> Services in the left navigation bar.
-
Search amamba-jenkins and choose Update from the list.
-
Change the access type to NodePort , and the node port selection will be automatically generated.
-
Click OK , then return to the details page and click the link to access the Jenkins Dashboard.
-
Enter the account/password (the default is admin/Admin01 ) to enter the Jenkins Dashboard page.
-
Choose Manage Jenkins in the left navigation bar.
-
Click Configuration as Code .
-
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.
Run pipelines and verify nodes¶
-
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.
-
Click Run Now for the pipeline, and go to Container Management to view the running node of the Pod that executes the task.
-
You can see that the Pod executing the pipeline task is running on the expected demo-dev-worker8 node.