I want to add the following rule to my Node Selector via Rancher GUI:
Key: kubernetes.io/hostname
Operator: in list
Values: my-node-1
When clicking on Save I am receiving the following error:
Validation failed in API: PersistentVolume “my-volume” is invalid: nodeAffinity: Invalid value: core.VolumeNodeAffinity{Required:(*core.NodeSelector)(0xc007efbc80)}: field is immutable
I am able to save the following rule in the same Node Selector:
Key: hostname
Operator: in list
Values: my-node-1
Of course my pod is not coming online because of this event:
Warning
FailedScheduling
0/2 nodes are available: 1 node(s) didn’t match node selector, 1 node(s) had volume node affinity conflict.
When I add custom label named Hostname to my-node-1 everything works as expected.
What am I doing wrong?
Edit:
I was able to create correct PV via kubectl.
cat > test-ssd-volume.yaml << EOF
apiVersion: v1
kind: PersistentVolume
metadata:
name: test-ssd-volume
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem
storageClassName: local-ssd
local:
path: /mnt/local-storage/ssd/disk1
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- my-node-1
EOF
kubectl create -f test-ssd-volume.yaml
Created PV looks fine in Rancher GUI.