<p>I'm ramping up on Docker and k8s, and am running into an issue with a 3rd party application I'm containerizing where the application is configured via flat text files, without override environment variables. </p>

<p>What is the best way to dynamically configure this app? I'm immediately leaning towards a sidecar container that accepts environment variables and writes the text file config, writes it to a shared volume in the pod, and then the application container will read the config file. Is this correct?</p>

<p>What is the best practice here?</p>

<p>Create a <code>ConfigMap</code> with this configuration file. Then, mount the <code>ConfigMap</code> into the pod. This will create the configuration file in mounted directory. Then, you can use this configuration file as usual.</p>

<p>Here are related example: </p>

<ol>
<li><p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files" rel="nofollow noreferrer">Create ConfigMap from file</a>.</p></li>
<li><p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-volume" rel="nofollow noreferrer">Mount ConfigMap as volume</a>.</p></li>
</ol>
