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

scripted volumes are not mounted into yaml defined pods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • k8s: 1.11.1
      docker: 17.03.2
      kubernetes-plugin: 1.12.4

      When using a combination of yaml pod definition plus regular script volumes the volumes are not automatically mounted into the pod:

       

      def label = "minion-backend-${UUID.randomUUID().toString()}"
      podTemplate(
          label: label, yaml: """
      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: maven
          image: maven:3.5.3-jdk-8
          securityContext:
            runAsUser: 10000
          command:
          - cat
          tty: true
          env:
          - name: MAVEN_CONFIG
            value: /home/jenkins/.m2
          - name: MAVEN_OPTS
            value: '-Xmx2048m -Duser.home=/home/jenkins'
      """
      ,
          volumes: [
            secretVolume(secretName: 'maven-secret', mountPath: '/home/jenkins/.m2'),
            persistentVolumeClaim(claimName: 'maven-repo', mountPath: '/home/jenkins/.m2repo')
          ],
          imagePullSecrets: ['regcred']
        ) {
          node(label) {
              stage('Checkout source') {
                  }
              }
      }
      

      In order to mount the scripted volumes we need to add the following section to the yaml spec:

          volumeMounts:
          - mountPath: /home/jenkins/.m2
            name: volume-0
          - mountPath: /home/jenkins/.m2repo
            name: volume-1
      

            Unassigned Unassigned
            askannon Thorsten Kunz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: