简体   繁体   English

在 Helm (Kube.netes) 中使用 Values.yaml 设置 airflow 连接

[英]Setting airflow connections using Values.yaml in Helm (Kubernetes)

Airflow Version - 2.3.0 Helm Chart - Apache-airflow/airflow Airflow 版本 - 2.3.0 Helm Chart - Apache-airflow/airflow

I have been working on setting up airflow using helm on kube.netes.我一直致力于在 kube.netes 上使用 helm 设置 airflow。 Currently, I am planning to set airflow connections using the values.yaml file and env variables instead of configuring them up on the webUI.目前,我计划使用 values.yaml 文件和环境变量设置 airflow 连接,而不是在 webUI 上配置它们。

I believe the settings to tweak, to set the connections, are:我相信要调整、设置连接的设置是:

extraSecrets: {}
# eg:
# extraSecrets:
#   '{{ .Release.Name }}-airflow-connections':
#     type: 'Opaque'
#     data: |
#       AIRFLOW_CONN_GCP: 'base64_encoded_gcp_conn_string'
#       AIRFLOW_CONN_AWS: 'base64_encoded_aws_conn_string'
#     stringData: |
#       AIRFLOW_CONN_OTHER: 'other_conn'
#   '{{ .Release.Name }}-other-secret-name-suffix':
#     data: |
#        ...

I am not sure how to set all the key-value pairs for a databricks/emr connection, and how to use the kube.netes secrets (already set up as env vars in pods) to get the values我不确定如何为 databricks/emr 连接设置所有键值对,以及如何使用 kube.netes 秘密(已在 pod 中设置为环境变量)来获取值

#extraSecrets:
#  '{{ .Release.Name }}-airflow-connections':
#    type: 'Opaque'
#    data:
#      AIRFLOW_CONN_DATABRICKS_DEFAULT_two:
#         conn_type: "emr"
#         host: <host_url>
#         extra:
#          token: <token string>
#          host: <host_url>

It would be great to get some insights on how to resolve this issue很高兴获得有关如何解决此问题的一些见解

I looked up this link: managing_connection on airflow我查找了这个链接: airflow 上的 managing_connection

Tried Changes in values.yaml file:尝试更改 values.yaml 文件:

#extraSecrets:
#  '{{ .Release.Name }}-airflow-connections':
#    type: 'Opaque'
#    data:
#      AIRFLOW_CONN_DATABRICKS_DEFAULT_two:
#         conn_type: "emr"
#         host: <host_url>
#         extra:
#          token: <token string>
#          host: <host_url>

Error Occurred: While updating helm release: extraSecrets.{{.Release.Name }}-airflow-connections expects string, got object发生错误:更新 helm 版本时: extraSecrets.{{.Release.Name }}-airflow-connections expects string, got object

Airflow connections can be set using Kube.netes secrets and env variables. Airflow 连接可以使用 Kube.netes 秘密和 env 变量设置。

For setting secrets, directly from the cli, the easiest way is to要直接从 cli 设置机密,最简单的方法是

  • Create a kube.netes secret创建一个 kube.netes 秘密

    • The secret value (connection string) has to be in the URI format suggested by airflow秘密值(连接字符串)必须采用 airflow 建议的 URI 格式

      my-conn-type://login:password@host:port/schema?param1=val1&param2=val2

  • Create an env variable in the airflow-suggested-format以 airflow-suggested-format 创建一个环境变量

    • Airflow format for connection - AIRFLOW_CONN_{connection_name in all CAPS} Airflow 连接格式 - AIRFLOW_CONN_{connection_name in all CAPS}
  • set the value of the connection env variable using the secret使用秘密设置连接环境变量的值

How to manage airflow connections: here如何管理 airflow 连接: 这里

Example, To set the default databricks connection (databricks_default)in airflow -例如,在 airflow 中设置默认数据块连接 (databricks_default) -

  • create secret创建秘密
    kubectl create secret generic airflow-connection-databricks \
        --from-literal=AIRFLOW_CONN_DATABRICKS_DEFAULT='databricks://@<DATABRICKS_HOST>?token=<DATABRICKS_TOKEN>'
  • In helm's (values.yaml), add new env variable using the secret:在 helm 的 (values.yaml) 中,使用秘密添加新的环境变量:
    envName: "AIRFLOW_CONN_DATABRICKS_DEFAULT"
                secretName: "airflow-connection-databricks"
                secretKey: "AIRFLOW_CONN_DATABRICKS_DEFAULT"

Some useful links:一些有用的链接:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM