quarkus
quarkus copied to clipboard
Kubernetes extension: Support env vars from secrets with a prefix
Description
Right now you can apply a Secret (or ConfigMap) as environment variables like this:
quarkus.kubernetes.env.secrets=my-secret
This would map all keys of the Secret (or ConfigMap) to the environment of the Kubernetes deployment manifest:
envFrom:
- secretRef:
name: my-secret
However, especially when you're dealing with more than - perhaps - one datasource, it would be great to specify also a prefix. Kubernetes supports adding a prefix to imported keys from Secret / ConfigMap.
envFrom:
- secretRef:
name: my-secret
prefix: DB1_
If my-secret
contains a key called user
it would be mapped to DB1_user
, which you then could use to specify your datasource properties in application.properties
:
%prod.quarkus.datasource.username=${DB1_user:wanja}
It would be great if Quarkus could allow the specification of a prefix inapplication.properties
for example by using this grammar:
quarkus.kubernetes.env.secrets=my-secret[DB1_],my-other-secret[DB2_]
Or by introducing another sub key of env
called prefix
:
quarkus.kubernetes.env.prefix.my-secret=DB1_
Implementation ideas
No response
/cc @geoand (kubernetes), @iocanel (kubernetes)
Seems reasonable to me! WDYT @iocanel?
Hi @wpernath, can I get this one or do you want to work on this issue?
@mcruzdev, please, please take it. -- Thank you!
Thank you @wpernath!
Hi @iocanel and @geoand , I am making some research before implement the solution. Looking the io.dekorate.kubernetes.config.EnvBuilder
, there is no way to configure a prefix
for envFrom
property. I can be doing some mistakes, but if not there is a solution for this one?
@mcruzdev: It's possible that this needs to be implemented in dekorate first. Would you like to give it a try?
Hi @iocanel surely, I will try!
Hi @iocanel, I created the issue on https://github.com/dekorateio/dekorate repo, I will start to work on this tomorrow, thank you!
Hi @iocanel, @wpernath and @geoand I think that the #39782 is done, can you take a look?