Is there a way to use square bracket on environment variable in kubernetes?

4/16/2020

I have an environment variable like as follows that works with docker-compose.yaml in relation to a springboot container:

    - name: pool.config[0].Number
      value: "2"

This works completely fine in docker-compose.yaml but not in yaml - it keeps giving error:

    a valid environment variable name must consist of alphabetic characters, digits, '_', '-', or'.', and must not start with a digit (e.g. 'my.env-name',  or 'MY_ENV.NAME',  or 'MyEnvName1', regex used for validation is '[-._a-zA-Z][-._a-zA-Z0-9]*')

In docker-compose it's fine with the square brackets in the key name, but in kubernetes deployment spec it's not permitting. How can I work through this?

-- HAi
kubernetes
yaml

1 Answer

4/16/2020

see here and here

You should be able to use following binding for your case: POOL_CONFIG_0__Number

-- Anton Matsiuk
Source: StackOverflow