<p>I am trying to mount postgrsql persitance volume in kubernetes locally with static provisioning.
Here is my yaml file i created pv , pvc and pod</p>

<pre><code> apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: task-pv-volume
      namespace: manhattan
      labels:
        type: local
    spec:
      storageClassName: manual
      capacity:
        storage: 100Mi
      accessModes:
        - ReadWriteOnce
      hostPath:
        path: "/mnt/data"
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: task-pv-claim
      namespace: manhattan
    spec:
      storageClassName: manual
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 80Mi
    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: dbr-postgres
 namespace: manhattan
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: postgresql:2.0.1
      tty: true
      volumeMounts:
        -  mountPath: "/var/lib/pgsql/9.3/data"
           name: task-pv-storage
           subPath: data
           readOnly: false
  nodeSelector:
     kubernetes.io/hostname: k8s-master
</code></pre>

<p>My volume lies in the /var/lib/pgsql/9.3/data  but my pod fails and i don't want to change the location of mountPath to   /var/lib/pgsql/9.3/data/backup</p>

<p>can you please suggest any overwrite option in yaml file</p>

<p>I don't want to create the folder with new name here .</p>

<p><a href="https://i.stack.imgur.com/TaE1J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TaE1J.png" alt="enter image description here"></a></p>

<p>If i changed the mountPath to   /var/lib/pgsql/9.3/data/backup the pod starts running but i dont want that i want the data to writtend in  the same directory /var/lib/pgsql/9.3/data</p>

UDIT JOSHI
<p>As per official documentation for postgres:9.4 from dockerhub:</p>

<p><strong>1</strong>. Please Note:</p>

<blockquote>
  <p>Warning: the Docker specific variables will only have an effect if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.</p>
</blockquote>

<p><strong>2</strong>. <code>PGDATA</code> environment variable:</p>

<blockquote>
  <p>This optional variable can be used to define another location - like a subdirectory - for the database files. The default is /var/lib/postgresql/data, but if the data volume you're using is a filesystem mountpoint (like with GCE persistent disks), Postgres initdb recommends a subdirectory (for example /var/lib/postgresql/data/pgdata ) be created to contain the data.</p>
</blockquote>

<p>As workaround please refer to:</p>

<ul>
<li>the official docs while working with <a href="https://github.com/docker-library/postgres/blob/4b652bf95baee9cd7ef31300a4938ad72d09ad88/9.4/alpine/Dockerfile" rel="nofollow noreferrer">Dockerfile</a> </li>
<li>helm charts for stable <a href="https://github.com/helm/charts/tree/master/stable/postgresql" rel="nofollow noreferrer">postgresql</a> </li>
</ul>

<p>You can also change the image to the specific one <a href="https://github.com/helm/charts/tree/master/stable/postgresql#deploy-chart-using-docker-official-postgresql-image" rel="nofollow noreferrer">using helm chart</a>: </p>

<blockquote>
  <p>From chart version 4.0.0, it is possible to use this chart with the Docker Official PostgreSQL image. Besides specifying the new Docker repository and tag, it is important to modify the PostgreSQL data directory and volume mount point. Basically, the PostgreSQL data dir cannot be the mount point directly, it has to be a subdirectory.</p>
</blockquote>

<pre><code>helm install --name postgres \
             --set image.repository=postgres \
             --set image.tag=10.6 \
             --set postgresqlDataDir=/data/pgdata \
             --set persistence.mountPath=/data/ \
             stable/postgresql
</code></pre>

<p>You can template this helm chart and customizing. From another point of view the main problem is that you have initialized your database  - as you mentioned under /var/lib/pgsql/9.3/data/backup so please verify your docker file and your docker-entrypoint.sh to figure out where is the problem.</p>

<p>Please let me know if this helped.</p>
