Hi team,
       
      We found an issue in the kubernetes plugin. The field nodeSelector in the kubernetes cloud doesn't work as expected. We will try to keep builds isolated in different nodes with a Cluster Autoscaler.
      Piece of yaml:
      ```
            image: jenkins/inbound-agent:4.3-4
            imagePullPolicy: IfNotPresent
            name: jnlp
            resources:
              limits:
                cpu: 200m
                memory: 300Mi
              requests:
                cpu: 100m
                memory: 256Mi
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
            volumeMounts:
            - mountPath: /home/jenkins/agent
              name: workspace-volume
            - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
              name: xxxxxx
              readOnly: true
            - mountPath: /var/run/xxxx
              name: xxxx
              readOnly: true
          dnsPolicy: ClusterFirst
          enableServiceLinks: true
          nodeName: xxxxx
          nodeSelector:
            kubernetes.io/os: linux
          priority: 0
          restartPolicy: Never
          schedulerName: default-scheduler
          securityContext:
            fsGroup: 1000
          serviceAccount: xxxx
          serviceAccountName: xxxx
          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
      ```
       
      As you can see in the attached image we have configured this in our kubernetes cloud (this is our default cloud) inside jenkins configuration, but when we launch a new job, it's not built as expected. We need to configure each yaml from each pipeline with the selector because this option is not worked properly.
       
       
      Versions:
      Jenkins version: 2.263.4
      Kubernetes version: 1.18.9
      Kubernetes plugin version: 1.29.2
       
      Thank you in advance.

          [JENKINS-65031] Kubernetes plugin nodeSelector

          Borja created issue -
          Borja made changes -
          Attachment New: nodeselector.png [ 54135 ]
          Borja made changes -
          Description Original: Hi team,
           
          We found an issue in the kubernetes plugin. The field nodeSelector in the kubernetes cloud doesn't work as expected. We will try to keep builds isolated in different nodes with a Cluster Autoscaler.
          Piece of yaml:
          ```
                image: jenkins/inbound-agent:4.3-4
                imagePullPolicy: IfNotPresent
                name: jnlp
                resources:
                  limits:
                    cpu: 200m
                    memory: 300Mi
                  requests:
                    cpu: 100m
                    memory: 256Mi
                terminationMessagePath: /dev/termination-log
                terminationMessagePolicy: File
                volumeMounts:
                - mountPath: /home/jenkins/agent
                  name: workspace-volume
                - mountPath: /var/run/secrets/[kubernetes.io/serviceaccount|http://kubernetes.io/serviceaccount]
                  name: xxxxxx
                  readOnly: true
                - mountPath: /var/run/xxxx
                  name: xxxx
                  readOnly: true
              dnsPolicy: ClusterFirst
              enableServiceLinks: true
              nodeName: xxxxx
              nodeSelector:
                [kubernetes.io/os|http://kubernetes.io/os]: linux
              priority: 0
              restartPolicy: Never
              schedulerName: default-scheduler
              securityContext:
                fsGroup: 1000
              serviceAccount: xxxx
              serviceAccountName: xxxx
              terminationGracePeriodSeconds: 30
              tolerations:
              - effect: NoExecute
                key: [node.kubernetes.io/not-ready|http://node.kubernetes.io/not-ready]
                operator: Exists
                tolerationSeconds: 300
              - effect: NoExecute
                key: [node.kubernetes.io/unreachable|http://node.kubernetes.io/unreachable]
                operator: Exists
                tolerationSeconds: 300
          ```
           
          As you can see in our kubernetes cloud (this is our default cloud) inside jenkins configuration we have this configured but when we launch a new job, it's not built as expected. We need to configure each yaml from each pipeline with the selector because this option is not worked properly.
           
           
          Versions:
          Jenkins version: 2.263.4
          Kubernetes version: 1.18.9
          Kubernetes plugin version: 1.29.2
           
          Thank you in advance.
          New: Hi team,
            
           We found an issue in the kubernetes plugin. The field nodeSelector in the kubernetes cloud doesn't work as expected. We will try to keep builds isolated in different nodes with a Cluster Autoscaler.
           Piece of yaml:
           ```
                 image: jenkins/inbound-agent:4.3-4
                 imagePullPolicy: IfNotPresent
                 name: jnlp
                 resources:
                   limits:
                     cpu: 200m
                     memory: 300Mi
                   requests:
                     cpu: 100m
                     memory: 256Mi
                 terminationMessagePath: /dev/termination-log
                 terminationMessagePolicy: File
                 volumeMounts:
                 - mountPath: /home/jenkins/agent
                   name: workspace-volume
                 - mountPath: /var/run/secrets/[kubernetes.io/serviceaccount|http://kubernetes.io/serviceaccount]
                   name: xxxxxx
                   readOnly: true
                 - mountPath: /var/run/xxxx
                   name: xxxx
                   readOnly: true
               dnsPolicy: ClusterFirst
               enableServiceLinks: true
               nodeName: xxxxx
               nodeSelector:
                 [kubernetes.io/os|http://kubernetes.io/os]: linux
               priority: 0
               restartPolicy: Never
               schedulerName: default-scheduler
               securityContext:
                 fsGroup: 1000
               serviceAccount: xxxx
               serviceAccountName: xxxx
               terminationGracePeriodSeconds: 30
               tolerations:
               - effect: NoExecute
                 key: [node.kubernetes.io/not-ready|http://node.kubernetes.io/not-ready]
                 operator: Exists
                 tolerationSeconds: 300
               - effect: NoExecute
                 key: [node.kubernetes.io/unreachable|http://node.kubernetes.io/unreachable]
                 operator: Exists
                 tolerationSeconds: 300
           ```
            
           As you can see in the attached image we have configured this in our kubernetes cloud (this is our default cloud) inside jenkins configuration, but when we launch a new job, it's not built as expected. We need to configure each yaml from each pipeline with the selector because this option is not worked properly.
            
            
           Versions:
           Jenkins version: 2.263.4
           Kubernetes version: 1.18.9
           Kubernetes plugin version: 1.29.2
            
           Thank you in advance.

            Unassigned Unassigned
            blopezp Borja
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: