If you're looking to create persistent volumes in Kubernetes without setting nodeAffinity, setup your PV config like this:
---
apiVersion: v1
kind: PersistentVolume
metadata:
name:
labels:
type: local
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-path
hostPath:
path: /opt/data/
Note how we are using the labels key under metadata as well as changing path under spec to hostPath.
Hope this helps! I was stuck on it for a while. This is useful for single node K8s setups where you are only storing data locally (on the one host).