PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, August 20, 2022

[FIXED] How can I get configmap value where the key is dynamic in Kubernetes

 August 20, 2022     configmap, environment-variables, kubernetes, regex     No comments   

Issue

In one of my deployment files, I want to set an environment variable. The variable is KUBE_VERSION and values must be fetched from a ConfigMap.

  kube_1_21: 1.21.10_1550

This is part of ConfigMap where I want to set 1.21.10_1550 to KUBE_VERSION, but if the cluster is of IKS 1.20, then the key will be:

kube_1_20: 1.20.21_3456

kube_ is always static. How can I set environment variable using a regex expression?

Something of this sort:


 - name: KUBE_VERSION
            valueFrom:
              configMapKeyRef:
                 name: cluster-info
                 key: "kube_1*"

Solution

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:

regex used for validation is '[-._a-zA-Z0-9]+')

It follows that you have to enter key as an alphanumeric string and additionally you can use the characters -, _ and . So it is not possible to use regex in this place.

To workaround you can write your custom script i.e. in Bash and replace the proper line with sed command.



Answered By - Mikołaj Głodziak
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing