<p>I am setting up my jenkins on kubernetes via helm to run my java deployment, </p>

<p>This spawns new pods for every build -> fair enough</p>

<p>Then I see that I need to store some maven jars which will be used by other builds,</p>

<p>So I came up with NFS installation and mounted it to /home/jenkins/.m2 via  jenkins configure (Web console)</p>

<p>Then I keep getting the </p>

<p><code>error org.apache.maven.repository.LocalRepositoryNotAccessibleException: Could not create local repository at /home/jenkins/.m2/repository</code></p>

<p>I even tried </p>

<p><code>securityContext:
        runAsUser: 1000
        fsGroup: 1000
</code> 
in the deployment.yaml </p>

<p>I tried adding </p>

<p><code>USER root
RUN chown -R root /home/jenkins</code> </p>

<p>in the slave container</p>

<p>Its just not with the .m2 , slave is not able to write anything on this pvc.</p>

<p>At this point I’m confused where else the problem could be. 
can some one please help?</p>

<p>I had similar issue. I solved this way:</p>

<ul>
<li>made own jnlp image, modified, with maven installed on it</li>
<li>i moved m2 out of jenkins home directory into /opt/m2 through maven configuration</li>
<li>created persistent disk, and bounded pv and pvc with it and mounted on /opt/m2 inside pod</li>
<li>and last, I set inside Dockerfile for jnlp that User running image is ROOT, since every mount on kubernetes is mounted as root. Not very elegant but working solution</li>
</ul>
