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

Cannot start jenkins agent pod from podTemplate in a separate yaml file

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Running:

      Jenkins 2.289.1
      kubernetes plugin: 1.30.0

      Based on this example:

      https://github.com/jenkinsci/kubernetes-plugin#example

      I have created a podTemplate in a separate file:

      pod.yaml

      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: jnlp
          image: jenkins/inbound-agent:4.9-1-jdk11
          command:
          - cat
        - name: gradle
          image: gradle:7.1.1-jdk11
          ttyEnabled: true
          command:
          - cat
      

       
      Which I use in my Jenkinsfile:

      Jenkinsfile:

      podTemplate(yaml: readTrusted('pod.yaml')) {
        node(POD_LABEL) {
      
              stage('Checkout') {
                  checkout scm
              }
      
              stage('debug....') {
                  container('gradle') {
                      sh 'whoami'
      
                  }              
              }
        }
      }
      
      

       
      But when I run the above pipeline the jenkins agents just hangs - or rather it seems the jnlp container fails with:

      $ kubectl -c jnlp logs -f $(kubectl get pods | grep demo | awk '{print $1}')
      Unable to retrieve container logs for docker://d046ef89fbd062b501c66c9e4e2dc81cc37f1fcfe8d53c7f639469621bd0c4f5
      

      Which does not help much. 

      I have then tried to update the podtemplate to:

      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: jnlp
          image: jenkins/inbound-agent:4.9-1-jdk11
          command:
          - ""
          args: 
          - "^${computer.jnlpmac} ^${computer.name}"
          ttyEnabled: true
        - name: gradle
          image: gradle:7.1.1-jdk11
          ttyEnabled: true
          command:
          - cat
      

      But then I get:

      [Warning].....[Failed] Error: failed to start container "jnlp": Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "^${computer.jnlpmac} ^${computer.name}": executable file not found in $PATH: unknown
      

       
      If instead include the podTemplate in my Jenkinsfile like below:

      podTemplate(label: 'builder',
                  containers: [
                          containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:4.9-1-jdk11', args: '${computer.jnlpmac} ${computer.name}'),                    
                          containerTemplate(name: 'gradle', image: 'gradle:7.1.1-jdk11', ttyEnabled: true, command: 'cat')
                  ]) {
      
              node('builder') {
                  stage('Checkout') {
                      checkout scm
                  }
      
                  stage('debug....') {
                      container('gradle') {
                          sh 'whoami'
                      }              
                  }
              }
          }
      

      it works fine.

       

      Is this a bug or am I missing something?

      A few other things I have tried:

      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: jnlp
          image: jenkins/jnlp-slave:latest
          args: ['$(JENKINS_SECRET)', '$(JENKINS_NAME)']
        - name: gradle
          image: gradle:7.1.1-jdk11
          ttyEnabled: true    
          command: 
          - cat
      

      JNLP container just keeps restating and the only thing in the log:

      Jul 06, 2021 8:24:51 PM hudson.remoting.jnlp.Main$CuiListener status
      INFO: Remote identity confirmed: 30****14
      Jul 06, 2021 8:24:52 PM hudson.remoting.jnlp.Main$CuiListener status
      INFO: Connected
      Jul 06, 2021 8:25:06 PM org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave$SlaveDisconnector call
      INFO: Disabled agent engine reconnects.
      Jul 06, 2021 8:25:06 PM hudson.remoting.jnlp.Main$CuiListener status
      INFO: Terminated
      

      Also tried using:

          image: jenkins/inbound-agent:4.9-1-jdk11
      

      instead but same behavior/error.
       

        Attachments

          Activity

          dev_samples dev.samples created issue -
          dev_samples dev.samples made changes -
          Field Original Value New Value
          Description Running:

          Jenkins 2.289.1
           kubernetes plugin: 1.30.0

          Based on this example:

          [https://github.com/jenkinsci/kubernetes-plugin#example]

          I have created a podTemplate in a separate file:

          *pod.yaml*
          {code:java}
          apiVersion: v1
          kind: Pod
          spec:
            containers:
            - name: jnlp
              image: jenkins/inbound-agent:4.9-1-jdk11
              command:
              - cat
            - name: gradle
              image: gradle:7.1.1-jdk11
              ttyEnabled: true
              command:
              - cat
          {code}
           
           Which I use in my Jenkinsfile:

          *Jenkinsfile:*
          {code:java}
          podTemplate(yaml: readTrusted('pod.yaml')) {
            node(POD_LABEL) {

                  stage('Checkout') {
                      checkout scm
                  }

                  stage('debug....') {
                      container('gradle') {
                          sh 'whoami'

                      }
                  }
            }
          }

          {code}
           
           But when I run the above pipeline the jenkins agents just hangs - or rather it seems the jnlp container fails with:
          {code:java}
          $ kubectl -c jnlp logs -f $(kubectl get pods | grep demo | awk '{print $1}')
          Unable to retrieve container logs for docker://d046ef89fbd062b501c66c9e4e2dc81cc37f1fcfe8d53c7f639469621bd0c4f5
          {code}
          Which does not help much. 

          I have then tried to update the podtemplate to:
          {code:java}
          apiVersion: v1
          kind: Pod
          spec:
            containers:
            - name: jnlp
              image: jenkins/inbound-agent:4.9-1-jdk11
              command:
              - ""
              args:
              - "^${computer.jnlpmac} ^${computer.name}"
              ttyEnabled: true
            - name: gradle
              image: gradle:7.1.1-jdk11
              ttyEnabled: true
              command:
              - cat
          {code}
          But then I get:
          {code:java}
          [Warning].....[Failed] Error: failed to start container "jnlp": Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "^${computer.jnlpmac} ^${computer.name}": executable file not found in $PATH: unknown
          {code}
           
           If instead include the podTemplate in my Jenkinsfile like below:
          {code:java}
          podTemplate(label: 'builder',
                      containers: [
                              containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:4.9-1-jdk11', args: '${computer.jnlpmac} ${computer.name}'),
                              containerTemplate(name: 'gradle', image: 'gradle:7.1.1-jdk11', ttyEnabled: true, command: 'cat')
                      ]) {

                  node('builder') {
                      stage('Checkout') {
                          checkout scm
                      }

                      stage('debug....') {
                          container('gradle') {
                              sh 'whoami'
                          }
                      }
                  }
              }
          {code}
          it works fine.

           

          Is this a bug or am I missing something?
            
          Running:

          Jenkins 2.289.1
           kubernetes plugin: 1.30.0

          Based on this example:

          [https://github.com/jenkinsci/kubernetes-plugin#example]

          I have created a podTemplate in a separate file:

          *pod.yaml*
          {code:java}
          apiVersion: v1
          kind: Pod
          spec:
            containers:
            - name: jnlp
              image: jenkins/inbound-agent:4.9-1-jdk11
              command:
              - cat
            - name: gradle
              image: gradle:7.1.1-jdk11
              ttyEnabled: true
              command:
              - cat
          {code}
           
           Which I use in my Jenkinsfile:

          *Jenkinsfile:*
          {code:java}
          podTemplate(yaml: readTrusted('pod.yaml')) {
            node(POD_LABEL) {

                  stage('Checkout') {
                      checkout scm
                  }

                  stage('debug....') {
                      container('gradle') {
                          sh 'whoami'

                      }
                  }
            }
          }

          {code}
           
           But when I run the above pipeline the jenkins agents just hangs - or rather it seems the jnlp container fails with:
          {code:java}
          $ kubectl -c jnlp logs -f $(kubectl get pods | grep demo | awk '{print $1}')
          Unable to retrieve container logs for docker://d046ef89fbd062b501c66c9e4e2dc81cc37f1fcfe8d53c7f639469621bd0c4f5
          {code}
          Which does not help much. 

          I have then tried to update the podtemplate to:
          {code:java}
          apiVersion: v1
          kind: Pod
          spec:
            containers:
            - name: jnlp
              image: jenkins/inbound-agent:4.9-1-jdk11
              command:
              - ""
              args:
              - "^${computer.jnlpmac} ^${computer.name}"
              ttyEnabled: true
            - name: gradle
              image: gradle:7.1.1-jdk11
              ttyEnabled: true
              command:
              - cat
          {code}
          But then I get:
          {code:java}
          [Warning].....[Failed] Error: failed to start container "jnlp": Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "^${computer.jnlpmac} ^${computer.name}": executable file not found in $PATH: unknown
          {code}
           
           If instead include the podTemplate in my Jenkinsfile like below:
          {code:java}
          podTemplate(label: 'builder',
                      containers: [
                              containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:4.9-1-jdk11', args: '${computer.jnlpmac} ${computer.name}'),
                              containerTemplate(name: 'gradle', image: 'gradle:7.1.1-jdk11', ttyEnabled: true, command: 'cat')
                      ]) {

                  node('builder') {
                      stage('Checkout') {
                          checkout scm
                      }

                      stage('debug....') {
                          container('gradle') {
                              sh 'whoami'
                          }
                      }
                  }
              }
          {code}
          it works fine.

           

          Is this a bug or am I missing something?

          A few other things I have tried:

          {code:java}
          apiVersion: v1
          kind: Pod
          spec:
            containers:
            - name: jnlp
              image: jenkins/jnlp-slave:latest
              args: ['$(JENKINS_SECRET)', '$(JENKINS_NAME)']
            - name: gradle
              image: gradle:7.1.1-jdk11
              ttyEnabled: true
              command:
              - cat
          {code}

          JNLP container just keeps restating and the only thing in the log:

          {code:java}
          Jul 06, 2021 8:24:51 PM hudson.remoting.jnlp.Main$CuiListener status
          INFO: Remote identity confirmed: 30****14
          Jul 06, 2021 8:24:52 PM hudson.remoting.jnlp.Main$CuiListener status
          INFO: Connected
          Jul 06, 2021 8:25:06 PM org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave$SlaveDisconnector call
          INFO: Disabled agent engine reconnects.
          Jul 06, 2021 8:25:06 PM hudson.remoting.jnlp.Main$CuiListener status
          INFO: Terminated
          {code}


          Also tried using:

          {code:java}
              image: jenkins/inbound-agent:4.9-1-jdk11
          {code}

          instead but same behavior/error.
            

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dev_samples dev.samples
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: