简体   繁体   English

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

[英]What node field means in k8s volume.attachments?

I have the following Volume :我有以下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>

For the pod dev-cockroachdb-0 I'm getting the following error:对于 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

And the pod x-namespace/dev-cockroachdb-0 is currently scheduled to node-5.xyz.com .并且 pod x-namespace/dev-cockroachdb-0当前计划为node-5.xyz.com

So, as you can see the pod itself is in a different node than the VolumeAttachment .因此,如您所见,pod 本身与VolumeAttachment位于不同的节点中。 node-6.xyz.com vs node-5.xyz.com . node-6.xyz.comnode-5.xyz.com

Questions:问题:

  • Does Node in Volume.Attachments point to the node on which the pod (to which the volume is attached) is located? Volume.Attachments中的Node是否指向 Pod(卷所附加的)所在的节点? (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 ) (因此,如果卷附加到节点NodeA上的 pod,则卷附加的节点字段的值将为NodeA
  • May this error happen because of the failure to correctly detach the volume on some node?由于未能正确分离某个节点上的卷,是否可能会发生此错误?

You didn't mention it but it looks like you have a Rook volume.你没有提到它,但看起来你有一个 Rook 卷。 Perhaps a pvc-clone, something like this:也许是一个 pvc 克隆,像这样:

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? Volume.Attachments 中的 Node 是否指向 Pod(卷所附加的)所在的节点? (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) (因此,如果卷附加到节点 NodeA 上的 pod,则卷附加的节点字段的值将是 NodeA)

Not really, your Pod may be trying to start on node-5.xyz.com , but the volume could be attached to another node in your case it's node-6.xyz.com .并非如此,您的 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?由于未能正确分离某个节点上的卷,是否可能会发生此错误?

Yes, this error may happen if maybe you had another pod running in node-6.xyz.com that terminated and failed to detach.是的,如果您在node-6.xyz.com中运行的另一个 pod 终止并且无法分离,则可能会发生此错误。

Keep in mind that all of the above is considering that your volume has accessModes: ReadWriteOnce .请记住,以上所有内容都考虑到您的卷具有accessModes: ReadWriteOnce It looks like you are using Ceph with Rook and in that case, you can also use accessModes: ReadWriteMany which would essentially allow you to attach the volume to Kubernetes nodes.看起来您正在将 Ceph 与 Rook 一起使用,在这种情况下,您还可以使用accessModes: ReadWriteMany ,这实际上允许您将卷附加到 Kubernetes 节点。

✌️ ✌️

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM