title: Error: PostgreSQL Kubernetes data directory "/var/lib/postgresql/data" has wrong ownership windows
body: <p>I am new to kubernetes and stuff. I was going through the tutorials, I encountered a error while using the pstgres database and persistent volume claim. I am pretty sure that all the permissions are being given to the user but still  the error suggest that the folder has wrong ownership. </p>
  
  <p>Here are my configuration files</p>
  
  <p>This is the persistent volume claim file</p>
  
  <pre><code>apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: database-persistent-volume-claim
  spec:
    accessModes: 
      - ReadWriteOnce
    resources:
      requests:
        storage: 2Gi
  </code></pre>
  
  <p>Here is my postgres deployment file</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata: 
    name: postgres-deployment
  spec:
    replicas: 1
    selector:
      matchLabels: 
        component: postgres
    template: 
       metadata:
         labels:
           component: postgres
       spec:
         volumes:
          - name: postgres-storage
            persistentVolumeClaim:
              claimName: database-persistent-volume-claim
         containers:
           - name: postgres
             image: postgres
             ports:
               - containerPort: 5432
             volumeMounts:
               - name: postgres-storage
                 mountPath: /var/lib/postgresql/data
                 subPath: postgres
             env:
               - name: POSTGRES_HOST_AUTH_METHOD
                 value: "trust"
               - name: PGPASSWORD
                 valueFrom:
                   secretKeyRef:
                     name: pgpassword
                     key: PGPASSWORD
  
  </code></pre>
  
  <pre><code>Here is the error message 
  2020-04-12 01:57:11.986 UTC [82] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
  2020-04-12 01:57:11.986 UTC [82] HINT:  The server must be started by the user that owns the data directory.
  child process exited with exit code 1
  initdb: removing contents of data directory "/var/lib/postgresql/data"
  </code></pre>
  
  <p>Any help is appreciated?</p>