
Airflow의 다양한 고급 기능과 CI/CD 환경 설정에 대해 학습 (2)
먼저 스프레드 시트 우측 상단 공유버튼 누름
앞서 구글 서비스 어카운트에서 찾은 이메일을 공유 (+ 권한 설정)
airflow.cfg의 api 섹션에서 auth_backend의 값을 변경[api]
auth_backend = airflow.api.auth.backend.basic_auth
docker-compose.yaml에는 이미 설정이 되어 있음 (environments)AIRFLOW__API__AUTH_BACKENDS: 'airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session'
airflow config get-value api auth_backend
curl -X GET --user "monitor:MonitorUser1" http://localhost:8080/health
정상 경우 응답:
{
"metadatabase": {
"status": "healthy"
},
"scheduler": {
"status": "healthy",
"latest_scheduler_heartbeat": "2022-03-12T06:02:38.067178+00:00"
}
}
curl -X POST --user "airflow:airflow" -H 'Content-Type: application/json' -d
'{"execution_date":"2023-05-24T00:00:00Z"}'
"http://localhost:8080/api/v1/dags/HelloWorld/dagRuns"
응답
{
"detail": "DAGRun with DAG ID: 'HelloWorld' and DAGRun logical date: '2023-05-24 00:00:00+00:00'
already exists",
"status": 409,
"title": "Conflict",
"type":
"https://airflow.apache.org/docs/apache-airflow/2.5.1/stable-rest-api-ref.html#section/Errors/AlreadyExists"
}
curl -X GET --user "airflow:airflow" http://localhost:8080/api/v1/dags
응답
{
"dag_id": "SQL_to_Sheet",
"default_view": "grid",
"description": null,
"file_token": "...",
"fileloc": "/opt/airflow/dags/SQL_to_Sheet.py",
"has_import_errors": false,
"has_task_concurrency_limits": false,
"is_active": true,
"is_paused": true,
"is_subdag": false,
"last_expired": null,
"last_parsed_time": "2023-06-18T05:21:34.266335+00:00",
"last_pickled": null,
"max_active_runs": 16,
"max_active_tasks": 16,
"next_dagrun": "2022-06-18T00:00:00+00:00",
"next_dagrun_create_after": "2022-06-18T00:00:00+00:00",
"next_dagrun_data_interval_end": "2022-06-18T00:00:00",
"next_dagrun_data_interval_start": "2022-06-18T00:00:00",
"owners": [ "airflow" ],
"pickle_id": null,
"root_dag_id": null,
"schedule_interval": {
"__type": "CronExpression",
"value": "@once"
},
"scheduler_lock": null,
"tags": [ { "name": "example" }],
"timetable_description": "Once, as soon as possible"
}
curl -X GET --user "airflow:airflow" http://localhost:8080/api/v1/variables
응답
{
"total_entries": 7,
"variables": [
{
"description": null,
"key": "api_token",
"value": "12345667"
},
{
"description": null,
"key": "csv_url",
"value": "https://s3-geospatial.s3-us-west-2.amazonaws.com/name_gender.csv"
}
curl -X GET --user "airflow:airflow" http://localhost:8080/api/v1/config
응답
{
"detail": "Your Airflow administrator chose not to expose the configuration, most likely for security
reasons.",
"status": 403,
"title": "Forbidden",
"type":
"https://airflow.apache.org/docs/apache-airflow/2.5.1/stable-rest-api-ref.html#section/Errors/PermissionDe
nied"
}