influxdata / influxdata-operator

A k8s operator for InfluxDB
MIT License
76 stars 32 forks source link

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

Open zealzhangz opened 5 years ago

zealzhangz commented 5 years ago

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
jpeck89 commented 4 years ago

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,

mikaelkundert commented 3 years ago

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