Skip to content

Document how to import a Docker secret as a configtree #25095

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

Closed
jkroepke opened this issue Feb 3, 2021 · 6 comments
Closed

Document how to import a Docker secret as a configtree #25095

jkroepke opened this issue Feb 3, 2021 · 6 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@jkroepke
Copy link

jkroepke commented Feb 3, 2021

Hi,

Context:

I'm trying to configure a spring boot application using docker secrets. Since spring boot does not support _FILE environment vars out of box. I figure out whats should work out of the box.

Reading spring-projects/spring-framework#21961 I got this: #19990

The configuration is needs a property called keycloak.password. I setup a docker secret called keycloak-password which lives in /var/run/secrets/keycloak-password. As i know, docker secrets are always in /var/run/secrets/, I could not use the wildcard feature of config tree here.

According to https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/html/spring-boot-features.html#boot-features-external-config-files-configtree I configured may application env variables like this:

SPRING_CONFIG_IMPORT='configtree:var/run/secrets/'

but the still missing the keycloak.password property.

While KEYCLOAK_PASSWORD=admin work fine, using KEYCLOAK_PASSWORD=${keycloak-password} raise an error like:

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'keycloak.password' to java.lang.String:

    Property: keycloak.password
    Value: ${keycloak-password}
    Origin: System Environment Property "KEYCLOAK_PASSWORD"
    Reason: Circular placeholder reference 'keycloak-password' in property definitions

Action:

Update your application's configuration

Actual Result

The property keycloak.password isn't configureable via docker secrets. Re-assign the var via environment variables results in Circular placeholder reference.

Expected Result

Configtree should have the same relax binding support as I known form env variables.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 3, 2021
@mbhave
Copy link
Contributor

mbhave commented Feb 3, 2021

Can you expand on why you need to set the environment variable as KEYCLOAK_PASSWORD=${keycloak-password}? If you need a property such as keycloak.password in the environment, the secret would be available at: var/run/secrets/keycloak/password.

@mbhave mbhave added the status: waiting-for-feedback We need additional information before we can continue label Feb 3, 2021
@jkroepke
Copy link
Author

jkroepke commented Feb 3, 2021

I have to check that. As I know the path of secrets for docker secrets is always /run/secrets/<name> (/var/run/secrets/<name> on older versions). Unlike on kubernetes, the path is not configurable.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 3, 2021
@philwebb philwebb added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Feb 3, 2021
@jkroepke
Copy link
Author

jkroepke commented Feb 4, 2021

I figure out, just name the file keycloak.password instead using subfolders will work, too.

Reading the docs, I would expect, define properties with dots via configtree this is only possible trough sub directions.

@jkroepke jkroepke closed this as completed Feb 4, 2021
@wilkinsona wilkinsona removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Feb 4, 2021
@wilkinsona
Copy link
Member

I wonder if we should update the documentation here? I'm not sure that, strictly speaking, what Docker writes out is a configtree so it may get a bit confusing.

@wilkinsona wilkinsona reopened this Feb 4, 2021
@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Feb 4, 2021
@wilkinsona wilkinsona changed the title Relax binding does not work with configtree. raises circular placeholder reference error Consider documenting how to import a Docker secret as a configtree Feb 4, 2021
@wilkinsona wilkinsona added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 4, 2021
@sreenathhari
Copy link

In ur application.properties file you need to add the property
spring.config.import=configtree:var/run/secrets
Then in the same path provided u need to create the secret file with file name as the key which u want to import and file content should be the value of the corresponding property and you can have multiple files in the same location all will be imported as properties to your application on startup.

keycloak.password should be the file name you are creating and the file should contain the secret password

@jkroepke
Copy link
Author

@sreenathhari Thanks!

Everything works already fine and document here: https://github.com/adorsys/keycloak-config-cli#configure-properties-values-through-files

From spring docs, its not known that /var/run/secrets.keycloak worked. By reading the docs I thought the file must be named /var/run/secrets/keycloak.

@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Feb 22, 2021
@philwebb philwebb added this to the 2.4.x milestone Feb 22, 2021
@mbhave mbhave changed the title Consider documenting how to import a Docker secret as a configtree Documenting how to import a Docker secret as a configtree Mar 2, 2021
@mbhave mbhave changed the title Documenting how to import a Docker secret as a configtree Document how to import a Docker secret as a configtree Mar 2, 2021
@mbhave mbhave self-assigned this Mar 4, 2021
@mbhave mbhave closed this as completed in cfac223 Mar 4, 2021
@mbhave mbhave removed this from the 2.4.x milestone Mar 4, 2021
@mbhave mbhave added this to the 2.4.4 milestone Mar 4, 2021
This was referenced Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

6 participants