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

PVC isn't created in the namespace specified in the podTemplate

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • kubernetes-plugin
    • 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.

          [JENKINS-67711] PVC isn't created in the namespace specified in the podTemplate

          Florin Hillebrand created issue -
          Florin Hillebrand made changes -
          Description Original: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          Looking at the *project-namespace* the PVC isn't created, but instead it is created in the namespace which jenkins runs.
          New: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          Looking at the *project-namespace* the PVC isn't created, but instead it is created in the namespace which jenkins runs.

          h3. 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.
          Florin Hillebrand made changes -
          Issue Type Original: Task [ 3 ] New: Bug [ 1 ]
          Florin Hillebrand made changes -
          Description Original: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          Looking at the *project-namespace* the PVC isn't created, but instead it is created in the namespace which jenkins runs.

          h3. 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.
          New: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          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.

          h3. 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.
          Florin Hillebrand made changes -
          Description Original: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          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.

          h3. 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.
          New: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          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.

          h3. 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.
          Florin Hillebrand made changes -
          Description Original: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          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.

          h3. 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.
          New: When creating a podTemplate and specifying a `namespace`, defined persistentVolumeClaims as volumes are not created in the given namespace.

          h3. podTemplate

          {code:groovy}
           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"
          {code}

          h3. 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:

          {noformat}
          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.
          {noformat}

          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.

          h3. 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.
          Florin Hillebrand made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: Open [ 1 ] New: Fixed but Unreleased [ 10203 ]
          Florin Hillebrand made changes -
          Assignee New: Florin Hillebrand [ flozzone ]

            flozzone Florin Hillebrand
            flozzone Florin Hillebrand
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: