【问题标题】:Use kubernetes secret with GKEPodOperator in Airflow在 Airflow 中将 kubernetes secret 与 GKEPodOperator 一起使用
【发布时间】:2020-04-08 21:23:27
【问题描述】:

我正在尝试将 GOOGLE_APPLICATION_CREDENTIALS 机密与 GKEPodOperator 一起使用。 基本上我想: 1.上传秘钥到GKE 2. 将秘密挂载(?)到容器中 3.运行容器时使用秘钥。

到目前为止,我已经在构建时将 key.json 文件添加到我的图像中,我知道这不是正确的方法。

我发现了这个问题:How to set GOOGLE_APPLICATION_CREDENTIALS on GKE running through Kubernetes

不同之处在于他们没有使用 GKEPodOperator。

我做了什么: 1. 使用以下方法创建秘密:

kubectl create secret generic mysupersecret --from-file=service_account_key=key.json

我看到有volumesvolume_mounts 参数,但我不明白如何使用它们。

谁能帮我解决这个问题?也许我要做一些愚蠢的事情..

【问题讨论】:

    标签: kubernetes google-kubernetes-engine airflow kubernetes-secrets docker-secrets


    【解决方案1】:

    To use a Secret with your workloads, you can specify environment variables that reference the Secret's values, or mount a volume containing the Secret. 请按照此link 使用机密并设置volumes 和volume_mounts。

    此链接 refer 到 Google 通用文档,用于使用服务帐户向 Cloud Platform 进行身份验证以使用 GOOGLE_APPLICATION_CREDENTIALS 密钥。而这个link 描述了如何使用 KubernetesPodOperator 来启动 Kubernetes pod。

    【讨论】:

      【解决方案2】:

      这类似于将秘密传递给KubernetesPodOperatorCheck details here.

      这里是快速示例。

      influx_username = secret.Secret(
      ...
      )
      influx_pass = secret.Secret(
      ...
      )
      operator = GKEPodOperator(
          task_id='task-id',
          project_id='prj-id',
          location='location',
          cluster_name='cluster-name',
          name='pod-name',
          namespace='default',
          image='image-path',
          secrets=[influx_username, influx_pass],
      )
      

      【讨论】:

        猜你喜欢
        • 2021-02-26
        • 1970-01-01
        • 1970-01-01
        • 2019-06-10
        • 2022-07-06
        • 2020-09-29
        • 2023-02-01
        • 2020-06-05
        • 1970-01-01
        相关资源
        最近更新 更多