<p>I have a large set of <strong>read-only</strong> configuration files (around 4k) which is used by the microservice to process some XML files and supposed to be read via <strong>Apache Commons Configuration</strong>.</p>

<p>These files are of the following types: </p>

<ul>
<li>Properties file</li>
<li>XML</li>
<li>dtd</li>
<li>xfo</li>
<li>xslt</li>
</ul>

<p>5 of these files will need some environment variables to be substituted in their content, such as third party software location, or different services URL based on the environment the files are deployed in.</p>

<p>Now, I need to make these files available for 4 microservices at run time.</p>

<p>I'm using fabric8.io maven docker plugin with dockerfile for image generation.
Kubernetes, helm, Jenkinsfile, and ArgoCD for the spring-boot microservices CD/CI.</p>

<p>The 2 challenges that I'm facing is how to substitute the variables inside of these static files, and how to make these files available for each pod.</p>

<p>I have three solutions in mind but <strong>I would like to know what is the best/optimal 12-factor approach for this problem.</strong></p>

<p>Solution 1: is to deploy the files as a separate pod and allow other pods to access to some volume mount that it provides.</p>

<p>Solution  2: Add the files to the microservice image during the docker image build.</p>

<p>Solution  3: Add the files as a container of each microservice pod.</p>

Jalal Sordo
<p>You could upload this file to a kubernetes ConfigMap.</p>

<blockquote>
  <p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/</a></p>
</blockquote>

<pre><code>apiVersion: v1
kind: ConfigMap
data:
  haproxy.cfg: "complete file contents" 
</code></pre>

<p>It can contain entire file, and mount this file in a pod directory</p>

<pre><code>    volumeMounts:
      - mountPath: /usr/local/etc/haproxy
        name: config
  volumes:
    - name: config
      configMap:
        name: env-config-haproxy
        items:
          - key: haproxy.cfg
            path: haproxy.cfg
</code></pre>
