linux - 带有 xfs 的 Kubernetes PVC 挂载失败,代码为 32
问题描述
我有一个Pod
从PersistentVolumeClaim
. PVC 使用StorageClass
带有文件系统的配置 EBS 卷xfs
。设置如下:
volumeMounts:
- mountPath: "/opt/st1"
name: opt-st1
volumes:
- name: opt-st1
persistentVolumeClaim:
claimName: st1-xfs-pvc
kind: PersistentVolumeClaim
metadata:
name: st1-xfs-pvc
labels:
app: st1-xfs-pvc
spec:
storageClassName: st1-xfs-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Gi
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: st1-xfs-sc
provisioner: kubernetes.io/aws-ebs
parameters:
type: st1
fsType: xfs
reclaimPolicy: Retain
mountOptions:
- debug
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- us-east-1a
当我在基于 EKS 的集群(版本 1.13)上运行此设置时,我收到以下错误:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 45s default-scheduler Successfully assigned jira-node-deployment-5f4f59c44d-jbc4c to ip-10-237-86-124.ec2.internal
Warning FailedAttachVolume 40s (x4 over 44s) attachdetach-controller AttachVolume.Attach failed for volume "pvc-50996814-bf53-11e9-848f-0ec61103f6e0" : "Error attaching EBS volume \"vol-077709885f54252c7\"" to instance "i-0fe9867c4129f058e" since volume is in "creating" state
Normal SuccessfulAttachVolume 33s attachdetach-controller AttachVolume.Attach succeeded for volume "pvc-50996814-bf53-11e9-848f-0ec61103f6e0"
Warning FailedMount 24s kubelet, ip-10-237-86-124.ec2.internal MountVolume.MountDevice failed for volume "pvc-50996814-bf53-11e9-848f-0ec61103f6e0" : mount failed: exit status 32
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7 --scope -- mount -t xfs -o debug,defaults /dev/xvdbp /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7
Output: Running scope as unit run-979548.scope.
mount: /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7: wrong fs type, bad option, bad superblock on /dev/xvdbp, missing codepage or helper program, or other error.
Warning FailedMount 22s kubelet, ip-10-237-86-124.ec2.internal MountVolume.MountDevice failed for volume "pvc-50996814-bf53-11e9-848f-0ec61103f6e0" : mount failed: exit status 32
如果我连接到 Kubernetes 工作者,并手动运行相同的命令,我能够重现错误:
$ systemd-run --description='Kubernetes transient mount for /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-068d85e415249b896' --scope -- mount -t xfs -o debug,defaults /dev/xvdcg /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-068d85e415249b896
Running scope as unit run-982245.scope.
mount: /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7: mount point does not exist.
$ mkdir /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7
$ systemd-run --description='Kubernetes transient mount for /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-068d85e415249b896' --scope -- mount -t xfs -o debug,defaults /dev/xvdcg /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-068d85e415249b896
Running scope as unit run-982245.scope.
mount: /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7: wrong fs type, bad option, bad superblock on /dev/xvdbp, missing codepage or helper program, or other error.
$ echo $?
32
我注意到通过debug
从命令中删除该选项并再次运行它,然后卷安装得很好......
$ systemd-run --description='Kubernetes transient mount for /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7' --scope -- mount -t xfs -o defaults /dev/xvdbp /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/aws/us-east-1a/vol-077709885f54252c7
Running scope as unit run-986177.scope.
...然后Pod
几秒钟后运行良好:
Normal Pulled 50s kubelet, ip-10-237-86-124.ec2.internal Container image "nginx:alpine" already present on machine
Normal Created 49s kubelet, ip-10-237-86-124.ec2.internal Created container
Normal Started 46s kubelet, ip-10-237-86-124.ec2.internal Started container
我还注意到,如果我使用ext4
而不是xfs
,上述设置工作正常。
解决方案
过了一会儿,我意识到这个debug
动作是我自己在StorageClass
配置中添加的:
mountOptions:
- debug
在我删除这两行之后,一切都按预期工作。
推荐阅读
- google-cloud-platform - 我检查了我的 OAuth 客户端 ID。它存在!但我收到“OAuth 客户端已删除”。
- java - 为什么我的 Spring MVC 项目中有白标错误页面
- python - 我想让这段代码更短,这可能吗?
- html - 关于使用@media print 时的 Firefox 与 Chrome 打印到 pdf 工具
- docker - Docker compose - 使用 localhost 的容器之间的连接
- jquery - 使用 jQuery 从文档流中删除单选按钮和标签
- python - django fooloop 计数器在新页面中重新启动
- flutter - Flutter的invokeMethod回调是否在App处于后台状态时运行?
- sql-server - 从 SQL Server 调用时,可以传递 Oracle 存储过程的变量 Ref 游标
- azure - 如何在 Log Analytics 中获取弹性池详细信息