admin管理员组文章数量:1287595
How to expand environment variables coming from a secret store and pass them inside a docker container?. Said docker container does not have a shell, therefore it is not possible to run a script. This is the sample yaml file
envFrom:
- secretRef:
name: secret
command: ["my-command"]
args:
- "--env=ENV1=${MY_ENV_VAR1}"
- "--env=env2=${MY_ENV_VAR2}"
How to expand environment variables coming from a secret store and pass them inside a docker container?. Said docker container does not have a shell, therefore it is not possible to run a script. This is the sample yaml file
envFrom:
- secretRef:
name: secret
command: ["my-command"]
args:
- "--env=ENV1=${MY_ENV_VAR1}"
- "--env=env2=${MY_ENV_VAR2}"
Share
Improve this question
edited Feb 25 at 0:40
David Maze
160k45 gold badges243 silver badges287 bronze badges
asked Feb 24 at 18:41
TucanTucan
1721 silver badge11 bronze badges
1
|
1 Answer
Reset to default 3You can pass environment variables to your arguments by using parentheses ()
instead of braces {}
envFrom:
- secretRef:
name: secret
command: ["my-command"]
args:
- "--env=ENV1=$(MY_ENV_VAR1)"
- "--env=env2=$(MY_ENV_VAR2)"
Kubernetes docs have an example here for reference: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#use-environment-variables-to-define-arguments
本文标签: kubernetespassing env variable to docker image from k8 secret storeStack Overflow
版权声明:本文标题:kubernetes - passing env variable to docker image from k8 secret store - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741247323a2365130.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
MY_ENV_VAR1
actually come from? What do you expect to set it? Theargs:
setting sort of suggests the program expects an actual environment variable, can you useenv: [{ name: ENV1, valueFrom: ... }]
to set the variables without trying to wire them through command-line arguments? – David Maze Commented Feb 24 at 19:46