<p>I have a postgres instance that I generally spin up using a <code>docker-compose.yml</code> file. It mounts some configuration files like this:</p>
<pre><code>    volumes:
      - postgres-volume:/var/lib/postgresql/data
      - ./postgresql.conf:/etc/postgresql.conf
      - ./logs:/logs
      - ./pg_hba.conf:/etc/pg_hba.conf
</code></pre>
<p>These files are located in the same folder as the <code>docker-compose.yml</code> file is.</p>
<p>My question is: how do I make a Pod that contains this container also mount these configuration files? I read something about PVC in Kubernetes but I'm having a hard time connecting the dots and going from the docker-compose way of thinking to the Kubernetes way of thinking.</p>
<p>Any help is greatly appreciated.</p>

Leon Held
<p>Easiest approach would be to store the files in a <code>ConfigMap</code> and mount those as volumes in the container.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config
data:
  my.properties: |
    url=example.com
    username=username
    password=password
  index.html: |
    Hello world
</code></pre>
<pre class="lang-yaml prettyprint-override"><code>[...]
  containers:
    - name: my-container
      image: some-registry/some-image
      volumeMounts:
      - name: config-volume
        mountPath: /etc/config/my.properties
        subPath: my.properties
      - name: config-volume
        mountPath: /some/different/path/index.html
        subPath: index.html
  volumes:
    - name: config-volume
      configMap:
        name: my-config
[...]
</code></pre>
<p>By that the <code>my.properties</code> file is mounted into <code>/etc/config</code> and <code>index.html</code> into <code>/some/different/path</code> of the <code>my-container</code> file system.</p>
<p>You can also generate the configmap from the file by <code>kubectl create configmap my-config --from-file /path/to/my.properties --from-file /path/to/index.html</code></p>
<p>See <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">docs</a> for more info on that.</p>
