gpt4 book ai didi

python - 使用带有 Jupyterlab 的 Pod 检索 EKS secret

转载 作者:行者123 更新时间:2023-12-02 11:38:33 26 4
gpt4 key购买 nike

如何从托管 jupyterlab 的 Pod 中检索 Kubernetes secret ?我需要访问一个包含 spark executor pod 配置所需信息的 secret 。我尝试使用此处给出的答案:
k8s/python: How do I read a secret using the Kubernetes Python client?
但我遇到了问题。是否有其他方法或此答案中没有特别提到的东西是它工作所必需的?

最佳答案

这些 secret 实际上是安装在您的 Pod 上的卷。因此,您可以通过这种方式访问​​它们。因此,根据您安装 secret 的位置,您可以只使用文件名。
例如:

apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
username: xxxx
password: xxxx
和 pod
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: mypod
image: redis
volumeMounts:
- name: foo
mountPath: "/etc/foo"
readOnly: true
volumes:
- name: foo
secret:
secretName: mysecret
可以看到内容:
cat /etc/foo/data
如果是 Opaque您可以使用 base64 对其进行解码
cat /etc/foo/data | base64 -d
✌️

关于python - 使用带有 Jupyterlab 的 Pod 检索 EKS secret ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63677434/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com