-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment Variables from Secrets #1715
Comments
if your put the credential in a secret, then you can use
the secret is then mounted to the pod and its values are made available to the integration thus you can do something like: @BindToRegistry("dataSource")
public BasicDataSource datasoure(
@PropertyInject("db.usr") String usr,
@PropertyInject("db.pwd") String pwd) {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("org.postgresql.Driver");
dataSource.setUrl("jdbc:postgresql://postgres:5432/my-db");
dataSource.setUsername(usr); // <-- from secret
dataSource.setPassword(pwd); // <-- from secret
return dataSource;
} |
btw, note that you can configure the datasource using properties only, see https://camel.apache.org/components/latest/others/main.html#_specifying_custom_beans, in that case you can reference any other property using placeholder
|
Thank you @lburgazzoli, those are both nice options! My confusion is stemming from the fact that normally I can attach a secret to the environment like so:
Then in properties, for say a Quarkus application, I can do My reasoning for this question is I have my DB info in a pre-existing secret:
And I have my properties like so in a config map:
Is it possible to populate the |
So about the
but they are not yet implemented so you either have to pack your credentials as a properties file or you can use some special resolvers, like:
Note 1 you still need to tell kamel to mount the |
🤣 well good news, since it appears to be working! I used it with the It would be very helpful to mention this on the docs for configmap/secret. If I can help by adding this example I'd be happy to do so 👍 Thank you for all your help @lburgazzoli! |
yes please go ahead |
Hi, I'm working on a route where I use a JDBC connector to perform a DB INSERT. I'd like to inject the db connection details from an existing secret and load via
System.getenv("DB_PASS"')
.To configure the datasource I have the following:
With this my
.to("jdbc:datasource")
line is working, but the username and password are plaintext. I could usekamel --env
to inject this, but I don't see how--env
can reference a key in a secret. Is this possible?Perhaps there's a way to set this in the
application.properties
that I am missing?The text was updated successfully, but these errors were encountered: