如何在Kubernetes env vars中添加金库秘密?
我正在使用oauth2-proxy
使用外部OIDC提供商进行身份验证的Helm图表,以及存储库来存储秘密。现在,为了将其传递client-id
& client-secret
存储在保险库中的秘密,我遵循此链接 - https://www.vaultproject.io/docs/platform/k8s/inject/injementor/examples/examples#environment-varible-varible-example-example-a>
这表明如何在容器中添加这些秘密, ,但是oauth2-proxy
需要这些变量首先启动(它们以args的形式传递给Docker Image的入口点)。我还尝试将源命令添加到PostStart
生命周期方法,但这也会给出以下错误 -
Exec lifecycle hook ([sh -c source /vault/secrets/oidc.sh]) for Container "oauth2-proxy" in Pod "oauth2-proxy-f6c8f7b69-kgjws_istio-system(7e488c12-2964-496f-a658-47739fcf3695)" failed - error: command 'sh -c source /vault/secrets/oidc.sh' exited with 126: , message: "OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown\r\n"
我认为这是因为Docker Image的入口点需要这些Env vars,并且该容器在该命令失败。还有其他方法吗?
I am using the OAuth2-Proxy
helm chart which is authenticating using an external oidc provider, along with Vault to store the secrets. Now, in order to pass it the client-id
& client-secret
secrets stored in Vault, I followed this link - https://www.vaultproject.io/docs/platform/k8s/injector/examples#environment-variable-example
This shows how to add these secrets as env vars in a container, but OAuth2-Proxy
needs these variables to start in the first place (They are passed as args to the docker image's entrypoint). I also tried adding the source command to the postStart
lifecycle method but that also gives the following error -
Exec lifecycle hook ([sh -c source /vault/secrets/oidc.sh]) for Container "oauth2-proxy" in Pod "oauth2-proxy-f6c8f7b69-kgjws_istio-system(7e488c12-2964-496f-a658-47739fcf3695)" failed - error: command 'sh -c source /vault/secrets/oidc.sh' exited with 126: , message: "OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown\r\n"
I think this is because the docker image's entry-point requires those env vars and the container dies off as soon as that command fails. Is there any other approach for doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种使用 Vault Agent Injector 方法
首先,应创建一个模板,以将保险库秘密作为环境变量导出。
并且应用程序容器应在启动过程中摘下这些文件。
Here is a way to inject vault secrets into the k8s pod as ENV vars using vault Agent Injector method
First A template should be created that exports a Vault secret as an environment variable.
And the application container should source those files during startup.