Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
[stable/airflow] Add a feature to run extra init scripts in the sched…
Browse files Browse the repository at this point in the history
…uler
  • Loading branch information
NBardelot committed Feb 26, 2020
1 parent e6530ae commit 8555df8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stable/airflow/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: Airflow is a platform to programmatically author, schedule and monitor workflows
name: airflow
version: 6.1.1
version: 6.2.0
appVersion: 1.10.4
icon: https://airflow.apache.org/_images/pin_large.png
home: https://airflow.apache.org/
Expand Down
1 change: 1 addition & 0 deletions stable/airflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ The following table lists the configurable parameters of the Airflow chart and t
| `airflow.podAnnotations` | annotations for scheduler, worker and web pods | `{}` |
| `airflow.extraInitContainers` | additional Init Containers to run in the scheduler pods | `[]` |
| `airflow.extraContainers` | additional containers to run in the scheduler, worker & web pods | `[]` |
| `airflow.extraStartupScripts` | name of a configmap with extra init scripts to run in the scheduler | |
| `airflow.extraVolumeMounts` | additional volumeMounts to the main container in scheduler, worker & web pods | `[]`|
| `airflow.extraVolumes` | additional volumes for the scheduler, worker & web pods | `[]` |
| `airflow.initdb` | run `airflow initdb` when starting the scheduler | `true` |
Expand Down
18 changes: 18 additions & 0 deletions stable/airflow/templates/deployments-scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ spec:
subPath: {{ .subPath }}
{{ end }}
{{- end }}
{{- if .Values.airflow.extraStartupScripts }}
- name: extra-startup-scripts
mountPath: /usr/local/extra-startup-scripts/
{{- end}}
{{- if .Values.airflow.extraVolumeMounts }}
{{ toYaml .Values.airflow.extraVolumeMounts | indent 12 }}
{{- end }}
Expand Down Expand Up @@ -203,6 +207,10 @@ spec:
{{- if .Values.airflow.pools }}
echo "adding pools" &&
airflow pool -i /usr/local/variables-pools/pools.json &&
{{- end }}
{{- if .Values.airflow.extraStartupScripts }}
echo "running extra startup scripts" &&
/usr/local/extra-startup-scripts/run.sh &&
{{- end }}
echo "executing scheduler" &&
airflow scheduler -n {{ .Values.airflow.schedulerNumRuns }}
Expand All @@ -227,6 +235,10 @@ spec:
{{- if .Values.airflow.pools }}
echo "adding pools" &&
airflow pool -i /usr/local/variables-pools/pools.json &&
{{- end }}
{{- if .Values.airflow.extraStartupScripts }}
echo "running extra startup scripts" &&
/usr/local/extra-startup-scripts/run.sh &&
{{- end }}
echo "executing scheduler" &&
airflow scheduler -n {{ .Values.airflow.schedulerNumRuns }}
Expand Down Expand Up @@ -280,6 +292,12 @@ spec:
configMap:
name: {{ .configMap }}
{{- end }}
{{- if .Values.airflow.extraStartupScripts }}
- name: extra-startup-scripts
configMap:
name: {{ .Values.airflow.extraStartupScripts }}
defaultMode: 0740
{{- end }}
{{- if .Values.airflow.extraVolumes }}
{{ toYaml .Values.airflow.extraVolumes | indent 8 }}
{{- end }}
12 changes: 12 additions & 0 deletions stable/airflow/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ airflow:
## Run initdb when the scheduler starts.
initdb: true

# If set, must be the name of a configmap that contains at least one entry, which key must be named 'run.sh',
# and corresponds to a shell script that will be executed in the scheduler container after it has finished
# initdb and other standard startup scripts (just before it starts).
# Other entries provided in the same configmap will also be mounted in the same directory (using the key name
# as their filename). This allows you to split your initialization tasks into several scripts that you can call from
# the main 'run.sh' script, for example.
# Notes:
# - the behaviour of those extra scripts should be idempotent, and fast enough, as they will be executed every time
# the scheduler restarts
# - if those scripts use sensitive data, you should provide the sensitive data using secrets
# (see .Values.airflow.extraConfigmapMounts and .Values.airflow.extraEnv)
extraStartupScripts:

scheduler:
resources: {}
Expand Down

0 comments on commit 8555df8

Please sign in to comment.