google-cloud-platform - 在 Google Cloud Composer 中使用 json 文件导入变量
问题描述
如何使用命令行将 json 文件导入 Google Cloud Composer?
我尝试了以下命令
gcloud composer environments run comp-env --location=us-central1 variables -- --import composer_variables.json
我收到以下错误
[2019-01-17 13:34:54,003] {configuration.py:389} INFO - Reading the config from /etc/airflow/airflow.cfg
[2019-01-17 13:34:54,117] {app.py:44} WARNING - Using default Composer Environment Variables. Overrides have not been applied.
Missing variables file.
但是,当我使用以下命令设置单个变量时,它工作正常。
gcloud composer environments run comp-env --location=us-central1 variables -- --set variable_name variable_value
由于我要导入的变量超过 75 个,因此我们需要使用 json 文件导入它。请帮我解决这个问题
解决方案
以下命令在 Airflow 容器内远程gcloud composer environments run {environment-name} variables -- --i {path-to-json-file}
执行。airflow variables
因此,需要在 Airflow worker/scheduler pod 中访问 json 文件。因此,您需要var.json
先将您的复制到 GCS,然后运行该命令。例如:
gcloud composer environments storage data import --source=your-var.json --environment={environment-name} --location={location}
gcloud composer environments run {environment-name} --location={location} variables -- --i /home/airflow/gcs/data/your-var.json
.
推荐阅读
- visual-studio-code - Bash终端不允许打字
- java - JSON字符串到JAXB java对象解组
- docker - docker-compose mariadb docker-entrypoint-initdb.d sql 未执行
- maven - “mvn”命令未被识别为内部或外部命令,正在工作
- nuxt.js - 调用异步方法时不是函数错误吗?
- node.js - 获取 req.user.following 未定义
- python - 更改绘图表达树形图的悬停文本
- rest - 如果我们的服务器使用 RESTful API,一致性散列没有用吗?
- oracle - Oracle apex 审计所有活动
- sas - 在 SAS University Edition 中使用库