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

Cannot define a different default jnlp container

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      It seems I cannot define a default jnlp container to be used for all the pods and the plugin defaults always to "jenkins/inbound-agent:4.3-4".

      I specified a custom image in the kubernetes configure clouds page, but the template has always no container and not even the custom ENV var that I specify.

      The workaround I found, is to specify the jnlp in the yaml variable, but i'd prefer to have a global one.

      Here the code:

       node("worker") {
          String yaml = """
      kind: Pod
      apiVersion: v1
      spec:
        containers:
          - name: bash
            image: registry.example.com/registry/shell:bash5.0-alpine3.12
            imagePullPolicy: Always
            command: ["cat"]
            tty: true
          """  podTemplate(yaml: yaml) {
          node(POD_LABEL) {
              stage("Build for packaging") {
                container('bash') {
                  sh label: "Build for packaging", script: """
      set -e
      echo "Test"
      """
                }
              }
          }
        }
      }
      

      Here the logs:

      Jun 17, 2021 6:13:07 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
      Parsed pod template from yaml: ---
      apiVersion: "v1"
      kind: "Pod"
      spec:
        containers:
        - command:
          - "cat"
          image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
          imagePullPolicy: "Always"
          name: "bash"
          tty: trueJun 17, 2021 6:13:13 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
      In provisioning : []
      Jun 17, 2021 6:13:13 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
      Label "TestC_10-c7j6c" excess workload: 1, executors: 0
      Jun 17, 2021 6:13:13 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
      Template for label "TestC_10-c7j6c": TestC_10-c7j6c-rg2vb
      Jun 17, 2021 6:13:13 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesProvisioningLimits
      kubernetes global limit: 1/10
      Jun 17, 2021 6:13:13 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesProvisioningLimits
      TestC_10-c7j6c-rg2vb template limit: 1/2147483647
      Jun 17, 2021 6:13:13 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
      Planned 1 Kubernetes agents with template "TestC_10-c7j6c-rg2vb"
      Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
      Building connection to Kubernetes kubernetes URL https://kubernetes.default namespace jenkins
      Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesFactoryAdapter
      Creating Kubernetes client: KubernetesFactoryAdapter [serviceAddress=https://kubernetes.default, namespace=jenkins, caCertData=null, credentials=null, skipTlsVerify=false, connectTimeout=5, readTimeout=15]
      Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesFactoryAdapter
      Proxy Settings for Cloud: false
      Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesClientProvider
      Created new Kubernetes client: kubernetes io.fabric8.kubernetes.client.DefaultKubernetesClient@65831bf
      Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
      Connected to Kubernetes kubernetes URL https://kubernetes.default/ namespace jenkins
      Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
      Parsed pod template from yaml: ---
      apiVersion: "v1"
      kind: "Pod"
      spec:
        containers:
        - command:
          - "cat"
          image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
          imagePullPolicy: "Always"
          name: "bash"
          tty: trueJun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
      Combining pods, parent: ---
      apiVersion: "v1"
      kind: "Pod"
      metadata: {}
      spec:
        containers:
        - command:
          - "cat"
          image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
          imagePullPolicy: "Always"
          name: "bash"
          tty: true
       template: ---
      apiVersion: "v1"
      kind: "Pod"
      metadata:
        annotations:
          buildUrl: "http://jenkins.jenkins.svc.cluster.local:8080/job/TestC/10/"
          runUrl: "job/TestC/10/"
        labels:
          jenkins/jenkins-jenkins-agent: "true"
          jenkins/label-digest: "5eee0bc5e5793f888965251dee9e803c7e074684"
          jenkins/label: "TestC_10-c7j6c"
        name: "testc-10-c7j6c-rg2vb-jllp6"
      spec:
        containers: []
        volumes:
        - emptyDir:
            medium: ""
          name: "workspace-volume"Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
      Pods combined: ---
      apiVersion: "v1"
      kind: "Pod"
      metadata:
        annotations:
          buildUrl: "http://jenkins.jenkins.svc.cluster.local:8080/job/TestC/10/"
          runUrl: "job/TestC/10/"
        labels:
          jenkins/jenkins-jenkins-agent: "true"
          jenkins/label-digest: "5eee0bc5e5793f888965251dee9e803c7e074684"
          jenkins/label: "TestC_10-c7j6c"
        name: "testc-10-c7j6c-rg2vb-jllp6"
      spec:
        containers:
        - command:
          - "cat"
          image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
          imagePullPolicy: "Always"
          name: "bash"
          tty: true
        nodeSelector: {}
        volumes:
        - emptyDir:
            medium: ""
          name: "workspace-volume"Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder
      Pod built: ---
      apiVersion: "v1"
      kind: "Pod"
      metadata:
        annotations:
          buildUrl: "http://jenkins.jenkins.svc.cluster.local:8080/job/TestC/10/"
          runUrl: "job/TestC/10/"
        labels:
          jenkins/jenkins-jenkins-agent: "true"
          jenkins/label-digest: "5eee0bc5e5793f888965251dee9e803c7e074684"
          jenkins/label: "TestC_10-c7j6c"
        name: "testc-10-c7j6c-rg2vb-jllp6"
      spec:
        containers:
        - command:
          - "cat"
          image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
          imagePullPolicy: "Always"
          name: "bash"
          tty: true
          volumeMounts:
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
        - env:
          - name: "JENKINS_SECRET"
            value: "b1ac3255b8ae76de67e1723b23c9ac68d81cb6ed388cc4ea13d5c17ccc08bf33"
          - name: "JENKINS_TUNNEL"
            value: "jenkins-agent.jenkins.svc.cluster.local:50000"
          - name: "JENKINS_AGENT_NAME"
            value: "testc-10-c7j6c-rg2vb-jllp6"
          - name: "JENKINS_NAME"
            value: "testc-10-c7j6c-rg2vb-jllp6"
          - name: "JENKINS_AGENT_WORKDIR"
            value: "/home/jenkins/agent"
          - name: "JENKINS_URL"
            value: "http://jenkins.jenkins.svc.cluster.local:8080/"
          image: "jenkins/inbound-agent:4.3-4"
          name: "jnlp"
          resources:
            limits: {}
            requests:
              memory: "256Mi"
              cpu: "100m"
          volumeMounts:
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
        nodeSelector:
          kubernetes.io/os: "linux"
        restartPolicy: "Never"
        volumes:
        - emptyDir:
            medium: ""
          name: "workspace-volume" 

        Attachments

          Activity

          krufab Fabio created issue -
          krufab Fabio made changes -
          Field Original Value New Value
          Description It seems I cannot define a different default jnlp container to be used for all the pods.

          Even if I specify a custom image in the configure clouds -> kubernetes -> pod template -> containers -> containers template

          name = jnlp

          docker image = private.example.com/registry/custom-jnlp:123
          It seems I cannot define a default jnlp container to be used for all the pods and the plugin defaults always to "jenkins/inbound-agent:4.3-4".

          I specified a custom image in the kubernetes configure clouds page, but the template has always no container and not even the custom ENV var that I specify.

          The workaround I found, is to specify the jnlp in the yaml variable, but i'd prefer to have a global one.

          Here the code:
          {code:java}
           node("worker") {
              String yaml = """
          kind: Pod
          apiVersion: v1
          spec:
            containers:
              - name: bash
                image: registry.example.com/registry/shell:bash5.0-alpine3.12
                imagePullPolicy: Always
                command: ["cat"]
                tty: true
              """ podTemplate(yaml: yaml) {
              node(POD_LABEL) {
                  stage("Build for packaging") {
                    container('bash') {
                      sh label: "Build for packaging", script: """
          set -e
          echo "Test"
          """
                    }
                  }
              }
            }
          }
          {code}
          Here the logs:
          {code:java}
          Jun 17, 2021 6:13:07 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
          Parsed pod template from yaml: ---
          apiVersion: "v1"
          kind: "Pod"
          spec:
            containers:
            - command:
              - "cat"
              image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
              imagePullPolicy: "Always"
              name: "bash"
              tty: trueJun 17, 2021 6:13:13 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
          In provisioning : []
          Jun 17, 2021 6:13:13 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
          Label "TestC_10-c7j6c" excess workload: 1, executors: 0
          Jun 17, 2021 6:13:13 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
          Template for label "TestC_10-c7j6c": TestC_10-c7j6c-rg2vb
          Jun 17, 2021 6:13:13 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesProvisioningLimits
          kubernetes global limit: 1/10
          Jun 17, 2021 6:13:13 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesProvisioningLimits
          TestC_10-c7j6c-rg2vb template limit: 1/2147483647
          Jun 17, 2021 6:13:13 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
          Planned 1 Kubernetes agents with template "TestC_10-c7j6c-rg2vb"
          Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
          Building connection to Kubernetes kubernetes URL https://kubernetes.default namespace jenkins
          Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesFactoryAdapter
          Creating Kubernetes client: KubernetesFactoryAdapter [serviceAddress=https://kubernetes.default, namespace=jenkins, caCertData=null, credentials=null, skipTlsVerify=false, connectTimeout=5, readTimeout=15]
          Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesFactoryAdapter
          Proxy Settings for Cloud: false
          Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesClientProvider
          Created new Kubernetes client: kubernetes io.fabric8.kubernetes.client.DefaultKubernetesClient@65831bf
          Jun 17, 2021 6:13:14 PM FINE org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud
          Connected to Kubernetes kubernetes URL https://kubernetes.default/ namespace jenkins
          Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
          Parsed pod template from yaml: ---
          apiVersion: "v1"
          kind: "Pod"
          spec:
            containers:
            - command:
              - "cat"
              image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
              imagePullPolicy: "Always"
              name: "bash"
              tty: trueJun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
          Combining pods, parent: ---
          apiVersion: "v1"
          kind: "Pod"
          metadata: {}
          spec:
            containers:
            - command:
              - "cat"
              image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
              imagePullPolicy: "Always"
              name: "bash"
              tty: true
           template: ---
          apiVersion: "v1"
          kind: "Pod"
          metadata:
            annotations:
              buildUrl: "http://jenkins.jenkins.svc.cluster.local:8080/job/TestC/10/"
              runUrl: "job/TestC/10/"
            labels:
              jenkins/jenkins-jenkins-agent: "true"
              jenkins/label-digest: "5eee0bc5e5793f888965251dee9e803c7e074684"
              jenkins/label: "TestC_10-c7j6c"
            name: "testc-10-c7j6c-rg2vb-jllp6"
          spec:
            containers: []
            volumes:
            - emptyDir:
                medium: ""
              name: "workspace-volume"Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils
          Pods combined: ---
          apiVersion: "v1"
          kind: "Pod"
          metadata:
            annotations:
              buildUrl: "http://jenkins.jenkins.svc.cluster.local:8080/job/TestC/10/"
              runUrl: "job/TestC/10/"
            labels:
              jenkins/jenkins-jenkins-agent: "true"
              jenkins/label-digest: "5eee0bc5e5793f888965251dee9e803c7e074684"
              jenkins/label: "TestC_10-c7j6c"
            name: "testc-10-c7j6c-rg2vb-jllp6"
          spec:
            containers:
            - command:
              - "cat"
              image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
              imagePullPolicy: "Always"
              name: "bash"
              tty: true
            nodeSelector: {}
            volumes:
            - emptyDir:
                medium: ""
              name: "workspace-volume"Jun 17, 2021 6:13:14 PM FINEST org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder
          Pod built: ---
          apiVersion: "v1"
          kind: "Pod"
          metadata:
            annotations:
              buildUrl: "http://jenkins.jenkins.svc.cluster.local:8080/job/TestC/10/"
              runUrl: "job/TestC/10/"
            labels:
              jenkins/jenkins-jenkins-agent: "true"
              jenkins/label-digest: "5eee0bc5e5793f888965251dee9e803c7e074684"
              jenkins/label: "TestC_10-c7j6c"
            name: "testc-10-c7j6c-rg2vb-jllp6"
          spec:
            containers:
            - command:
              - "cat"
              image: "registry.example.com/registry/shell:bash5.0-alpine3.12"
              imagePullPolicy: "Always"
              name: "bash"
              tty: true
              volumeMounts:
              - mountPath: "/home/jenkins/agent"
                name: "workspace-volume"
                readOnly: false
            - env:
              - name: "JENKINS_SECRET"
                value: "b1ac3255b8ae76de67e1723b23c9ac68d81cb6ed388cc4ea13d5c17ccc08bf33"
              - name: "JENKINS_TUNNEL"
                value: "jenkins-agent.jenkins.svc.cluster.local:50000"
              - name: "JENKINS_AGENT_NAME"
                value: "testc-10-c7j6c-rg2vb-jllp6"
              - name: "JENKINS_NAME"
                value: "testc-10-c7j6c-rg2vb-jllp6"
              - name: "JENKINS_AGENT_WORKDIR"
                value: "/home/jenkins/agent"
              - name: "JENKINS_URL"
                value: "http://jenkins.jenkins.svc.cluster.local:8080/"
              image: "jenkins/inbound-agent:4.3-4"
              name: "jnlp"
              resources:
                limits: {}
                requests:
                  memory: "256Mi"
                  cpu: "100m"
              volumeMounts:
              - mountPath: "/home/jenkins/agent"
                name: "workspace-volume"
                readOnly: false
            nodeSelector:
              kubernetes.io/os: "linux"
            restartPolicy: "Never"
            volumes:
            - emptyDir:
                medium: ""
              name: "workspace-volume" {code}
          Hide
          krufab Fabio added a comment - - edited

          Solved. The way (maybe not super clear in the documentation) is to set a default provider template name (Configure clouds page -> Kubernetes -> Click on Kubernetes Cloud details ... -> Click on Advanced -> Default Provider Template Name).

          And also use the same name in the Pod Template -> name field.

          Then set the desired jnlp container template image.

          Check this log snippet, where the template uses the custom "registry.example.com/registry/custom-jnlp:123" image.

          template: ---
          apiVersion: "v1"
          kind: "Pod"
          metadata:
            annotations:
              buildUrl: "http://jenkins.jenkins.svc.cluster.local:8080/job/TestC/12/"
              runUrl: "job/TestC/12/"
            labels:
              jenkins/jenkins-jenkins-agent: "true"
              jenkins/label-digest: "cbfd5513968684e176326b0809a013ee10a90ad6"
              jenkins/label: "TestC_12-s2336"
            name: "testc-12-s2336-91rw7-v5197"
          spec:
            containers:
            - args:
              - "46b07c677ce57fb92e9068c82125a076dc6e4b748003bf429feef75b1aefaa17"
              - "testc-12-s2336-91rw7-v5197"
              command:
              - "cat"
              env:
              - name: "JENKINS_SECRET"
                value: "46b07c677ce57fb92e9068c82125a076dc6e4b748003bf429feef75b1aefaa17"
              - name: "JENKINS_TUNNEL"
                value: "jenkins-agent.jenkins.svc.cluster.local:50000"
              - name: "JENKINS_AGENT_NAME"
                value: "testc-12-s2336-91rw7-v5197"
              - name: "TZ"
                value: "Europe/Luxembourg"
              - name: "JENKINS_NAME"
                value: "testc-12-s2336-91rw7-v5197"
              - name: "JENKINS_AGENT_WORKDIR"
                value: "/home/jenkins"
              - name: "JENKINS_URL"
                value: "http://jenkins.jenkins.svc.cluster.local:8080/"
              image: "registry.example.com/registry/custom-jnlp:123"
              imagePullPolicy: "Always"
              name: "jnlp"
              resources:
                limits:
                  memory: "512Mi"
                  cpu: "512m"
                requests:
                  memory: "512Mi"
                  cpu: "512m"
              securityContext:
                privileged: false
                runAsGroup: 1000
                runAsUser: 1000
              tty: false
              volumeMounts:
              - mountPath: "/home/jenkins"
                name: "workspace-volume"
                readOnly: false
              workingDir: "/home/jenkins"
            hostNetwork: false
            nodeSelector:
              kubernetes.io/os: "linux"
            serviceAccountName: "default"
            volumes:
            - emptyDir:
                medium: ""
              name: "workspace-volume" 
          Show
          krufab Fabio added a comment - - edited Solved. The way (maybe not super clear in the documentation) is to set a default provider template name (Configure clouds page -> Kubernetes -> Click on Kubernetes Cloud details ... -> Click on Advanced -> Default Provider Template Name). And also use the same name in the Pod Template -> name field . Then set the desired jnlp container template image. Check this log snippet, where the template uses the custom "registry.example.com/registry/custom-jnlp:123" image. template: --- apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "http: //jenkins.jenkins.svc.cluster.local:8080/job/TestC/12/" runUrl: "job/TestC/12/" labels: jenkins/jenkins-jenkins-agent: " true " jenkins/label-digest: "cbfd5513968684e176326b0809a013ee10a90ad6" jenkins/label: "TestC_12-s2336" name: "testc-12-s2336-91rw7-v5197" spec: containers: - args: - "46b07c677ce57fb92e9068c82125a076dc6e4b748003bf429feef75b1aefaa17" - "testc-12-s2336-91rw7-v5197" command: - "cat" env: - name: "JENKINS_SECRET" value: "46b07c677ce57fb92e9068c82125a076dc6e4b748003bf429feef75b1aefaa17" - name: "JENKINS_TUNNEL" value: "jenkins-agent.jenkins.svc.cluster.local:50000" - name: "JENKINS_AGENT_NAME" value: "testc-12-s2336-91rw7-v5197" - name: "TZ" value: "Europe/Luxembourg" - name: "JENKINS_NAME" value: "testc-12-s2336-91rw7-v5197" - name: "JENKINS_AGENT_WORKDIR" value: "/home/jenkins" - name: "JENKINS_URL" value: "http: //jenkins.jenkins.svc.cluster.local:8080/" image: "registry.example.com/registry/custom-jnlp:123" imagePullPolicy: "Always" name: "jnlp" resources: limits: memory: "512Mi" cpu: "512m" requests: memory: "512Mi" cpu: "512m" securityContext: privileged: false runAsGroup: 1000 runAsUser: 1000 tty: false volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" hostNetwork: false nodeSelector: kubernetes.io/os: "linux" serviceAccountName: " default " volumes: - emptyDir: medium: "" name: "workspace-volume"
          Hide
          nurhun Nurhun added a comment - - edited

          I also can't override jnlp podTemplate & container - Jenkins declarative pipeline

          I'm using jenkins on kubernetes cluster, installed with helm chart as below, 

          helm install my-jenkins jenkinsci/jenkins -n jenkins \
          --set controller.serviceType=LoadBalancer \
          --set controller.servicePort=8888 \
          --set persistence.existingClaim=jenkins-pvc \
          --set persistence.accessMode=ReadWriteMany
          

           

          Also tried --set agent.enabled=false but also graps the default jnlp image

          And tried to override the jnlp agent by below pipeline, but it skip my definition and pull the default jenkins/inbound-agent:4.3-4 image.

           

          My pipeline:

          pipeline {
            
              agent {
                  kubernetes {
                      cloud 'kubernetes'
                      label 'jnlp'
                      defaultContainer 'jnlp'
                      yaml """
                          apiVersion: v1
                          kind: Pod
                          metadata:
                          labels:
                              label: agent
                              jenkins: slave
                          name: jnlp
                          spec:
                          containers:
                          - name: jnlp
                            image: nurhun/my_custom_jenkins_inboud_agent:v1.0
                            args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
                            env:
                            - name: CONTAINER_ENV_VAR
                              value: jnlp
                            - name: JENKINS_AGENT_WORKDIR
                              value: /home/jenkins/agent
                            - name: JENKINS_URL
                              value: http://my-jenkins.jenkins.svc.cluster.local:8888/
                            - name: "JENKINS_TUNNEL"
                              value: "my-jenkins-agent.jenkins.svc.cluster.local:50000"
                            volumeMounts:
                            - mountPath: "/home/jenkins/agent"
                              name: "workspace-volume"
                              readOnly: false
                            - name: jenkins-docker-cfg
                              mountPath: /var/run/docker.sock
                          volumes:
                          - name: jenkins-docker-cfg
                            hostPath:
                              path: /var/run/docker.sock
                          - emptyDir:
                              medium: ""
                              name: "workspace-volume"
                      """
                  }
              }
          
                
              stages {
          
                  stage('Build') {
                      agent {
                          kubernetes {
                              label 'jnlp'
                              defaultContainer 'jnlp'
                          }
                      }
          
                      steps {
                          sh "docker build . -t custom_image:${IMAGE_TAG}"
                      }
                  }
               }
          }
          

           

          I also tried to set the Defaults Provider Template Name as below, but still doesn't work.

          Any ideas ?

          Show
          nurhun Nurhun added a comment - - edited I also can't override jnlp podTemplate & container - Jenkins declarative pipeline I'm using jenkins on kubernetes cluster, installed with helm chart as below,  helm install my-jenkins jenkinsci/jenkins -n jenkins \ --set controller.serviceType=LoadBalancer \ --set controller.servicePort=8888 \ --set persistence.existingClaim=jenkins-pvc \ --set persistence.accessMode=ReadWriteMany   Also tried --set agent.enabled=false but also graps the default jnlp image And tried to override the jnlp agent by below pipeline, but it skip my definition and pull the default  jenkins/inbound-agent:4.3-4  image.   My pipeline: pipeline { agent { kubernetes { cloud 'kubernetes' label 'jnlp' defaultContainer 'jnlp' yaml """ apiVersion: v1 kind: Pod metadata: labels: label: agent jenkins: slave name: jnlp spec: containers: - name: jnlp image: nurhun/my_custom_jenkins_inboud_agent:v1.0 args: [ '\$(JENKINS_SECRET)' , '\$(JENKINS_NAME)' ] env: - name: CONTAINER_ENV_VAR value: jnlp - name: JENKINS_AGENT_WORKDIR value: /home/jenkins/agent - name: JENKINS_URL value: http: //my-jenkins.jenkins.svc.cluster.local:8888/ - name: "JENKINS_TUNNEL" value: "my-jenkins-agent.jenkins.svc.cluster.local:50000" volumeMounts: - mountPath: "/home/jenkins/agent" name: "workspace-volume" readOnly: false - name: jenkins-docker-cfg mountPath: / var /run/docker.sock volumes: - name: jenkins-docker-cfg hostPath: path: / var /run/docker.sock - emptyDir: medium: "" name: "workspace-volume" """ } } stages { stage( 'Build' ) { agent { kubernetes { label 'jnlp' defaultContainer 'jnlp' } } steps { sh "docker build . -t custom_image:${IMAGE_TAG}" } } } }   I also tried to set the  Defaults Provider Template Name  as below, but still doesn't work. Any ideas ?
          Hide
          imvincent Vincent added a comment -

          Fabio is right. It's works for me, the follow is my pipeline configuration.

          pipeline {
            agent {
              kubernetes {
                defaultContainer 'jnlp'
                yaml '''
                  apiVersion: v1
                  kind: Pod
                  metadata:
                    labels:
                      app: myapp
                  spec:
                    containers:
                    - name: jnlp
                      image: mydomain.com/group/custom-inbound-agent:4.9-1-alpine
                      args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
                    ...
          Show
          imvincent Vincent added a comment - Fabio is right. It's works for me, the follow is my pipeline configuration. pipeline { agent { kubernetes { defaultContainer 'jnlp' yaml ''' apiVersion: v1 kind: Pod metadata: labels: app: myapp spec: containers: - name: jnlp image: mydomain.com/group/custom-inbound-agent:4.9-1-alpine args: [ '\$(JENKINS_SECRET)' , '\$(JENKINS_NAME)' ] ...

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            krufab Fabio
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: