我在Kubernetes上使用pod产生了一个非常奇怪的效果:它尝试装入emptyDir
类型的卷,但是没有这样做。窗格的事件列表将显示以下条目:
LAST SEEN FIRST SEEN COUNT NAME KIND SUBOBJECT TYPE REASON SOURCE MESSAGE
2m 10h 281 953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-1530827425856-xbg84.153e978b9b811f46 Pod Warning FailedMount kubelet, ip-172-20-73-118.eu-central-1.compute.internal Unable to mount volumes for pod "953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-1530827425856-xbg84_example(6cfbf40a-809d-11e8-bb05-0227730cc812)": timeout expired waiting for volumes to attach/mount for pod "example"/"953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-1530827425856-xbg84". list of unattached/unmounted volumes=[workspace]
奇怪的是,这在大多数情况下都有效,但是现在已经发生了。这可能是什么原因?以及如何更详细地找出出了什么问题?
更新:根据评论的要求,我在此处添加了广告连播规范:
apiVersion: v1
kind: Pod
metadata:
name: 953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-1530827425856-xbg84
namespace: example
spec:
containers:
- args:
- --context=/workspace/1b5c4fd2-bb39-4096-b055-52dc99d8da0e
- --dockerfile=/workspace/1b5c4fd2-bb39-4096-b055-52dc99d8da0e/Dockerfile-broker
- --destination=registry.example.com:443/example/953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-broker:1530827425856
image: gcr.io/kaniko-project/executor:732a2864f4c9f55fba71e4afd98f4fdd575479e6
imagePullPolicy: IfNotPresent
name: 953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-1530827425856-broker
volumeMounts:
- mountPath: /kaniko/.docker/config.json
name: config-json
subPath: config.json
- mountPath: /workspace
name: workspace
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-mk89h
readOnly: true
- args:
- --context=/workspace/1b5c4fd2-bb39-4096-b055-52dc99d8da0e
- --dockerfile=/workspace/1b5c4fd2-bb39-4096-b055-52dc99d8da0e/Dockerfile-core
- --destination=registry.example.com:443/example/953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-core:1530827425856
image: gcr.io/kaniko-project/executor:732a2864f4c9f55fba71e4afd98f4fdd575479e6
imagePullPolicy: IfNotPresent
name: 953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-1530827425856-core
volumeMounts:
- mountPath: /kaniko/.docker/config.json
name: config-json
subPath: config.json
- mountPath: /workspace
name: workspace
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-mk89h
readOnly: true
- args:
- --context=/workspace/1b5c4fd2-bb39-4096-b055-52dc99d8da0e
- --dockerfile=/workspace/1b5c4fd2-bb39-4096-b055-52dc99d8da0e/Dockerfile-flows
- --destination=registry.example.com:443/example/953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-flows:1530827425856
image: gcr.io/kaniko-project/executor:732a2864f4c9f55fba71e4afd98f4fdd575479e6
imagePullPolicy: IfNotPresent
name: 953fb7fe6825ce398f6243fbe2b2df9400d8cbe0-1530827425856-flows
volumeMounts:
- mountPath: /kaniko/.docker/config.json
name: config-json
subPath: config.json
- mountPath: /workspace
name: workspace
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-mk89h
readOnly: true
initContainers:
- command:
- sh
- -c
- echo ${CONFIG_JSON} | base64 -d > /config-json/config.json
env:
- name: CONFIG_JSON
value: […]
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: store-config-json
volumeMounts:
- mountPath: /config-json
name: config-json
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-mk89h
readOnly: true
restartPolicy: Never
volumes:
- emptyDir: {}
name: config-json
- name: workspace
persistentVolumeClaim:
claimName: example
- name: default-token-mk89h
secret:
defaultMode: 420
secretName: default-token-mk89h
答案 0 :(得分:1)
您不直接在podSpec中使用emptyDir。我建议仅用emptyDir: {}
替换PVC,并检查它是否为您解决了问题。
如果您仍要遵循PVC和PV方法,请提供其清单和说明。也有可能。您在启动了Pod的另一台主机上有一个PVC堆,其中PV带有空目录。