Kubernetes + Jenkins: how to assign all jenkins slave to one specific node Kubernetes + Jenkins: how to assign all jenkins slave to one specific node kubernetes kubernetes

Kubernetes + Jenkins: how to assign all jenkins slave to one specific node


All you need to do is specify this in the Deployment of your jenkins slave with nodeAffinity, like so:

---apiVersion: apps/v1kind: Deploymentmetadata:  name: jenkins-slave  namespace: ci  labels:    app: jenkins    role: slavespec:  selector:    matchLabels:      app: jenkins      role: slave  template:    metadata:      labels:        app: jenkins        role: slave    spec:      affinity:        nodeAffinity:          requiredDuringSchedulingIgnoredDuringExecution:            nodeSelectorTerms:              - matchExpressions:                  - key: kubernetes.io/hostname                    operator: In                    values:                      - vm-1

You can see some examples here

However, I am not sure if kubernetes.io/hostname is a valid label to be used when selecting node affinity, maybe you will need to create one, such as role, dedicated or type.