<p>I have defined an environment variable for a container from a Configmap, But I want to apply changes automatically when changing the variable value in the ConfigMap.
Maybe we can target an environment variable in volume path !?</p>

<p>In the following lines I'll try to exhibit an idea (It can be considered as solution, at least for the moment), it consist of mounting the configmap values as Volume, </p>

<pre><code>spec:
  containers:
  - name
    ...
    volumeMounts:
      - name: config-volume
        mountPath: /etc/config   #just an example
  volumes:
    - name: config-volume
      configMap:
        name : &lt;name-of-configmap&gt;
        items:
          - key: &lt;key-in-onfigmap&gt;
            path: keys
</code></pre>

<p>As result we will get the value of our configMap Key inside a volume file (/etc/config/keys) we can ensure by executing theses commands </p>

<pre><code>kubectl exec -it &lt;name-of-pod&gt; sh      #to get a shell to the running container/pod
cat /etc/config/keys                   #
</code></pre>

<p>Note : there a delay time from the moment when the ConfigMap is updated to the moment when keys are projected to the pod (it can be as long as kubelet ConfigMap sync period + ttl of ConfigMap cache in kubelet )</p>

<p>Take a look to <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">this</a> to make it more clear, Best regards </p>
