run the pipeline on the specified node¶
This article describes how to run the customer's pipeline tasks on the specified nodes in Workbench.
Modify the configuration file jenkins-casc-config¶
-
Go to the
Container Management
module and enter the details page of the target cluster, such as thekpanda-global-cluster
cluster. -
Click
Configuration and Keys
->Configuration Items
in the left navigation. -
Search
jenkins-casc-config
, selectEdit YAML
from the list. -
Add
nodeSelector: "ci=base"
for a specific Agent underjenkins.cloud.kubernetes.templates
in the YAML configuration itemjenkins.yaml
, and clickOK
to save the changes.
Select the specified node to add a label¶
-
Enter the
Container Management
module, on thekpanda-global-cluster
cluster details page, clickNode Management
on the left navigation. -
Select the target worker node (for example, demo-dev-worker-03), and click
Modify Label
. -
Add the
ci=base
tag and clickOK
to save the changes.
Visit Jenkins Dashbord, 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 thekpanda-global-cluster
cluster page, clickContainer Network
->Service
in the left navigation bar. -
Search
amamba-jenkins
and selectUpdate
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. -
Select
Manage Jenkins
in the left navigation bar. -
Click
Configuration as Code
. -
Click
Reload existing configuration
inConfiguration as Code
. If there is no prompt on the current page after clicking, it means that the configuration loading takes effect.
Run the pipeline and check if it is on the specified node¶
-
Create a pipeline job in
Workbench
, and editJenkinsfile
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
Execute Now
for the pipeline, and go toContainer 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-worker-03
node.