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

workspace-volume should be optional

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: kubernetes-plugin
    • Labels:
      None
    • Environment:
      Plugin version 1.1
    • Similar Issues:

      Description

      The current default volumeMounts for a slave pod includes:

      volumeMounts:
       - mountPath: /home/jenkins
       name: workspace-volume
      ...
        volumes:
        - emptyDir: {}
          name: workspace-volume
      

      I am building a custom image on top of jenkins/jnlp-slave:alpine and I have populated some files under:

      • /home/jenkins/.helm/
      • /home/jenkins/.config/

      Unfortunately everything under /home/jenkins vanishes because of the mount point.

      I wish I had the option for /home/jenkins to not be mounted.

        Attachments

          Issue Links

            Activity

            Hide
            fgsalomon Fran Garcia added a comment -

            Sometime after my first comment this was fixed for us but recently this behavior has been regressed.

            We are using Jenkins: 2.164.1. We thought the behavior had changed after updating to kubernetes-1.14.9, however we've tried downgrading it to 1.14.8 and the volume is still mounted over /home/jenkins. I don't see changes related to this issue on the changelog. Could this happen because of a change in a dependency?

            Show
            fgsalomon Fran Garcia added a comment - Sometime after my first comment this was fixed for us but recently this behavior has been regressed. We are using Jenkins: 2.164.1. We thought the behavior had changed after updating to kubernetes-1.14.9, however we've tried downgrading it to 1.14.8 and the volume is still mounted over /home/jenkins. I don't see changes related to this issue on the changelog . Could this happen because of a change in a dependency?
            Hide
            bernardomk Bernardo Corrêa added a comment - - edited

            Carlos Sanchez Wouldn't adding subPath solve the issue (under Secret Volume)? Then we would be able to specify a subpath and mount secrets as shown bellow:

             

            volumeMounts:
             - name: jenkins
             mountPath: "/home/jenkins/.npmrc"
             subPath: npmrc
             readOnly: false 
             volumes:
             - name: jenkins
             secret:
             secretName: jenkins

             

            We have a bunch of configuration files under JENKINS_HOME. Would also be nice to be able to have SecurityContext. 

             

            Or if you have any suggestions on how to get around this issue...

             Or allowing users to change from emptyDir to secret or ConfigMap...

            Thanks in advance.

             

             

            Show
            bernardomk Bernardo Corrêa added a comment - - edited Carlos Sanchez Wouldn't adding subPath solve the issue (under Secret Volume)? Then we would be able to specify a subpath and mount secrets as shown bellow:   volumeMounts: - name: jenkins mountPath: "/home/jenkins/.npmrc" subPath: npmrc readOnly: false volumes: - name: jenkins secret: secretName: jenkins   We have a bunch of configuration files under JENKINS_HOME. Would also be nice to be able to have SecurityContext.    Or if you have any suggestions on how to get around this issue...  Or allowing users to change from emptyDir to secret or ConfigMap... Thanks in advance.    
            Hide
            akom Alexander Komarov added a comment - - edited

            Like many people here I pre-configure my docker images with everything including the autoinstalled contents of the [WORKDIR]/tools directory (maven, gradle, groovy, etc).   This works great with the docker plugin, not so much with k8s.

            My current workaround is to symlink the tools directory into the Working Directory in my ENTRYPOINT script when running in k8s (my images are also used outside of k8s)

            NORMAL_WORKDIR=/data/jenkins-slave
            if [ -n "$JENKINS_AGENT_WORKDIR" ] && [ "$JENKINS_AGENT_WORKDIR" != "$NORMAL_WORKDIR" ] ; then
              echo "Linking preinstalled Jenkins tools into the active workdir: $JENKINS_AGENT_WORKDIR"
              ln -s $NORMAL_WORKDIR/tools $JENKINS_AGENT_WORKDIR/
            fi
            

            (My ENTRYPOINT script is a wrapper around /usr/local/bin/jenkins-slave)

            Show
            akom Alexander Komarov added a comment - - edited Like many people here I pre-configure my docker images with everything including the autoinstalled contents of the [WORKDIR] /tools directory (maven, gradle, groovy, etc).   This works great with the docker plugin, not so much with k8s. My current workaround is to symlink the tools directory into the Working Directory in my ENTRYPOINT script when running in k8s (my images are also used outside of k8s) NORMAL_WORKDIR=/data/jenkins-slave if [ -n "$JENKINS_AGENT_WORKDIR" ] && [ "$JENKINS_AGENT_WORKDIR" != "$NORMAL_WORKDIR" ] ; then echo "Linking preinstalled Jenkins tools into the active workdir: $JENKINS_AGENT_WORKDIR" ln -s $NORMAL_WORKDIR/tools $JENKINS_AGENT_WORKDIR/ fi (My ENTRYPOINT script is a wrapper around /usr/local/bin/jenkins-slave)
            Hide
            rainerw Rainer Weinhold added a comment -

            For me a part got 'fixed' when in one of the last Versions the EmptyDirectory got mounted at ~/agent instead of the ~ directory.

            But this won't fix the tools case. Which i'm currently not using, but I want, because of performance (time + traffic) issues, when with every new container Jenkins needs to download all tools again. Would it be possible to change the tools root folder to somthing like "~/agent-tools" ?

             

            Show
            rainerw Rainer Weinhold added a comment - For me a part got 'fixed' when in one of the last Versions the EmptyDirectory got mounted at ~/agent instead of the ~ directory. But this won't fix the tools case. Which i'm currently not using, but I want, because of performance (time + traffic) issues, when with every new container Jenkins needs to download all tools again. Would it be possible to change the tools root folder to somthing like "~/agent-tools" ?  
            Hide
            vlatombe Vincent Latombe added a comment -

            This was fixed through the changes done in kubernetes plugin 1.18.x where the default working directory was changed from /home/jenkins to /home/jenkins/agent.

            Regarding the problem with 'tools': don't use them when working with docker images. Install the tools in docker images.

            Show
            vlatombe Vincent Latombe added a comment - This was fixed through the changes done in kubernetes plugin 1.18.x where the default working directory was changed from /home/jenkins to /home/jenkins/agent. Regarding the problem with 'tools': don't use them when working with docker images. Install the tools in docker images.

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              h0tbird Marc Villacorta
              Votes:
              11 Vote for this issue
              Watchers:
              19 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: