<p>I am trying to Dockerize the python application and want to read the configuration settings from the configmap. How do I read configmap in python?</p>

One Developer
<p>Create a configMap with the configuration file:</p>
<pre><code>$ kubectl create configmap my-config --from-file my-config.file
</code></pre>
<p>Mount the configMap in your Pod's container and use it from your application:</p>
<pre class="lang-yaml prettyprint-override"><code>        volumeMounts:
        - name: config
          mountPath: &quot;/config-directory/my-config.file&quot;
          subPath: &quot;my-config.file&quot;
      volumes:
        - name: config
          configMap:
            name: my-config
</code></pre>
<p>Now, your config file will be available in <code>/config-directory/my-config.file</code>. You can read it from your Python code like below:</p>
<pre><code>config = open(&quot;/config-directory/my-config.file&quot;, &quot;r&quot;)
</code></pre>
<p>You can also use configMap's data as the container's env - <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data" rel="nofollow noreferrer">Define container environment variables using configMap data</a></p>
<pre><code>config = os.environ['MY_CONFIG']
</code></pre>
