Search code examples
kubernetesdeploymentkubernetes-pod

Kubernetes determining default pod path for file write


I am looking to write to a file on a Kubernetes pod through Elixir code. The pod starts off when exec'ing in at /opt/app and I want to write a file to some path like /opt/app/file_tmp.

Currently I am hard coding in the file writing the string "/opt/app/" and was 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?

Is there something env variable I can use like K8S_HOME or similar?


Solution

  • 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 is the container orchestrator. Your app runs in a container with its filesystem. You set the "working directory" in your Dockerfile with WORKDIR.