稳定/气流连接外部PostgreSQL数据库

时间:2020-10-11 00:08:51

标签: kubernetes airflow kubernetes-helm

我正在使用https://github.com/helm/charts/tree/master/stable/airflow

将气流部署到Kubernetes中

我正在尝试通过修改values.yml连接外部PostgreSQL数据库:

WITH sub AS (
  -- SAME CTEs AS ABOVE
)

SELECT curr_qtr.[Year]
     , curr_qtr.[Report_Date] AS Curr_Qtr_Date
     , curr_qtr.[Sales] AS Curr_Qtr_Sales
     , last_qtr.[Report_Date] AS Last_Qtr_Date
     , last_qtr.[Sales] AS Last_Qtr_Sales
     , curr_qtr.[Sales] - last_qtr.[Sales] AS Diff
     , COALESCE((curr_qtr.[Sales] - last_qtr.[Sales]) / last_qtr.[Sales], 0) AS QoQ
FROM sub curr_qtr
LEFT JOIN sub last_qtr
   ON  curr_qtr.[Year] = last_qtr.[Year]  -- ASSUMING FISCAL YEAR AND NOT CALENDAR YEAR
   AND curr_qtr.[Quarter] = last_qtr.[Quarter] + 1
   AND curr_qtr.[QuarterMonth] = last_qtr.[QuarterMonth]

但是它正在请求externalDatabase: ## the type of external database: {mysql,postgres} ## type: postgres ## the host of the external database ## host: <HOST> ## the port of the external database ## port: 5432 ## the database/scheme to use within the the external database ## database: airflow ## the user of the external database ## user: <USER> ## the name of a pre-created secret containing the external database password ## passwordSecret: "" ## the key within `externalDatabase.passwordSecret` containing the password string ## passwordSecretKey: "" ## the connection properties for external database, e.g. "?sslmode=require" properties: "?sslmode=require" passwordSecret

如何在Kubernetes中创建passwordSecret秘密?

passwordSecretKey是气流用户的密码吗?

1 个答案:

答案 0 :(得分:2)

最简单的方法是遵循步骤here

创建一个名为mysecretcreator.yaml的Yaml文件

apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  username: YWRtaW4=
  password: MWYyZDFlMmU2N2Rm

然后运行kubectl apply -f mysecretcreator.yaml

创建秘密后,将以下内容添加到custom-values.yaml

  ## the name of a pre-created secret containing the external database password
  ##
  passwordSecret: "mysecret"