k8s volume.attachments 中的节点字段是什么意思?

What node field means in k8s volume.attachments?

我有以下 Volume:

Name:         pvc-c8a0c1ee-b9e6-11e9-9ffa-0cc47ab04738
Namespace:    rook-ceph-system
Labels:       <none>
Annotations:  <none>
API Version:  rook.io/v1alpha2
Attachments:
  Cluster Name:   rook-ceph
  Mount Dir:      /var/lib/kubelet/pods/72fd4f89-5110-49b7-8d88-87488b58695c/volumes/ceph.rook.io~rook-ceph-system/pvc-c8a0c1ee-b9e6-11e9-9ffa-0cc47ab04738
  Node:           node-6.xyz.com
  Pod Name:       dev-cockroachdb-0
  Pod Namespace:  x-namespace
  Read Only:      false
Kind:             Volume
Metadata:
  Creation Timestamp:  2020-08-12T17:13:51Z
  Generation:          6
  Resource Version:    638003207
  Self Link:           /apis/rook.io/v1alpha2/namespaces/rook-ceph-system/volumes/pvc-c8a0c1ee-b9e6-11e9-9ffa-0cc47ab04738
  UID:                 db0a9491-95fe-49cd-8160-89031847d636
Events:                <none>

对于 pod dev-cockroachdb-0 我收到以下错误:

MountVolume.SetUp failed for volume "pvc-c8a0c1ee-b9e6-11e9-9ffa-0cc47ab04738" : mount command failed, status: Failure, reason: Rook: Mount volume failed: failed to attach volume pvc-c8a0c1ee-b9e6-11e9-9ffa-0cc47ab04738 for pod x-namespace/dev-cockroachdb-0. Volume is already attached by pod x-namespace/dev-cockroachdb-0. Status Pending

并且 pod x-namespace/dev-cockroachdb-0 当前计划到 node-5.xyz.com

因此,如您所见,pod 本身与 VolumeAttachment 位于不同的节点中。 node-6.xyz.com 对比 node-5.xyz.com.

问题:

你没有提到它,但看起来你有一个 Rook 卷。也许 pvc-clone,像这样:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rbd-pvc-clone
spec:
  storageClassName: rook-ceph-block
  dataSource:
    name: rbd-pvc
    kind: PersistentVolumeClaim
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

Does Node in Volume.Attachments point to the node on which the pod (to which the volume is attached) is located? (So if the volume is attached to a pod on node NodeA, then the value of node field for the volume attachment will be NodeA)

不是真的,您的 Pod 可能试图在 node-5.xyz.com 上启动,但卷可能附加到另一个节点,在您的情况下是 node-6.xyz.com

May this error happen because of the failure to correctly detach the volume on some node?

是的,如果您在 node-6.xyz.com 中有另一个 pod 运行 终止并且无法分离,则可能会发生此错误。

请记住,以上所有内容均考虑到您的卷有 accessModes: ReadWriteOnce。看起来您正在将 Ceph 与 Rook 一起使用,在这种情况下,您还可以使用 accessModes: ReadWriteMany,这实际上允许您将卷附加到 Kubernetes 节点。

✌️