<p>I would like to ask, what is the preferred way or best way to pass Config file for my app under the following scenario.</p>

<p>My app is developed on NodeJS and i have a JSON file called "config.json" that contains all the config parameters of my application i.e. AD, SMTP, DB etc. a glimpse of the file is like.</p>

<pre><code>{
  "slackIncomingHook": [
    {"HookUrl": "&lt;&lt;HookUrl&gt;&gt;"}
  ],
  "wikiPage": {
    "url": "&lt;&lt;url&gt;&gt;",
    "timeFrame" : "week"
  },
  "database": {
    "dbName": "DBNAME",
    "dbHostName": "mongodb://username:password@&lt;&lt;IP Address&gt;&gt;:27017/"
  }
}
</code></pre>

<p>Now i want to deploy this project using Kubernetes and i want to pass this information to at runtime or somehow merged at the time when the cluster is being built using configMaps.</p>

<p>My DockerFile for this project consists of copying two separate/dependent projects, setting ENV, NPM Installs and exposing PORTS.</p>

<p>PS - the Docker Image is pushed to my Private Repository.</p>

<p>Experts advise would be highly appreciated.</p>

Umer
<p>You can either create a ConfigMap or a Secret e.g.</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: test-config
  namespace: default
data:
  AppConfig.json: |-
    {
      "slackIncomingHook": [
        {"HookUrl": "&lt;&lt;HookUrl&gt;&gt;"}
      ],
      "wikiPage": {
        "url": "&lt;&lt;url&gt;&gt;",
        "timeFrame" : "week"
      },
      "database": {
        "dbName": "DBNAME",
        "dbHostName": "mongodb://username:password@&lt;&lt;IP Address&gt;&gt;:27017/"
      }
    }
</code></pre>

<p>You can create secret also as they are base64 encoded so</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: test-secret
  namespace: default
type: Opaque
data:
  AppConfig.json: |-
     BASE_64_ENCODED_JSON
</code></pre>

<p>In the deployment, add secret/config to volumes node and set volume mounts and mountPath to the path of your config.json.</p>

<pre><code>volumeMounts:
    - name: test-secretm
      mountPath: PATH_OF_YOUR_CONFIG_JSON

volumes:
      - name: test-secretm
        secret:
            secretName: test-secret
</code></pre>
