<p>I want to create persistent volume for postgres kubernetes pod on windows 10 (<code>C:\Postrges</code>)</p>

<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:

  name: localstorage

provisioner: docker.io/hostpath
volumeBindingMode: Immediate
reclaimPolicy: Delete
allowVolumeExpansion: True

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: database-persistent-volume-claim
spec:
  storageClassName: localstorage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi

---

# How do we want it implemented
apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-storage
spec:
  storageClassName: localstorage
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete  
  hostPath:
    path: "/C/postgres"
    type: DirectoryOrCreate





$ kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                                      STORAGECLASS   REASON   AGE  
local-storage                              2Gi        RWO            Delete           Available                                              localstorage            4m14s
pvc-7e1d810f-1114-4b7c-9160-2b07830c682f   2Gi        RWO            Delete           Bound       default/database-persistent-volume-claim   localstorage            4m14s

$ kubectl get pvc
NAME                               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
database-persistent-volume-claim   Bound    pvc-7e1d810f-1114-4b7c-9160-2b07830c682f   2Gi        RWO            localstorage   5m36s
</code></pre>

<p>No events for PV, for PVC it shows "waiting for a volume to be created, either by external provisioner"</p>

<pre><code>kubectl describe pvc
Name:          database-persistent-volume-claim
Namespace:     default
StorageClass:  localstorage
Status:        Bound
Volume:        pvc-7e1d810f-1114-4b7c-9160-2b07830c682f
Labels:        &lt;none&gt;
Annotations:   pv.kubernetes.io/bind-completed: yes
               pv.kubernetes.io/bound-by-controller: yes
               volume.beta.kubernetes.io/storage-provisioner: docker.io/hostpath
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      2Gi
Access Modes:  RWO
VolumeMode:    Filesystem
Mounted By:    &lt;none&gt;
Events:
  Type    Reason                 Age    From                                                                         Message
  ----    ------                 ----   ----                                                                         -------
  Normal  ExternalProvisioning   7m24s  persistentvolume-controller                                                  waiting for a volume to be created, either by external provisioner "docker.io/hostpath" or manually created by system administrator
  Normal  Provisioning           7m24s  docker.io/hostpath_storage-provisioner_4bfa0399-b72d-4e03-ae9d-70ee4d8a7c33  External provisioner is provisioning volume for claim "default/database-persistent-volume-claim"
  Normal  ProvisioningSucceeded  7m24s  docker.io/hostpath_storage-provisioner_4bfa0399-b72d-4e03-ae9d-70ee4d8a7c33  Successfully provisioned volume pvc-7e1d810f-1114-4b7c-9160-2b07830c682f
</code></pre>

<p>But in windows explorer i can't see postgres folder on C drive</p>

<p>PVC is assigned to postgres pod</p>

<pre><code> volumes:
        - name: postgres-storage
          persistentVolumeClaim:
           claimName: database-persistent-volume-claim
      containers:
        - name: postgres
          image: postgres
          ports:
            - containerPort: 5432
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              subPath: postgres
              name: postgres-storage
</code></pre>

<p>Pod has no any errors, ran CMD as Administrator before executing <code>kubectl apply</code>, same configuration works without issues on Linux. Any thougts ?</p>

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

<p>In fact, everything is OK, Docker Desktop doesn't map Windows local storage but reclaim space on VM created when Docker Desktop is installed.</p>

<p>This VM can be accessed as described in <a href="https://www.bretfisher.com/getting-a-shell-in-the-docker-for-windows-vm/" rel="nofollow noreferrer">this post</a></p>

<pre><code>kubectl get pvc
NAME                               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
database-persistent-volume-claim   Bound    pvc-ceb8dfa1-37ca-48fe-b4bc-cc642faac6c4   2Gi        RWO            localstorage   33m
</code></pre>

<p>Browsing Docker desktop VM:    </p>

<pre><code>ls /var/lib/k8s-pvs/database-persistent-volume-claim/pvc-ceb8dfa1-37ca-48fe-b4bc-cc642faac6c4/postgres
PG_VERSION            pg_hba.conf           pg_replslot           pg_subtrans           postgresql.auto.conf
base                  pg_ident.conf         pg_serial             pg_tblspc             postgresql.conf
global                pg_logical            pg_snapshots          pg_twophase           postmaster.opts
pg_commit_ts          pg_multixact          pg_stat               pg_wal
pg_dynshmem           pg_notify             pg_stat_tmp           pg_xact
</code></pre>

<p>When postgres deployment is deleted, database files remain</p>

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