-
Bug
-
Resolution: Not A Defect
-
Minor
-
Jenkins 2.319.2
kubernetes-plugin 1.31.3
Running on Openshift4
Scripted pipeline with a Jenkins shared library
When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.
podTemplate
podTemplate( serviceAccount: "default", containers: [ containerTemplate( name: "jnlp", image: "image-registry.openshift-image-registry.svc:5000/openshift/jenkins-agent-nodejs:latest", envVars: [ envVar(key: "HOME", value: "/home/jenkins/agent") ] ), containerTemplate( name: "maven", image: "${imageRegistry}/${imageNamespace}/jdk-maven-jenkins-slave:jdk-11", command: "sleep", args: "99999", alwaysPullImage: true, envVars: [ envVar(key: "HOME", value: "/home/jenkins/agent"), envVar(key: "TZ", value: "Europe/Rome"), ], resourceLimitCpu: "2", resourceRequestCpu: "1", resourceLimitMemory: "4Gi", resourceRequestMemory: "1Gi" ) ], volumes: [ persistentVolumeClaim(mountPath: "/home/jenkins/agent/.m2/repository", claimName: "maven-repository-cache") ], namespace: "project-namespace"
Actual result
The PVC maven-repository-cache is not created in the namespace project-namespace and thus the slave pod doesn't start up with the following error:
Created Pod: openshift project-namespace/dummy-job-11-4r89n-r81k2-9jh13 [Warning][project-namespace/dummy-job-11-4r89n-r81k2-9jh13][FailedScheduling] 0/10 nodes are available: 10 persistentvolumeclaim "maven-repository-cache" not found.
Looking at the project-namespace the PVC isn't created, but instead it is created in the namespace which jenkins runs.
EDIT: The PVC isn't created in Jenkins namespace, but was there already from previous run. This brought me to the assumption that jenkins-kubernetes created the PVC.
Expected result
The plugin should populate the PVC resource with the namespace given in the podTemplate, so that the PVC is created in the correct namespace.