我如何找出为什么成功的 kubernetes MountVolume 设置不会在 docker 容器中产生任何装载?
How can I find out why a succesful kubernetes MountVolume step doesnt result in any Mounts in a docker container?
我定义了一个挂载点:
- name: dir-graphite
configMap:
name: hub-logstash-grafana
items:
- key: logstash.conf.file
path: config
随后的卷声明:
volumes:
volumeMounts:
- mountPath: "/opt/blackduck/hub/logs"
name: dir-webapp
- mountPath: "/var/lib/logstash/data"
name: dir-logstash
- mountPath: "/tmp/x"
name: dir-graphite
在 kubernetes 1.6.6 中,我看到
Aug 05 02:02:59 ip-10-0-26-84 kubelet[30344]: I0805 02:02:59.912640 30344 operation_generator.go:597]
MountVolume.SetUp succeeded for volume "kubernetes.io/configmap/a47ebff8-7976-11e7-8369-12207729cdd2-dir-graphite" (spec.Name: "dir-graphite") pod "a47ebff8-7976-11e7-8369-12207729cdd2" (UID: "a47ebff8-7976-11e7-8369-12207729cdd2").
也就是说,我可以看到我的配置映射的挂载设置操作成功,但是,当我检查实际创建的容器时,我没有看到关联的挂载:
"Mounts": [
{
"Source": "/var/lib/kubelet/pods/a47ebff8-7976-11e7-8369-12207729cdd2/etc-hosts",
"Destination": "/etc/hosts",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Source": "/var/lib/kubelet/pods/a47ebff8-7976-11e7-8369-12207729cdd2/containers/logstash/86b079de",
"Destination": "/dev/termination-log",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Source": "/var/lib/kubelet/pods/a47ebff8-7976-11e7-8369-12207729cdd2/volumes/kubernetes.io~secret/default-token-2t0cl",
"Destination": "/var/run/secrets/kubernetes.io/serviceaccount",
"Mode": "ro",
"RW": false,
"Propagation": "rprivate"
}
以下片段确实正确:
31 containers:
32 - image: blackducksoftware/hub-logstash:4.0.0
33 name: logstash
34 volumeMounts:
35 - name: dir-graphite
36 mountPath: /tmp/x
我相信在 1.6 中,如果你有一个小的缩进,验证不是很严格,所以你会得到一个空操作,其中加载了一个卷,但不一定读取装载路径进入任何东西。
郑重声明,如果卷确实已附加,您应该在 运行 docker 检查时在挂载点中看到它:
"Mounts": [
{
"Source": "/var/lib/kubelet/pods/bf655bb7-7985-11e7-8369-12207729cdd2/volumes/kubernetes.io~configmap/dir-graphite",
"Destination": "/tmp/x",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
故事的寓意:对于 ConfigMaps(以及可能由 kubelet 延迟安装的任何其他卷),kubelet 级别的成功 MountVolume.SetUp 日志并不能保证您的文件是安装到容器中,相反,这仅意味着 kubelet 能够创建一个与您定义的 ConfigMap 卷之一对应的卷。
我定义了一个挂载点:
- name: dir-graphite
configMap:
name: hub-logstash-grafana
items:
- key: logstash.conf.file
path: config
随后的卷声明:
volumes:
volumeMounts:
- mountPath: "/opt/blackduck/hub/logs"
name: dir-webapp
- mountPath: "/var/lib/logstash/data"
name: dir-logstash
- mountPath: "/tmp/x"
name: dir-graphite
在 kubernetes 1.6.6 中,我看到
Aug 05 02:02:59 ip-10-0-26-84 kubelet[30344]: I0805 02:02:59.912640 30344 operation_generator.go:597]
MountVolume.SetUp succeeded for volume "kubernetes.io/configmap/a47ebff8-7976-11e7-8369-12207729cdd2-dir-graphite" (spec.Name: "dir-graphite") pod "a47ebff8-7976-11e7-8369-12207729cdd2" (UID: "a47ebff8-7976-11e7-8369-12207729cdd2").
也就是说,我可以看到我的配置映射的挂载设置操作成功,但是,当我检查实际创建的容器时,我没有看到关联的挂载:
"Mounts": [
{
"Source": "/var/lib/kubelet/pods/a47ebff8-7976-11e7-8369-12207729cdd2/etc-hosts",
"Destination": "/etc/hosts",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Source": "/var/lib/kubelet/pods/a47ebff8-7976-11e7-8369-12207729cdd2/containers/logstash/86b079de",
"Destination": "/dev/termination-log",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Source": "/var/lib/kubelet/pods/a47ebff8-7976-11e7-8369-12207729cdd2/volumes/kubernetes.io~secret/default-token-2t0cl",
"Destination": "/var/run/secrets/kubernetes.io/serviceaccount",
"Mode": "ro",
"RW": false,
"Propagation": "rprivate"
}
以下片段确实正确:
31 containers:
32 - image: blackducksoftware/hub-logstash:4.0.0
33 name: logstash
34 volumeMounts:
35 - name: dir-graphite
36 mountPath: /tmp/x
我相信在 1.6 中,如果你有一个小的缩进,验证不是很严格,所以你会得到一个空操作,其中加载了一个卷,但不一定读取装载路径进入任何东西。
郑重声明,如果卷确实已附加,您应该在 运行 docker 检查时在挂载点中看到它:
"Mounts": [
{
"Source": "/var/lib/kubelet/pods/bf655bb7-7985-11e7-8369-12207729cdd2/volumes/kubernetes.io~configmap/dir-graphite",
"Destination": "/tmp/x",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
故事的寓意:对于 ConfigMaps(以及可能由 kubelet 延迟安装的任何其他卷),kubelet 级别的成功 MountVolume.SetUp 日志并不能保证您的文件是安装到容器中,相反,这仅意味着 kubelet 能够创建一个与您定义的 ConfigMap 卷之一对应的卷。