Nesting Pod templates with yaml definition

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Minor
    • Component/s: kubernetes-plugin
    • None

      Based on this test I've tried to create nested pods where both pods are defined by yaml. It seems like this does not work, as only two containers are started. All other combinations seem to work.

      podtemplate + podtemplate → ok

      podTemplate(label: 'mypod', containers: [
      		containerTemplate(name: 'golang', image: 'golang:1.6.3-alpine', ttyEnabled: true, command: '/bin/cat'),
      	]) {
      	podTemplate(label: 'mypodNested', containers: [
      		containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: '/bin/cat'),
      	]) {
      		node ('mypodNested') {
      			stage('Nested') {
      				container('maven') {
      					sh "mvn -version"
      				}
      			}
      			stage('Parent') {
      				container('golang') {
      					sh "go version"
      				}
      			}
      		}
      	}
      }
      

      jenkins-slave-jds40-9nn3m 0/3

      yaml+ podtemplate → ok

      podTemplate(label: 'mypod',  yaml: """
      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: golang
          image: golang:1.6.3-alpine
          command:
          - /bin/cat
          tty: true
      """) {
      	podTemplate(label: 'mypodNested', containers: [
      		containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: '/bin/cat'),
      	]) {
      		node ('mypodNested') {
      			stage('Nested') {
      				container('maven') {
      					sh "mvn -version"
      				}
      			}
      			stage('Parent') {
      				container('golang') {
      					sh "go version"
      				}
      			}
      		}
      	}
      }
      

      jenkins-slave-z5wq3-nt697 0/3

      podtemplate + yaml → ok

      podTemplate(label: 'mypod', containers: [
      		containerTemplate(name: 'golang', image: 'golang:1.6.3-alpine', ttyEnabled: true, command: '/bin/cat'),
      	]) {
      	podTemplate(label: 'mypodNested', yaml: """
      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: maven
          image: maven:3.3.9-jdk-8-alpine
          command:
          - /bin/cat
          tty: true
      """
      	) {
      		node ('mypodNested') {
      			stage('Nested') {
      				container('maven') {
      					sh "mvn -version"
      				}
      			}
      			stage('Parent') {
      				container('golang') {
      					sh "go version"
      				}
      			}
      		}
      	}
      }
      

      jenkins-slave-97ddl-c9sp4 0/3

      yaml+ yaml → nok

      podTemplate(label: 'mypod',  yaml: """
      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: golang
          image: golang:1.6.3-alpine
          command:
          - /bin/cat
          tty: true
      """) {
      	podTemplate(label: 'mypodNested', yaml: """
      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: maven
          image: maven:3.3.9-jdk-8-alpine
          command:
          - /bin/cat
          tty: true
      """
      	) {
      		node ('mypodNested') {
      			stage('Nested') {
      				container('maven') {
      					sh "mvn -version"
      				}
      			}
      			stage('Parent') {
      				container('golang') {
      					sh "go version"
      				}
      			}
      		}
      	}
      }
      

      jenkins-slave-9qm48-k758m 0/2

            Assignee:
            Carlos Sanchez
            Reporter:
            Bene
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: