pods 是否共享文件系统,类似于它们共享同一网络命名空间的方式?

Do pods share the filesystems, similar to how they share same network namespace?

我创建了一个包含两个容器的 pod。我知道 pod 中的不同容器共享相同的网络名称 space(即相同的 IP 和端口 space),并且还可以通过配置映射在它们之间共享存储卷。我的问题是 pods 是否也共享相同的文件系统。例如,在我的例子中,我有一个容器 'C1' 每 10 分钟在 /var/targets.yml 中生成一个动态文件,我希望另一个容器 'C2' 读取这个文件并执行它的自己的独立行动。

有没有办法做到这一点,可能是通过 configmaps 的一些解决方法?或者我是否必须通过网络访问这些文件,因为每个容器都有自己的 IP(但这在 POD 重启时可能不是一个好主意)。请问有什么建议或参考吗?

您可以为此使用 emptyDir

apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: gcr.io/google_containers/test-webserver
    name: generating-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  - image: gcr.io/google_containers/test-webserver
    name: consuming-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  volumes:
  - name: cache-volume
    emptyDir: {}

但请注意,数据在容器重建期间不是持久的。