在 Google Cloud Composer 中使用 json 文件导入变量
Import variables using json file in Google Cloud Composer
如何使用命令行将 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 容器内远程执行 airflow variables
。因此,json 文件需要在 Airflow worker/scheduler pod 中可访问。因此,您需要先将 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
.
如何使用命令行将 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 容器内远程执行 airflow variables
。因此,json 文件需要在 Airflow worker/scheduler pod 中可访问。因此,您需要先将 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
.