influxdata-operator icon indicating copy to clipboard operation
influxdata-operator copied to clipboard

Create Local Storage Failed(spec.nodeAffinity: Required value: Local volume requires node affinity)

Open zealzhangz opened this issue 5 years ago • 2 comments

Create PV failed

kubectl create -f local_storage.yaml
storageclass.storage.k8s.io/standard-resize created
The PersistentVolume "influxdb-data-pv" is invalid: spec.nodeAffinity: Required value: Local volume requires node affinity

I found a sample,It can create success, but it's uncertain whether it really provides the ability to store data.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: standard-resize
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: Immediate
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: influxdb-data-pv
spec:
  capacity:
    storage: 8Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local
  local:
    path: /var/lib/influxdb/
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
            - key: kubernetes.io/hostname
              operator: In
              values:
                - my-node

zealzhangz avatar Sep 26 '19 11:09 zealzhangz

I'm seeing a similar issue with node affinity.

I attempted to update the storage.yaml file to use my current hostname, however, this throws a new error.

$ kubectl apply -f influxoperator/deploy/storage.yaml storageclass.storage.k8s.io/standard-resize unchanged persistentvolumeclaim/influxdb-data-pvc unchanged The PersistentVolume "influxdb-data-pv" is invalid: nodeAffinity: Invalid value: core.VolumeNodeAffinity{Required:(*core.NodeSelector)(0xc100090)}: field is immutable

Is there a hardcoded expected value for the hostname? or am I misreading this field? Is there any documentation available to help avoid node affinity issues?

Thanks,

jpeck89 avatar Apr 01 '20 21:04 jpeck89

Thanks for sharing your nodeAffinity example. I used it with minikube value (instead of my-node).

mikaelkundert avatar Jun 04 '21 13:06 mikaelkundert