<p>I have deployment a postgresql stateful service in kubernetes, now mapped the <code>/bitnami/postgresql</code> to the NFS volumn like this way:</p>
<pre><code>spec:
  volumes:
    - name: dshm
      emptyDir:
        medium: Memory
    - name: data-reddwarf-postgresql-postgresql-general
      persistentVolumeClaim:
        claimName: data-reddwarf-postgresql-postgresql-general
  containers:
    - name: reddwarf-postgresql
      image: docker.io/bitnami/postgresql:13.3.0-debian-10-r75
      ports:
        - name: tcp-postgresql
          containerPort: 5432
          protocol: TCP
      env:
        - name: BITNAMI_DEBUG
          value: 'false'
        - name: POSTGRESQL_PORT_NUMBER
          value: '5432'
        - name: POSTGRESQL_VOLUME_DIR
          value: /bitnami/postgresql
        - name: PGDATA
          value: /bitnami/postgresql/data
        - name: POSTGRES_USER
          value: postgres
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: reddwarf-postgresql
              key: postgresql-password
        - name: POSTGRESQL_ENABLE_LDAP
          value: 'no'
        - name: POSTGRESQL_ENABLE_TLS
          value: 'no'
        - name: POSTGRESQL_LOG_HOSTNAME
          value: 'false'
        - name: POSTGRESQL_LOG_CONNECTIONS
          value: 'false'
        - name: POSTGRESQL_LOG_DISCONNECTIONS
          value: 'false'
        - name: POSTGRESQL_PGAUDIT_LOG_CATALOG
          value: 'off'
        - name: POSTGRESQL_CLIENT_MIN_MESSAGES
          value: error
        - name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
          value: pgaudit
      resources:
        limits:
          cpu: 600m
          memory: 1Gi
        requests:
          cpu: 250m
          memory: 256Mi
      volumeMounts:
        - name: dshm
          mountPath: /dev/shm
        - name: data-reddwarf-postgresql-postgresql-general
          mountPath: /bitnami/postgresql
</code></pre>
<p>now I want to add another folder <code>/docker-entrypoint-preinitdb.d</code> mapping from deployment to the NFS PV. Am I need to add a new PVC&amp;PV for mapping the new folder? what should I do to use the same PV&amp;PVC with multiple folder so that I did not need to add extra NFS mapping? I have already tried the config like this:</p>
<pre><code>volumeMounts:
            - name: dshm
              mountPath: /dev/shm
            - name: data-reddwarf-postgresql-postgresql-general
              mountPath: /bitnami/postgresql
            - name: data-reddwarf-postgresql-postgresql-general
              mountPath: /docker-entrypoint-preinitdb.d
</code></pre>
<p>but the NFS folder did not create the container folder <code>docker-entrypoint-preinitdb.d</code>. Seems the mapping did not success.</p>

<p>You should definitely go with a separate volume.</p>
<p>Even if you manage to mount multiple times the same PV in different locations, each mount would still expose all the files and directory in the PV. If <code>/docker-entrypoint-preinitdb.d</code> contains a bunch of scripts and no actual data, you could use a <a href="https://kubernetes.io/docs/concepts/configuration/configmap/#using-configmaps-as-files-from-a-pod" rel="nofollow noreferrer">ConfigMap</a> instead of creating a new NFS PVC.</p>
