【发布时间】:2022-01-03 18:05:44
【问题描述】:
我的问题与这个问题相同:k8s/python: How do I read a secret using the Kubernetes Python client? 但来自 Kubernetes 内部。我知道如何使用 kubernetes python 客户端从外部访问机密。
但是在 kubernetes 中如何访问 python 中的秘密?我有几个 python 微服务,它们都应该从 kubernetes 中访问秘密。
根据官方文档https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#create-a-pod-that-has-access-to-the-secret-data-through-environment-variables我可以创建环境变量。然后可以通过import os; os["MY_VAR"] 访问这些变量吗?
【问题讨论】:
标签: python kubernetes kubernetes-secrets