我正在使用OAuth2-Proxy舵机图表,它使用外部oidc提供商进行身份验证,并与Vault一起存储秘密。现在,为了传递存储在Vault中的client-id & client-secret秘密,我遵循了这个链接- https://www.vaultproject.io/docs/platform/k8s/injector/examples#environment-variable-example。
这说明了如何将这些秘密作为env添加到容器中,但是OAuth2-Proxy首先需要启动这些变量(它们作为args传递到坞映像的入口点)。我还尝试将源命令添加到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"我认为这是因为码头映像的入口点需要那些entry,容器一旦命令失败就会关闭。还有其他方法可以做到吗?
发布于 2022-07-15 09:55:13
下面是一种使用k8s保险代理注入器( Injector )方法将保险库秘密作为ENV注入舱的方法
首先,应该创建一个模板,作为环境变量导出一个Vault秘密。
spec: template:
metadata:
annotations:
# Environment variable export template
vault.hashicorp.com/agent-inject-template-config: |
{{ with secret "secret/data/web" -}}
export api_key="{{ .Data.data.payments_api_key }}"
{{- end }}应用程序容器应该在启动过程中找到这些文件。
args:
['sh', '-c', 'source /vault/secrets/config && <entrypoint script>']https://stackoverflow.com/questions/72487297
复制相似问题