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

Kubernetes PlugIn is not spawning Pods as expected when using an external Podtemplate file

    Details

    • Similar Issues:

      Description

       

      Our Jenkins Instance (which is running outside of the Cluster) was configured through the UI to dynamically spawn Slaves inside the Cluster, which was working fine.

      Now we wanted configure the PodTemplate as config-as-code in a declarative Pipeline. Using following configuration (as stated in the github description) is working and produces a Pod with 2 Containers (jnlp and maven):

       

       agent {
          kubernetes {
            defaultContainer 'jnlp'
            yaml """
      apiVersion: v1
      kind: Pod
      metadata:
        labels:
          some-label: some-label-value
          namespace: jenkins
      spec:
        containers:
        - name: maven
          image: maven:3.3.9-jdk-8-alpine
          command:
          - cat
          tty: true
      """
          }
        }
      

      But when we wanted to pull out the Pod config in a seperate file as described in the documentation (https://github.com/jenkinsci/kubernetes-plugin#declarative-pipeline) like so (the file contains the exact same content as above):

      agent {    
        kubernetes {
          defaultContainer 'jnlp'
          yamlFile 'KubernetesPod.yaml'
        }
      }
      

      ... it didn't work as expected anymore.

      There were created two seperate Pods, each containing a "jenkins/jnlp-slave:alpine" Container, but no maven container at all, which lead to following error in the build log:

      java.io.IOException: container [maven] does not exist in pod [testpodfromyml-9-r72hx-m491z-pr022]

      Maybe it is important to mention that the Cloud & Podconfiguration in the GUI was still active.

       

       

       

       

       

       

       

        Attachments

          Activity

          alexagrosc alex grosc created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              alexagrosc alex grosc
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: