title: Kubernetes `local` PV and directory creation
body: <p>When configuring a <code>local</code> PV I noticed there is no option to explicitly create the PV directory on the underlying node if it does not already exist, unlike an <code>hostPath</code> PV which provides the <code>DirectoryOrCreate</code> option (as shown in the doc <a href="https://kubernetes.io/fr/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">here</a>), a <code>local</code> PV requires you to first create the directory manually and give it the correct ownership and permissions.</p>
  <p>I am trying to use a <code>local</code> PV with a directory as a mounted local storage device with this code:</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
  kind: PersistentVolume
  metadata:
    name: jenkins-pv-volume
    namespace: jenkins
  spec:
    capacity:
      storage: 4Gi
    volumeMode: Filesystem
    accessModes:
      - ReadWriteOnce
    persistentVolumeReclaimPolicy: Delete
    storageClassName: local-storage
    local:
      path: &quot;/var/jenkins_home&quot;
    nodeAffinity:
      required:
        nodeSelectorTerms:
          - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                  - worker-1
  </code></pre>
  <p>However, in order for the PV to be configured correctly, I first need to ssh into the <code>worker-1</code> node and run the following commands:</p>
  <pre class="lang-sh prettyprint-override"><code>sudo mkdir -p /var/jenkins_home
  sudo chown -R 1000:1000 /var/jenkins_home
  sudo chmod -R 755 /var/jenkins_home
  </code></pre>
  <p>Would it be possible to create the directory and give it the correct ownership and permissions <em>when</em> the PV configuration is applied?</p>