Issue
I would like to apply the tolerations on the Jenkins slave pod that are dynamically spinned by the Kubernetes Plugin. I see that the Kubernetes Plugin does not provide any option on the Jenkins UI to add the tolerations, as shown in the image below. Could anyone tell me, how can I add the tolerations in this case to the slave pods(which are generated by kubernetes plugin).
P.S.:- I do not want to use labels,I Strictly want to use tolerations. And I am not sure if I want to add the podTemplate in the Jenkinsfile and specify the tolerations in this podTemplate. Because this will force me to do the same for every job's Jenkinsfile, which is tedious and not possible if multiple developers prepare their own respective pipelines.
Solution
You can actually add taints to the configs in jenkins outright.
https://github.com/jenkinsci/kubernetes-plugin/pull/311#issuecomment-386342776
You can add this into the "raw yaml for the pod" under your container and update your criteria accordingly for the labels.
I have used this myself and it does indeed work.
(here's the yaml from the link above)
apiVersion: v1
kind: Pod
metadata:
labels:
jenkins/kube-default: true
app: jenkins
component: agent
spec:
nodeSelector:
werkint.com/entity: other
tolerations:
- key: werkint.com/entity
operator: Equal
value: other
effect: NoSchedule
Answered By - bek
Answer Checked By - Marilyn (JavaFixing Volunteer)