When a PV has an affinity to node, the PV is only available to that node. This means when a pod is scheduled in another node and tries to use that PV, the pod will be in Pending status. To set nodeAffinity on a PV, here is an example:
apiVersion: v1
kind: PersistentVolume
metadata:
name: orange-pv-cka07-str
spec:
storageClassName: orange-stc-cka07-str
persistentVolumeReclaimPolicy: Retain
capacity:
storage: 150Mi
accessModes:
- ReadWriteOnce
local:
path: /opt/orange-data-cka07-str
nodeAffinity:
required:
nodeSelectorTerms:
- matchFields:
- key: metadata.name
operator: In
values:
- cluster1-controlplane