<p>In one of my deployment files, I want to set an environment variable. The variable is <code>KUBE_VERSION</code> and values must be fetched from a ConfigMap.</p>
<pre><code>  kube_1_21: 1.21.10_1550
</code></pre>
<p>This is part of ConfigMap where I want to set <code>1.21.10_1550</code> to <code>KUBE_VERSION</code>, but if the cluster is of IKS 1.20, then the key will be:</p>
<pre><code>kube_1_20: 1.20.21_3456
</code></pre>
<p><code>kube_</code> is always static. How can I set environment variable using a regex expression?</p>
<p>Something of this sort:</p>
<pre><code>
 - name: KUBE_VERSION
            valueFrom:
              configMapKeyRef:
                 name: cluster-info
                 key: &quot;kube_1*&quot;
</code></pre>

ambikanair
<p>As far as I know it is unfortunately not possible to use the regular expression as you would like. Additionally, you have information about the regular expression that validates the entered data:</p>
<blockquote>
<p>regex used for validation is '[-._a-zA-Z0-9]+')</p>
</blockquote>
<p>It follows that you have to enter <code>key</code> as an alphanumeric string and additionally you can use the characters <code>-</code>, <code>_</code> and <code>.</code> So it is not possible to use regex in this place.</p>
<p>To workaround you can write your custom script i.e. in Bash and replace the proper line with <a href="https://stackoverflow.com/questions/8822097/how-to-replace-a-whole-line-with-sed">sed command</a>.</p>
