Reputation: 385
I am trying to use envconsul to push environment variables to a docker container running openliberty. The variables are pulled from vault. Consul, Vault and Openliberty application pod is running on minikube. The pod also pulls non-secret variables from a configmap.
As per the logs, the variables get pulled but I cannot view them in the pod when I run env command.
Also the variables from configmap are not available at server start up time, but once the pod is up, an env command displays them.
The application docker file has CMD[./startup.sh].
startup.sh has this command
"/usr/local/bin/envconsul -log-level debug -config "/etc/envconsul/envconsul-config.hcl" /opt/ol/wlp/bin/server run defaultServer"
k logs pod/mp
2019/09/11 19:05:38.723258 [INFO] envconsul v0.9.0 (fd1ee3c7)
2019/09/11 19:05:38.723278 [INFO] (runner) creating new runner (once: false)
2019/09/11 19:05:38.723492 [DEBUG] (runner) final config: 9/09/11 19:05:38.723536 [INFO] (runner) creating watcher
2019/09/11 19:05:38.723615 [INFO] looking at vault secret/myapp/config
2019/09/11 19:05:38.724356 [INFO] (runner) starting
2019/09/11 19:05:38.724379 [DEBUG] (watcher) adding vault.read(secret/myapp/config)
2019/09/11 19:05:38.739500 [DEBUG] (runner) receiving dependency vault.read(secret/myapp/config)
2019/09/11 19:05:38.739527 [INFO] (runner) running
2019/09/11 19:05:38.739562 [DEBUG] (runner) setting USERNAME="appuser" from vault.read(secret/myapp/config)
2019/09/11 19:05:38.739659 [INFO] (child) spawning: /opt/ol/wlp/bin/server run defaultServer
Launching defaultServer (Open Liberty 19.0.0.8/wlp-1.0.31.cl190820190813-1136) on Eclipse OpenJ9 VM, version 1.8.0_222-b10 (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[WARNING ] CWWKG0011W: The configuration validation did not succeed. Value "${env.DB_MF_PORT}" is not a number.
[WARNING ] CWWKG0083W: A validation failure occurred while processing the [portNumber] property, value = [${env.DB_MF_PORT}]. Default value in use: [50000].
[WARNING ] CWWKG0033W: The value [myKeyStore] specified for the reference attribute [keyStoreRef] was not found in the configuration.
[AUDIT ] CWWKS4104A: LTPA keys created in 1.419 seconds. LTPA key file: /opt/ol/wlp/output/defaultServer/resources/security/ltpa.keys
[AUDIT ] CWPKI0803A: SSL certificate created in 2.867 seconds. SSL key file: /opt/ol/wlp/output/defaultServer/resources/security/key.p12
[AUDIT ] CWWKT0016I: Web application available (default_host): http://mp:9080/ibm/api/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://mp:9080/metrics/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://mp:9080/openapi/ui/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://mp:9080/health/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://mp:9080/openapi/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://mp:9080/${app_context_root}/
[AUDIT ] CWWKZ0001I: Application microprofile started in 13.021 seconds.
[AUDIT ] CWWKF0012I: The server installed the following features: [appSecurity-2.0, cdi-2.0, distributedMap-1.0, jaxb-2.2, jaxrs-2.1, jaxrsClient-2.1, jaxws-2.2, jdbc-4.2, jndi-1.0, jpa-2.2, jpaContainer-2.2, json-1.0, jsonp-1.1, monitor-1.0, mpConfig-1.3, mpHealth-2.0, mpMetrics-2.0, mpOpenAPI-1.1, mpRestClient-1.3, servlet-4.0, ssl-1.0].
[AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 23.484 seconds.
Upvotes: 0
Views: 1865
Reputation: 385
I changed the CMD in dockerfile and the config file for envconsul, and now it works
CMD ["/usr/local/bin/envconsul", "-log-level","debug", "-config","/etc/envconsul/envconsul-config.hcl"]
Config file
# This block defines the configuration the the child process to execute and manage.
exec{
# This is the command to execute as a child process. There can be only one command per process.
command = "/opt/ol/wlp/bin/server run defaultServer"
}
Upvotes: 1