Kubernetes master 不附加 FlexVolume
Kubernetes master doesn't attach FlexVolume
我正在尝试为 Kubernetes 附加 dummy-attachable FlexVolume sample,根据我在节点和主节点上的日志,它似乎正常初始化:
Loaded volume plugin "flexvolume-k8s/dummy-attachable
但是当我尝试将卷附加到 pod 时,主节点永远不会调用附加方法。来自节点的日志读取:
flexVolume driver k8s/dummy-attachable: using default GetVolumeName for volume dummy-attachable
operationExecutor.VerifyControllerAttachedVolume started for volume "dummy-attachable"
Operation for "\"flexvolume-k8s/dummy-attachable/dummy-attachable\"" failed. No retries permitted until 2019-04-22 13:42:51.21390334 +0000 UTC m=+4814.674525788 (durationBeforeRetry 500ms). Error: "Volume has not been added to the list of VolumesInUse in the node's volume status for volume \"dummy-attachable\" (UniqueName: \"flexvolume-k8s/dummy-attachable/dummy-attachable\") pod \"nginx-dummy-attachable\"
这是我尝试装载卷的方式:
apiVersion: v1
kind: Pod
metadata:
name: nginx-dummy-attachable
namespace: default
spec:
containers:
- name: nginx-dummy-attachable
image: nginx
volumeMounts:
- name: dummy-attachable
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: dummy-attachable
flexVolume:
driver: "k8s/dummy-attachable"
这是 kubectl describe pod nginx-dummy-attachable
的输出:
Name: nginx-dummy-attachable
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: [node id]
Start Time: Wed, 24 Apr 2019 08:03:21 -0400
Labels: <none>
Annotations: kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container nginx-dummy-attachable
Status: Pending
IP:
Containers:
nginx-dummy-attachable:
Container ID:
Image: nginx
Image ID:
Port: 80/TCP
Host Port: 0/TCP
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Requests:
cpu: 100m
Environment: <none>
Mounts:
/data from dummy-attachable (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-hcnhj (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
dummy-attachable:
Type: FlexVolume (a generic volume resource that is provisioned/attached using an exec based plugin)
Driver: k8s/dummy-attachable
FSType:
SecretRef: nil
ReadOnly: false
Options: map[]
default-token-hcnhj:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-hcnhj
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedMount 41s (x6 over 11m) kubelet, [node id] Unable to mount volumes for pod "nginx-dummy-attachable_default([id])": timeout expired waiting for volumes to attach or mount for pod "default"/"nginx-dummy-attachable". list of unmounted volumes=[dummy-attachable]. list of unattached volumes=[dummy-attachable default-token-hcnhj]
我向 FlexVolume 添加了调试日志记录,因此我能够验证从未在主节点上调用附加方法。我不确定我在这里遗漏了什么。
我不知道这是否重要,但是正在使用 KOPS 启动集群。我试过 k8s 1.11 和 1.14 都没有成功。
所以这很有趣。
尽管 kubelet 在 master 上初始化了 FlexVolume 插件,但 kube-controller-manager 是容器化在 KOP 中的,它是实际负责将卷附加到 pod 的应用程序。 KOPs 不会将默认插件目录 /usr/libexec/kubernetes/kubelet-plugins/volume/exec
挂载到 kube-controller-manager pod 中,因此它对 master 上的 FlexVolume 插件一无所知。
在 KOPs 解决这个问题之前,除了使用不同的 Kubernetes 部署工具之外,似乎没有一种简单的方法可以做到这一点。
我正在尝试为 Kubernetes 附加 dummy-attachable FlexVolume sample,根据我在节点和主节点上的日志,它似乎正常初始化:
Loaded volume plugin "flexvolume-k8s/dummy-attachable
但是当我尝试将卷附加到 pod 时,主节点永远不会调用附加方法。来自节点的日志读取:
flexVolume driver k8s/dummy-attachable: using default GetVolumeName for volume dummy-attachable
operationExecutor.VerifyControllerAttachedVolume started for volume "dummy-attachable"
Operation for "\"flexvolume-k8s/dummy-attachable/dummy-attachable\"" failed. No retries permitted until 2019-04-22 13:42:51.21390334 +0000 UTC m=+4814.674525788 (durationBeforeRetry 500ms). Error: "Volume has not been added to the list of VolumesInUse in the node's volume status for volume \"dummy-attachable\" (UniqueName: \"flexvolume-k8s/dummy-attachable/dummy-attachable\") pod \"nginx-dummy-attachable\"
这是我尝试装载卷的方式:
apiVersion: v1
kind: Pod
metadata:
name: nginx-dummy-attachable
namespace: default
spec:
containers:
- name: nginx-dummy-attachable
image: nginx
volumeMounts:
- name: dummy-attachable
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: dummy-attachable
flexVolume:
driver: "k8s/dummy-attachable"
这是 kubectl describe pod nginx-dummy-attachable
的输出:
Name: nginx-dummy-attachable
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: [node id]
Start Time: Wed, 24 Apr 2019 08:03:21 -0400
Labels: <none>
Annotations: kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container nginx-dummy-attachable
Status: Pending
IP:
Containers:
nginx-dummy-attachable:
Container ID:
Image: nginx
Image ID:
Port: 80/TCP
Host Port: 0/TCP
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Requests:
cpu: 100m
Environment: <none>
Mounts:
/data from dummy-attachable (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-hcnhj (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
dummy-attachable:
Type: FlexVolume (a generic volume resource that is provisioned/attached using an exec based plugin)
Driver: k8s/dummy-attachable
FSType:
SecretRef: nil
ReadOnly: false
Options: map[]
default-token-hcnhj:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-hcnhj
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedMount 41s (x6 over 11m) kubelet, [node id] Unable to mount volumes for pod "nginx-dummy-attachable_default([id])": timeout expired waiting for volumes to attach or mount for pod "default"/"nginx-dummy-attachable". list of unmounted volumes=[dummy-attachable]. list of unattached volumes=[dummy-attachable default-token-hcnhj]
我向 FlexVolume 添加了调试日志记录,因此我能够验证从未在主节点上调用附加方法。我不确定我在这里遗漏了什么。
我不知道这是否重要,但是正在使用 KOPS 启动集群。我试过 k8s 1.11 和 1.14 都没有成功。
所以这很有趣。
尽管 kubelet 在 master 上初始化了 FlexVolume 插件,但 kube-controller-manager 是容器化在 KOP 中的,它是实际负责将卷附加到 pod 的应用程序。 KOPs 不会将默认插件目录 /usr/libexec/kubernetes/kubelet-plugins/volume/exec
挂载到 kube-controller-manager pod 中,因此它对 master 上的 FlexVolume 插件一无所知。
在 KOPs 解决这个问题之前,除了使用不同的 Kubernetes 部署工具之外,似乎没有一种简单的方法可以做到这一点。