【发布时间】:2021-02-11 00:30:21
【问题描述】:
我有一个带有两个容器的简单 StatefulSet。我只想通过 emptyDir 卷共享路径:
volumes:
- name: shared-folder
emptyDir: {}
第一个容器是busybox:
- image: busybox
name: test
command:
- sleep
- "3600"
volumeMounts:
- mountPath: /cache
name: shared-folder
第二个容器在 /cache/
volumeMounts:
- name: shared-folder
mountPath: /cache/$(HOSTNAME)
问题。第二个容器没有解析 /cache/$(HOSTNAME),所以它不是挂载 /cache/pod-0,而是挂载 /cache/$(HOSTNAME)。我也尝试过获取 POD_NAME 并将其设置为 env 变量,但它也没有解决它。
有人知道是否可以在 mountPath 属性中使用这样的路径(带有环境变量)?
【问题讨论】:
标签: kubernetes kubernetes-statefulset