This repository was archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
[Merged by Bors] - Airflow demo with spark-k8s #119
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
29cdfe2
airflow cron demo
adwk67 52fe37a
airflow demo docs
adwk67 84b5d7e
added actual line to replace later before merging
adwk67 a874d18
working demo
adwk67 2d68bf4
merge main
adwk67 aacc9ce
deleted old docs
adwk67 f3c5950
changed scheduling to execute exactly once
adwk67 2fa4595
fixed clusterrole and check for registered DAG before REST calls
adwk67 257aa74
refactoring to wait for resources and to template spark job
adwk67 ebc47b0
updated documentation
adwk67 a1ddf82
added explanatory comment
adwk67 5d5f960
preserve job namespace
adwk67 a951a87
run spark-k8s job in same namespace as demo
adwk67 22f3491
revert to full paths
adwk67 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
demos/airflow-scheduled-job/01-airflow-spark-clusterrole.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: airflow-spark-clusterrole | ||
rules: | ||
- apiGroups: | ||
- spark.stackable.tech | ||
resources: | ||
- sparkapplications | ||
verbs: | ||
- create | ||
- get | ||
- list | ||
- apiGroups: | ||
- airflow.stackable.tech | ||
resources: | ||
- airflowdbs | ||
verbs: | ||
- create | ||
- get | ||
- list | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- statefulsets | ||
verbs: | ||
- get | ||
- watch | ||
- list | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- persistentvolumeclaims | ||
verbs: | ||
- list |
13 changes: 13 additions & 0 deletions
13
demos/airflow-scheduled-job/02-airflow-spark-clusterrolebinding.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: airflow-spark-clusterrole-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: airflow-spark-clusterrole | ||
subjects: | ||
- apiGroup: rbac.authorization.k8s.io | ||
kind: Group | ||
name: system:serviceaccounts |
26 changes: 26 additions & 0 deletions
26
demos/airflow-scheduled-job/03-enable-and-run-spark-dag.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: start-pyspark-job | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: start-pyspark-job | ||
image: docker.stackable.tech/stackable/tools:0.2.0-stackable0.3.0 | ||
# N.B. it is possible for the scheduler to report that a DAG exists, only for the worker task to fail if a pod is unexpectedly | ||
# restarted. Additionally, the db-init job takes a few minutes to complete before the cluster is deployed. The wait/watch steps | ||
# below are not "water-tight" but add a layer of stability by at least ensuring that the db is initialized and ready and that | ||
# all pods are reachable (albeit independent of each other). | ||
command: ["bash", "-c", " | ||
kubectl wait airflowdb/airflow --for jsonpath='{.status.condition}'=Ready --timeout 600s | ||
&& kubectl rollout status --watch statefulset/airflow-webserver-default | ||
&& kubectl rollout status --watch statefulset/airflow-worker-default | ||
&& kubectl rollout status --watch statefulset/airflow-scheduler-default | ||
&& curl -i -s --user airflow:airflow http://airflow-webserver-default:8080/api/v1/dags/sparkapp_dag | ||
&& curl -i -s --user airflow:airflow -H 'Content-Type:application/json' -XPATCH http://airflow-webserver-default:8080/api/v1/dags/sparkapp_dag -d '{\"is_paused\": false}' | ||
&& curl -i -s --user airflow:airflow -H 'Content-Type:application/json' -XPOST http://airflow-webserver-default:8080/api/v1/dags/sparkapp_dag/dagRuns -d '{}' | ||
"] | ||
restartPolicy: OnFailure | ||
backoffLimit: 20 # give some time for the Airflow cluster to be available |
26 changes: 26 additions & 0 deletions
26
demos/airflow-scheduled-job/04-enable-and-run-date-dag.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: start-date-job | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: start-date-job | ||
image: docker.stackable.tech/stackable/tools:0.2.0-stackable0.3.0 | ||
# N.B. it is possible for the scheduler to report that a DAG exists, only for the worker task to fail if a pod is unexpectedly | ||
# restarted. Additionally, the db-init job takes a few minutes to complete before the cluster is deployed. The wait/watch steps | ||
# below are not "water-tight" but add a layer of stability by at least ensuring that the db is initialized and ready and that | ||
# all pods are reachable (albeit independent of each other). | ||
command: ["bash", "-c", " | ||
kubectl wait airflowdb/airflow --for jsonpath='{.status.condition}'=Ready --timeout 600s | ||
&& kubectl rollout status --watch statefulset/airflow-webserver-default | ||
&& kubectl rollout status --watch statefulset/airflow-worker-default | ||
&& kubectl rollout status --watch statefulset/airflow-scheduler-default | ||
&& curl -i -s --user airflow:airflow http://airflow-webserver-default:8080/api/v1/dags/date_demo | ||
&& curl -i -s --user airflow:airflow -H 'Content-Type:application/json' -XPATCH http://airflow-webserver-default:8080/api/v1/dags/date_demo -d '{\"is_paused\": false}' | ||
&& curl -i -s --user airflow:airflow -H 'Content-Type:application/json' -XPOST http://airflow-webserver-default:8080/api/v1/dags/date_demo/dagRuns -d '{}' | ||
"] | ||
restartPolicy: OnFailure | ||
backoffLimit: 20 # give some time for the Airflow cluster to be available |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+26.5 KB
(120%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+17.6 KB
(130%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-12.8 KB
(67%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+33.3 KB
(110%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.19 KB
(97%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-343 Bytes
(97%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-330 Bytes
(100%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-36.3 KB
(94%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/airflow_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+67.9 KB
(130%)
docs/modules/ROOT/images/demo-airflow-scheduled-job/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.