I am using three nodes kubernetes cluster and have created pv and pvc with following yaml.
- pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv01
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
capacity:
storage: 1Gi
storageClassName: local-storage
local:
path: /mnt/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- kworker1
- pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc01
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
storageClassName: local-storage
volumeName: pv01
After creating the pv anc pvc, trying to create a pod, which uses the pvc but it ramined in pending state.
- pod.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc01
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
storageClassName: local-storage
volumeName: pv01
why it is in pending state.