Kubernetes Minio Volume 节点亲和性冲突

Kubernetes Minio Volume Node Affinity Conflict

我已经设置了一个带有 4 个代理和一个服务器的测试 k3d 集群。

我有一个存储 class 定义如下:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
    name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: Immediate

pv 定义如下:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: basic-minio-storage
  labels:
    storage-type: object-store-path
spec:
  capacity:
    storage: 500Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /data/basic_minio
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - k3d-test-agent-0

我定义的pvc是这样的:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  # This name uniquely identifies the PVC. Will be used in deployment below.
  name: minio-pv-claim
  labels:
    app: basic-minio
spec:
  # Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
  accessModes:
    - ReadWriteOnce
  storageClassName: local-storage
  resources:
    # This is the request for storage. Should be available in the cluster.
    requests:
      storage: 500Gi
  selector:
    matchLabels:
      storage-type: object-store-path


我的部署是这样的:


# Create a simple single node Minio linked to root drive
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: basic-minio
  namespace: minio
spec:
  selector:
    matchLabels:
      app: basic-minio
  serviceName: "basic-minio"
  template:
    metadata:
      labels:
        app: basic-minio
    spec:
      containers:
      - name: basic-minio
        image: minio/minio:RELEASE.2021-10-10T16-53-30Z
        imagePullPolicy: IfNotPresent
        args:
        - server
        - /data
        env:
        - name: MINIO_ROOT_USER
          valueFrom:
            secretKeyRef:
              name: minio-secret
              key: minio-root-user
        - name: MINIO_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: minio-secret
              key: minio-root-password 
        ports:
        - containerPort: 9000
        volumeMounts:
        - name: storage
          mountPath: "/data"
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: minio-pv-claim
        


在我的 kubernetes 仪表板中,我可以看到 PV 已配置并准备就绪。 已设置PV并绑定PV

但是我的 pod 显示错误:0/5 nodes are available: 5 node(s) had volume node affinity conflict.

是什么导致了这个问题,我该如何调试它?

您的(本地)卷是在工作节点 k3d-test-agent-0 上创建的,但是您的 pod 的 none 被安排到此节点上的 运行。这不是一个好方法,但如果你必须以这种方式 运行,你可以将所有 pods 定向到此主机上的 运行:

...
spec:
  nodeSelector:
    kubernetes.io/hostname: k3d-test-agent-0
  containers:
  - name: basic-minio
...