【问题标题】:Retrieve EKS Secret Using A Pod With Jupyterlab使用带有 Jupyterlab 的 Pod 检索 EKS 机密
【发布时间】:2020-12-19 23:08:41
【问题描述】:

如何从托管 jupyterlab 的 pod 中检索 Kubernetes 机密?我需要访问一个包含 spark executor pod 配置所需信息的秘密。我尝试使用此处给出的答案:

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

但我遇到了问题。是否有其他方法或此答案中没有特别提到的东西是它工作所必需的?

【问题讨论】:

    标签: python kubernetes jupyter-lab kubernetes-secrets


    【解决方案1】:

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

    例如:

    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
    

    ✌️

    【讨论】:

      猜你喜欢
      • 2021-03-21
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 2020-08-21
      • 2019-06-21
      • 2023-04-02
      • 2023-01-15
      • 1970-01-01
      相关资源
      最近更新 更多