使用Jupyterlab的Pod检索EKS秘密

问题描述

如何从托管jupyterlab的pod内检索Kubernetes机密?我需要访问一个秘密,其中包含火花执行程序容器配置所需的信息。我尝试使用此处给出的答案:

k8s/python: How do I read a secret using the Kubernetes Python client?

但是我遇到了问题。有其他方法还是此答案中没有特别提及的使其有效的必要内容?

解决方法

这些秘密实际上是安装在Pod上的卷。因此,您可以通过这种方式访问​​它们。因此,根据您在哪里安装秘密,您可以仅输入文件名。

例如:

apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  username: xxxx
  password: xxxx

和豆荚

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

✌️

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...