<p>I am reading the configuration details from the configmap as shown below</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  namespace: akv2k8s-test
  name: akv2k8s-test
data:
  Log_Level: Debug
  Alert_Email: Test@demo.com
</code></pre>
<p>pod definition</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: akv2k8s-test
  namespace: akv2k8s-test
spec:
  containers:
    - name: akv2k8s-env-test
      image: kavija/python-env-variable:latest
      envFrom:
        - configMapRef:
            name: akv2k8s-test
</code></pre>
<p>and reading it with python</p>
<pre><code>import os
loglevel = os.environ['Log_Level']
alertemail = os.environ['Alert_Email']
print(&quot;Running with Log Level: %s, Alert Email:%s&quot; % (loglevel,alertemail))
</code></pre>
<p>I want to update the Configuration values while deploying, the below command fails</p>
<pre><code>kubectl apply -f deploy.yaml --env=&quot;Log_Level=error&quot;
</code></pre>
<p>How do I pass the environment variable while deploying?</p>

One Developer
<p>Since you want to update the configmap <strong>while deplyoing</strong>, The easiest way would be by getting the file content using cat and then update as you wish -</p>
<pre class="lang-sh prettyprint-override"><code>cat configmap.yaml |sed -e 's|Log_Level: Debug|Log_Level: error|' | kubectl apply -f -
</code></pre>
<p>In case you want to update the <strong>existing configmap</strong>, use <code>kubectl patch</code> command.</p>
<pre class="lang-sh prettyprint-override"><code>kubectl patch configmap/akv2k8s-test -n akv2k8s-test --type merge -p '{&quot;data&quot;:{&quot;Log_Level&quot;:&quot;error&quot;}}'
</code></pre>
