quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

kubernetes env var Nested environment variable not supported #35260

Open matter-it-does opened 1 year ago

matter-it-does commented 1 year ago

Describe the bug

support nested quarkus environment variables.

At build time, if the env var is present like

QUARKUS_KUBERNETES_ENV_VARS__QUARKUS_REST_CLIENT__EXTERNAL_SERVICE__URL__=http://example.com

then at runtime in the pod, the env var should be present like

QUARKUS_REST_CLIENT__EXTERNAL_SERVICE__URL=http://example.com

this way config map etc can be sidestepped to set url for the rest client with config-key: "external-service"

quarkus.rest-client."config-key".url is the property

https://quarkus.io/guides/all-config#quarkus-rest-client-config_quarkus.rest-client.-config-key-.url

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

Run this command for this example folder. qr_k8s_env_bug.zip

source ./source.sh && env &&  mvn package -DskipTests=true

Output of uname -a or ver

macos

Output of java -version

17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.1.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @Sgitario (kubernetes), @geoand (kubernetes), @iocanel (kubernetes)

Sgitario commented 1 year ago

@radcortez can you confirm if this is supported or not? I guess what @matter-it-does is trying to achieve is to provide the following property: quarkus.kubernetes.env.vars."quarkus.rest-client."external-service".url=http://example.com. The problematic part is the second .".

radcortez commented 1 year ago

Yes, it is possible. You need to provide either combination:

quarkus.kubernetes.env.vars."quarkus.rest.client".external.service.url=
QUARKUS_KUBERNETES_ENV_VARS__QUARKUS_REST_CLIENT__EXTERNAL_SERVICE_URL=http://example.com

or

quarkus.kubernetes.env.vars."quarkus.rest.client".external.service."url"=
QUARKUS_KUBERNETES_ENV_VARS__QUARKUS_REST_CLIENT__EXTERNAL_SERVICE__URL__=http://example.com

Note that you need to provide the dotted format of the environment variable name to disambiguate dynamic segments in the name. Please check: https://quarkus.io/guides/config-reference#environment-variables

Sgitario commented 1 year ago

Yes, it is possible. You need to provide either combination:

quarkus.kubernetes.env.vars."quarkus.rest.client".external.service.url=
QUARKUS_KUBERNETES_ENV_VARS__QUARKUS_REST_CLIENT__EXTERNAL_SERVICE_URL=http://example.com

or

quarkus.kubernetes.env.vars."quarkus.rest.client".external.service."url"=
QUARKUS_KUBERNETES_ENV_VARS__QUARKUS_REST_CLIENT__EXTERNAL_SERVICE__URL__=http://example.com

Note that you need to provide the dotted format of the environment variable name to disambiguate dynamic segments in the name. Please check: https://quarkus.io/guides/config-reference#environment-variables

Many thanks @radcortez !

matter-it-does commented 1 year ago

@radcortez hi! I attached a repro with both of your suggested approaches. Please take a look on why neither worked.

radcortez commented 1 year ago

Hum... this is how it is supposed to work, but it seems that the inner key quotes are getting discarded at some point. I need to investigate further.

For now, please use rest client names with a single segment.