I try to understand how Persistent volume works in Kubernetes and faced with some trouble.
I use minikube and start it on Windows 10 Pro. My goal is to add volume c:\manifests\data to my test pod.
This is my PV manifest:
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-test-pv
spec:
accessModes:
- ReadWriteOnce
local:
path: 'c:\manifests\data\'
capacity:
storage: 2Gi
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- minikube
persistentVolumeReclaimPolicy: Retain
c:\manifests\kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
my-test-pv 2Gi RWO Retain Available 54s
Then I try to create PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myclaim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
volumeName: my-test-pv
And nothing changes in my cluster. my-test-pv still available, but I assumed it have to be Bound state.
What I did wrong?
I'll use this manifest for testing my PV:
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: my-test-pod
image: nginx
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: myclaim