Kubernetes 确定文件写入的默认 Pod 路径

Kubernetes determining default pod path for file write

我希望通过 Elixir 代码写入 Kubernetes pod 上的文件。 Pod 在 /opt/app 处执行时启动,我想将文件写入某个路径,例如 /opt/app/file_tmp.

目前我正在文件中硬编码写入字符串“/opt/app/”并且想知道是否有更好的方法来获取 Kubernetes 主目录所以我不需要硬编码这个字符串在应用程序中?

有没有我可以使用的环境变量,比如 K8S_HOME 或类似的?

wondering if there is a better way to get the Kubernetes home directory so I don't need to hard code this string within the application?

Kubernetes 是容器编排器。您的应用程序在带有文件系统的容器中运行。您在 Dockerfile 中使用 WORKDIR.

设置“工作目录”