<p>I have an existing configuration file in JSON format, something like below</p>

<pre><code>{
    "maxThreadCount": 10,
    "trackerConfigs": [{
            "url": "https://example1.com/",
            "username": "username",
            "password": "password",
            "defaultLimit": 1
        },
        {
            "url": "https://example2.com/",
            "username": "username",
            "password": "password",
            "defaultLimit": 1
        }
    ],
    "repoConfigs": [{
        "url": "https://github.com/",
        "username": "username",
        "password": "password",
        "type": "GITHUB"
    }],
    "streamConfigs": [{
        "url": "https://example.com/master.json",
        "type": "JSON"
    }]
}
</code></pre>

<p>I understand that I am allowed to pass key/value pair properties file with --from-file option for configmap and secret creation. </p>

<p>But How about JSON formatted file ? Does Kubernetes take JSON format file as input file to create configmap and secret as well? </p>

<pre><code>$ kubectl create configmap demo-configmap --from-file=example.json
</code></pre>

<p>If I run this command, it said configmap/demo-configmap created. But how can I refer this configmap values in other pod ? </p>

<p>When you create configmap/secret using <code>--from-file</code>, by default the file name will be the key name and content of the file will be the value. </p>

<p>For example, You created configmap will be like</p>

<pre><code>apiVersion: v1
data:
  test.json: |
    {
        "maxThreadCount": 10,
        "trackerConfigs": [{
                "url": "https://example1.com/",
                "username": "username",
                "password": "password",
                "defaultLimit": 1
            },
            {
                "url": "https://example2.com/",
                "username": "username",
                "password": "password",
                "defaultLimit": 1
            }
        ],
        "repoConfigs": [{
            "url": "https://github.com/",
            "username": "username",
            "password": "password",
            "type": "GITHUB"
        }],
        "streamConfigs": [{
            "url": "https://example.com/master.json",
            "type": "JSON"
        }]
    }
kind: ConfigMap
metadata:
  creationTimestamp: "2020-05-07T09:03:55Z"
  name: demo-configmap
  namespace: default
  resourceVersion: "5283"
  selfLink: /api/v1/namespaces/default/configmaps/demo-configmap
  uid: ce566b36-c141-426e-be30-eb843ab20db6
</code></pre>

<p>You can mount the configmap into your pod as volume. where the key name will be the file name and value will be the content of the file. like following</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  containers:
    - name: test-container
      image: k8s.gcr.io/busybox
      command: [ "/bin/sh", "-c", "ls /etc/config/" ]
      volumeMounts:
      - name: config-volume
        mountPath: /etc/config
  volumes:
    - name: config-volume
      configMap:
        name: demo-configmap
  restartPolicy: Never
</code></pre>

<p>When the pod runs, the command ls <code>/etc/config/</code> produces the output below:</p>

<p><code>test.json</code></p>
