如何使用命令行将 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 文件导入它。请帮助我解决此问题
以下命令
gcloud composer environments run {environment-name} variables -- --i {path-to-json-file}
在气流包含内远程执行airflow variables
。因此,需要在 Airflow 工作程序/调度程序 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
.