Skip to content

Commit 8395562

Browse files
airflow-scheduled-job: adapt to listener changes (#247)
* adapt listener changes * Update demos/airflow-scheduled-job/03-enable-and-run-spark-dag.yaml Co-authored-by: Nick <[email protected]> * Apply suggestions from code review Co-authored-by: Nick <[email protected]> --------- Co-authored-by: Nick <[email protected]>
1 parent 5b5dc16 commit 8395562

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

demos/airflow-scheduled-job/03-enable-and-run-spark-dag.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ spec:
1313
# restarted. Additionally, the db-init job takes a few minutes to complete before the cluster is deployed. The wait/watch steps
1414
# below are not "water-tight" but add a layer of stability by at least ensuring that the db is initialized and ready and that
1515
# all pods are reachable (albeit independent of each other).
16-
command: ["bash", "-c", "
17-
kubectl rollout status --watch statefulset/airflow-webserver-default
18-
&& kubectl rollout status --watch statefulset/airflow-scheduler-default
19-
&& export AIRFLOW_ADMIN_PASSWORD=$(cat /airflow-credentials/adminUser.password)
20-
&& export ACCESS_TOKEN=$(curl -XPOST http://airflow-webserver-default:8080/auth/token -H 'Content-Type: application/json' -d '{\"username\": \"admin\", \"password\": \"'$AIRFLOW_ADMIN_PASSWORD'\"}' | jq '.access_token' | tr -d '\"')
21-
&& curl -H \"Authorization: Bearer $ACCESS_TOKEN\" -H 'Content-Type: application/json' -XPATCH http://airflow-webserver-default:8080/api/v2/dags/sparkapp_dag -d '{\"is_paused\": false}' | jq
22-
&& curl -H \"Authorization: Bearer $ACCESS_TOKEN\" -H 'Content-Type: application/json' -XPOST http://airflow-webserver-default:8080/api/v2/dags/sparkapp_dag/dagRuns -d '{\"logical_date\": null}' | jq
23-
"]
16+
command:
17+
- bash
18+
- -euo
19+
- pipefail
20+
- -c
21+
- |
22+
kubectl rollout status --watch statefulset/airflow-webserver-default
23+
kubectl rollout status --watch statefulset/airflow-scheduler-default
24+
AIRFLOW_ADMIN_PASSWORD=$(cat /airflow-credentials/adminUser.password)
25+
ACCESS_TOKEN=$(curl -XPOST http://airflow-webserver-default-headless:8080/auth/token -H 'Content-Type: application/json' -d '{"username": "admin", "password": "'$AIRFLOW_ADMIN_PASSWORD'"}' | jq -r .access_token)
26+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Content-Type: application/json' -XPATCH http://airflow-webserver-default-headless:8080/api/v2/dags/sparkapp_dag -d '{"is_paused": false}' | jq
27+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Content-Type: application/json' -XPOST http://airflow-webserver-default-headless:8080/api/v2/dags/sparkapp_dag/dagRuns -d '{"logical_date": null}' | jq
2428
volumeMounts:
2529
- name: airflow-credentials
2630
mountPath: /airflow-credentials

demos/airflow-scheduled-job/04-enable-and-run-date-dag.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ spec:
1313
# restarted. Additionally, the db-init job takes a few minutes to complete before the cluster is deployed. The wait/watch steps
1414
# below are not "water-tight" but add a layer of stability by at least ensuring that the db is initialized and ready and that
1515
# all pods are reachable (albeit independent of each other).
16-
command: ["bash", "-c", "
17-
kubectl rollout status --watch statefulset/airflow-webserver-default
18-
&& kubectl rollout status --watch statefulset/airflow-scheduler-default
19-
&& export AIRFLOW_ADMIN_PASSWORD=$(cat /airflow-credentials/adminUser.password)
20-
&& export ACCESS_TOKEN=$(curl -XPOST http://airflow-webserver-default:8080/auth/token -H 'Content-Type: application/json' -d '{\"username\": \"admin\", \"password\": \"'$AIRFLOW_ADMIN_PASSWORD'\"}' | jq '.access_token' | tr -d '\"')
21-
&& curl -H \"Authorization: Bearer $ACCESS_TOKEN\" -H 'Content-Type: application/json' -XPATCH http://airflow-webserver-default:8080/api/v2/dags/date_demo -d '{\"is_paused\": false}' | jq
22-
&& curl -H \"Authorization: Bearer $ACCESS_TOKEN\" -H 'Content-Type: application/json' -XPOST http://airflow-webserver-default:8080/api/v2/dags/date_demo/dagRuns -d '{\"logical_date\": null}' | jq
23-
"]
16+
command:
17+
- bash
18+
- -euo
19+
- pipefail
20+
- -c
21+
- |
22+
kubectl rollout status --watch statefulset/airflow-webserver-default
23+
kubectl rollout status --watch statefulset/airflow-scheduler-default
24+
AIRFLOW_ADMIN_PASSWORD=$(cat /airflow-credentials/adminUser.password)
25+
ACCESS_TOKEN=$(curl -XPOST http://airflow-webserver-default-headless:8080/auth/token -H 'Content-Type: application/json' -d '{"username": "admin", "password": "'$AIRFLOW_ADMIN_PASSWORD'"}' | jq -r .access_token)
26+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Content-Type: application/json' -XPATCH http://airflow-webserver-default-headless:8080/api/v2/dags/date_demo -d '{"is_paused": false}' | jq
27+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Content-Type: application/json' -XPOST http://airflow-webserver-default-headless:8080/api/v2/dags/date_demo/dagRuns -d '{"logical_date": null}' | jq
2428
volumeMounts:
2529
- name: airflow-credentials
2630
mountPath: /airflow-credentials

stacks/airflow/airflow.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ spec:
2626
mountPath: /dags/pyspark_pi.yaml
2727
subPath: pyspark_pi.yaml
2828
webservers:
29+
roleConfig:
30+
listenerClass: external-unstable
2931
config:
3032
resources:
3133
cpu:
@@ -34,7 +36,6 @@ spec:
3436
memory:
3537
limit: 2Gi
3638
gracefulShutdownTimeout: 30s
37-
listenerClass: external-unstable
3839
roleGroups:
3940
default:
4041
envOverrides:

0 commit comments

Comments
 (0)