<p>In Kubernetes, I have the following section in deployment.yaml. I am using ConfigMap and I want to set the path dynamically based on the pod metadata or label or env variable in pod. Does ConfigMap support setting path dynamically?</p>
<pre><code>spec:
                  volumes:
                    - name: configmap
                      configMap:
                        name: devconfig
                        items:
                          - key: config
                            path: $(ENVIRONMENT)
                        defaultMode: 420
</code></pre>

developthou
<p>As an alternative to <a href="https://stackoverflow.com/questions/14155596/how-to-substitute-shell-variables-in-complex-text-files">envsubst</a>, that was absolutely correct answered by @gohm's, you may wanna try to use combination of job, that will check your configmap and pass proper values to your <code>path</code>.</p>
<p>Take a look: <a href="https://stackoverflow.com/questions/65091430/kubernetes-use-environment-variable-configmap-in-persistentvolume-host-path">Kubernetes: use environment variable/ConfigMap in PersistentVolume host path</a></p>
