-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major
-
Component/s: kubernetes-plugin
Hi
I would like my Pods to be created in the namespace of my choice, and I would like to use several namespaces at the same time (depending on the job).
With this Jenkinsfile, it works as expected :
podTemplate( Â Â Â namespace: 'ci-space-test', label: 'mypod', Â Â Â containers: [ Â Â Â Â Â containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:3.10-1-alpine', args: '${computer.jnlpmac} ${computer.name}') Â Â Â ]) { Â Â Â node ('mypod') { Â Â Â Â Â Â Â container(name: 'jnlp') { Â Â Â Â Â Â Â Â Â Â Â sh "cat /var/run/secrets/kubernetes.io/serviceaccount/namespace" Â Â Â Â Â Â Â } Â Â Â } }
But with this syntax, it does not:
pipeline {
   agent {
       kubernetes {
           label 'unique-pod-name'
           defaultContainer 'container1'
           yaml """
apiVersion: v1
kind: Pod
metadata:
 namespace: my-pod-namespace
spec:
 containers:
 - name: container1
   image: centos:7
   command:
   - cat
   tty: true
"""
       }
   }
   stages {
       stage('Print config') {
           steps {
               container('container1') {
                   sh 'echo "in container container1"'
                   sh 'env | sort'
               }
           }
       }
   }
}
What am I missing?
- links to