<p>Here is my <code>containerTemplate</code> snippet from Jenkinsfile which creates a pod and a container called mvn-c1 onto Kubernetes.</p>

<pre><code>containerTemplate(
  name: 'mvn-c1',
  image: 'mycompany.lab/build_images/mvn_c1_k8s:0.3',
  privileged: true,
  ttyEnabled: true,
  command: 'cat',
  imagePullSecrets: ['docker-repo'],

  volumeMounts: [ name: 'maven-repo1' , mountPath: '/root/.m2' ],
  volumes: [
    nfsVolume( mountPath: '/root/.m2', serverAddress: 'nfs-server-ip', 
    serverPath: '/jenkins_data', readOnly: false ),
  ]
)
</code></pre>

<p>The problem is that the volume is not able to mount to the container nor doesn't show any parse errors on the console.</p>

<p>I have referred <a href="https://jenkins.io/doc/pipeline/steps/kubernetes/" rel="nofollow noreferrer">this documentation</a> to construct the <code>containerTemplate</code></p>

<p>Has anybody had luck trying this method?</p>

Vamshi Krishna Santhapuri
<p>Welcome on StackOverflow @Vamshi</p>

<p>I think you have two issues with your current Pipeline definition:</p>

<ol>
<li><code>volumes</code> are part of podTemplate not containerTemplate</li>
</ol>

<blockquote>
  <p>WARNING: Unknown parameter(s) found for class type
  'org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate': volumes</p>
</blockquote>

<ol>
<li>Usually your Kubernetes plugin spawns Jenkins slave Pods in another namespace than your NFS server resides, therefore it's safer to specify for NFS volumes as 'serverAddress' an IP address of NFS server instead of its Kubernetes Service name.</li>
</ol>

<p>Here is a fully working example:</p>

<pre><code>podTemplate(containers: [
    containerTemplate(name: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat')
  ],
    volumes: [
    nfsVolume( mountPath: '/root/.m2', serverAddress: '10.0.174.57', 
    serverPath: '/', readOnly: false ),
    ]
  ) {

    node(POD_LABEL) {
        stage('Get a Maven project') {
            container('maven') {
                stage('Build a Maven project') {
                    sh 'while true; do date &gt; /root/.m2/index.html; hostname &gt;&gt; /root/.m2/index.html; sleep $(($RANDOM % 5 + 5)); done'
                }
            }
        }

    }
}
</code></pre>

<p>Verifying the correctness of nfs-based Persistence Volume mounted inside POD:</p>

<pre><code>kubectl exec container-template-with-nfs-pv-10-cl42l-042tq-z3n7b -c maven -- cat /root/.m2/index.html
</code></pre>

<blockquote>
  <p>Output:
  Mon Aug 26 14:47:28 UTC 2019 nfs-busybox-9t7wx</p>
</blockquote>
