Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57184

Kubernetes Plugin inversely applies NodeSelector

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • Jenkins version 2.173
      Host OS: CentOS 7
      openjdk version "1.8.0_181"
      Kubernetes Plugin version: 1.15.1
      Kubernetes version: 1.13.2
      Kubernetes nodes: Container Linux by CoreOS 1911.4.0 (Rhyolite)

      Adding a NodeSelector to slaves provisioned with the Kubernetes appears to apply an anti-affinity to that NodeSelector rather than actually using the NodeSelector.

      We share our Kubernetes Cluster with Jenkins and a number of other projects. For our Jenkins slaves, we only want certain fast nodes, so they're labeled with `jenkins-slave=true` and our slow nodes do not have that corresponding label.

       

      When configuring slaves in Jenkins, we applied the NodeSelector with the given label:

       

      With the expectation it would only run on the fast nodes. But instead it only ran on the slow nodes without the label.

      It seems like rather than apply a NodeSelector, it's applying the opposite of the NodeSelector (anti-affinity).

      We can't do too much testing on our production instance of Jenkins, so for now we've just removed the NodeSelector and are letting Jenkins Slaves run everywhere, but this is very frustrating when a slave is scheduled on our slow nodes.

          [JENKINS-57184] Kubernetes Plugin inversely applies NodeSelector

          Carlos Sanchez added a comment - - edited

          I can't reproduce, the pod is created with this yaml which is correct

          apiVersion: v1
          kind: Pod
          metadata:
            creationTimestamp: "2019-04-25T14:42:23Z"
            labels:
              jenkins: slave
              jenkins/node-selector-test: "true"
            name: node-selector-test-59d36
            namespace: jx
          ...
          spec:
          ...
            nodeSelector:
              jenkins-slave: "true"
            priority: 0
            restartPolicy: Never
            schedulerName: default-scheduler
            securityContext: {}
            serviceAccount: default
            serviceAccountName: default
            terminationGracePeriodSeconds: 30
            tolerations:
            - effect: NoExecute
              key: node.kubernetes.io/not-ready
              operator: Exists
              tolerationSeconds: 300
            - effect: NoExecute
              key: node.kubernetes.io/unreachable
              operator: Exists
              tolerationSeconds: 300
          status:
            conditions:
            - lastProbeTime: null
              lastTransitionTime: "2019-04-25T14:42:23Z"
              message: '0/1 nodes are available: 1 node(s) didn''t match node selector.'
              reason: Unschedulable
              status: "False"
              type: PodScheduled
            phase: Pending
            qosClass: BestEffort
          

          Carlos Sanchez added a comment - - edited I can't reproduce, the pod is created with this yaml which is correct apiVersion: v1 kind: Pod metadata: creationTimestamp: "2019-04-25T14:42:23Z" labels: jenkins: slave jenkins/node-selector-test: " true " name: node-selector-test-59d36 namespace: jx ... spec: ... nodeSelector: jenkins-slave: " true " priority: 0 restartPolicy: Never schedulerName: default -scheduler securityContext: {} serviceAccount: default serviceAccountName: default terminationGracePeriodSeconds: 30 tolerations: - effect: NoExecute key: node.kubernetes.io/not-ready operator : Exists tolerationSeconds: 300 - effect: NoExecute key: node.kubernetes.io/unreachable operator : Exists tolerationSeconds: 300 status: conditions: - lastProbeTime: null lastTransitionTime: "2019-04-25T14:42:23Z" message: '0/1 nodes are available: 1 node(s) didn' 't match node selector.' reason: Unschedulable status: "False" type: PodScheduled phase: Pending qosClass: BestEffort

            Unassigned Unassigned
            darrien Darrien Glasser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: