title: Solution to mount a persistent "dynamic" file in Kubernetes
body: <p>The idea is to store persistently the data generated by the user in Jenkins Dashboard (jobs, scriptlers, credentials, ...) so when I mount theses volumes after each restart, I am able to retrieve the stored data  (mounted volumes) in jobs and scriptlers. (I am not using the solution with JcasC (yaml files) for jobs, scriptlers, ... as the user will define them dynamically from the UI).</p>
  <p>Now, I am trying to mount the &quot;credentials.xml&quot; file (persistent volume), as I made with &quot;scriptler&quot; and &quot;jobs&quot; folder mount. But it does not work because it's a file, not a folder.</p>
  <p>The solution to mount as a ConfigMap is not applicable here as the file cannot be predefined because modified by the user in the dashboard for any change in credentials.</p>
  <p>I am looking for a solution to mount this file like a &quot;persistent volume&quot;</p>
  <p>Here is my YAML deployment (values) file (it does not work with 'jenkins-credentials' mount):</p>
  <pre><code>persistence:
    volumes:
      - name: jenkins-jobs
        persistentVolumeClaim:
          claimName: jenkins-jobs
  
      - name: jenkins-scriptlers
        persistentVolumeClaim:
          claimName: jenkins-scriptlers
  
      - name: jenkins-credentials
        configMap:
          name: cm-credentials-xml
  
    mounts:
      - name: jenkins-jobs
        mountPath: /var/jenkins_home/jobs
        readOnly: false
  
      - name: jenkins-scriptlers
        mountPath: /var/jenkins_home/scriptler
        readOnly: false
  
      - name: jenkins-credentials
        mountPath: /var/jenkins_home/credentials.xml
        #subPath: credentials.xml
        readOnly: false
  </code></pre>
  <p>Thanks</p>