Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s - Airflow - Add annotations #2836

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion k8s/airflow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ CHART_NAME := airflow
APP_ID ?= $(CHART_NAME)
WAIT_FOR_READY_TIMEOUT := 600

TRACK ?= 2.8
TRACK ?= 2.10
SERVICE_NAME := services/a04a14b8-4fd4-469b-93c0-f540ac6eca56.cloudpartnerservices.goog

# Track for components
POSTGRESQL_TRACK ?= latest
NFS_TRACK ?= 1.3
Expand Down
8 changes: 4 additions & 4 deletions k8s/airflow/apptest/tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
FROM gcr.io/cloud-marketplace-tools/testrunner:0.1.5
FROM gcr.io/cloud-marketplace-tools/testrunner:0.1.8

RUN apt-get update && apt-get install -y --no-install-recommends \
curl wget dnsutils netcat jq \
ca-certificates curl dnsutils netcat-traditional jq \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /opt/kubectl/1.21 \
&& wget -q -O /opt/kubectl/1.21/kubectl \
&& curl -L -o kubectl \
https://storage.googleapis.com/kubernetes-release/release/v1.21.6/bin/linux/amd64/kubectl \
&& mv kubectl /opt/kubectl/1.21/ \
&& chmod 755 /opt/kubectl/1.21/kubectl \
&& ln -s /opt/kubectl/1.21/kubectl /usr/bin/kubectl

Expand All @@ -15,4 +16,3 @@ COPY tester.sh /tester.sh

WORKDIR /
ENTRYPOINT ["/tester.sh"]

12 changes: 6 additions & 6 deletions k8s/airflow/chart/airflow/templates/_helpers/pods.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ EXAMPLE USAGE: {{ include "airflow.init_container.check_db" (dict "Release" .Rel
command:
{{- include "airflow.command" . | indent 4 }}
args:
- "bash"
- "-c"
- "exec timeout 60s airflow db check"
- "db"
- "check"
volumeMounts:
{{- include "airflow.volumeMounts" . | indent 4 }}
{{- end }}
Expand All @@ -53,9 +52,10 @@ EXAMPLE USAGE: {{ include "airflow.init_container.wait_for_db_migrations" (dict
command:
{{- include "airflow.command" . | indent 4 }}
args:
- "bash"
- "-c"
- "exec airflow db check-migrations -t 60"
- "db"
- "check-migrations"
- "-t"
- "60"
volumeMounts:
{{- include "airflow.volumeMounts" . | indent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
name: {{ .Release.Name }}
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 120
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
initContainers:
{{- include "airflow.init_container.check_db" . | indent 8 }}
Expand All @@ -38,19 +39,21 @@ spec:
env:
{{- include "airflow.env" . | indent 12 }}
command:
{{- include "airflow.command" . | indent 12 }}
- python
args:
- "python"
- "-u"
- "/mnt/scripts/db_migrations.py"
volumeMounts:
{{- include "airflow.volumeMounts" . | indent 12 }}
- name: scripts
mountPath: /mnt/scripts
readOnly: true
lifecycle:
preStop:
exec:
command: ["/bin/bash", "-c", "pkill -SIGTERM python"]
volumes:
{{- include "airflow.volumes" . | indent 8 }}
- name: scripts
secret:
secretName: {{ .Release.Name }}-db-migrations

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
port: 2049
protocol: TCP
- name: mountd
port: 20048
port: 55038
protocol: TCP
selector:
role: nfs-server
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
initContainers:
- name: {{ .Release.Name }}-nfs-changeowner
image: busybox
command: ["sh", "-c", "mkdir -p /exports/dags && mkdir -p /exports/logs && chmod -R 777 /exports"]
command: ["sh", "-c", "mkdir -p /exports/dags && mkdir -p /exports/logs && chmod -R 777 /exports"]
volumeMounts:
- mountPath: /exports
name: {{ .Release.Name }}-nfs-server-pvc
Expand All @@ -29,7 +29,7 @@ spec:
- name: nfs
containerPort: 2049
- name: mountd
containerPort: 20048
containerPort: 55038
securityContext:
privileged: true
volumeMounts:
Expand Down
8 changes: 4 additions & 4 deletions k8s/airflow/chart/airflow/templates/nfs/nfs_server_pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ metadata:
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
storageClassName: "{{ .Values.nfs.persistence.storageClass }}"
resources:
requests:
storage: {{ .Values.nfs.persistence.size | quote }}
volumeName: {{ .Release.Name }}-nfs-dags-logs
---
apiVersion: v1
kind: PersistentVolume
Expand All @@ -34,10 +35,9 @@ spec:
persistentVolumeReclaimPolicy: "Delete"
capacity:
storage: {{ .Values.nfs.persistence.size | quote }}
storageClassName: ""
storageClassName: "{{ .Values.nfs.persistence.storageClass }}"
accessModes:
- ReadWriteMany
nfs:
server: {{ .Release.Name }}-nfs-server.{{ .Release.Namespace }}.svc.cluster.local
server: "{{ .Release.Name }}-nfs-server.{{ .Release.Namespace }}.svc.cluster.local"
path: "/"

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
name: {{ .Release.Name }}
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 60
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
initContainers:
{{- include "airflow.init_container.check_db" . | indent 8 }}
Expand All @@ -43,11 +44,11 @@ spec:
command:
{{- include "airflow.command" . | indent 12 }}
args:
- "bash"
- "-c"
- "exec airflow scheduler -n -1"
- "scheduler"
- "-n"
- "-1"
livenessProbe:
initialDelaySeconds: 10
initialDelaySeconds: 10
periodSeconds: 30
failureThreshold: 5
timeoutSeconds: 60
Expand Down Expand Up @@ -91,4 +92,3 @@ spec:
- name: pod-template
configMap:
name: {{ .Release.Name }}-pod-template

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
name: {{ .Release.Name }}
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 60
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
initContainers:
{{- include "airflow.init_container.check_db" . | indent 8 }}
Expand All @@ -44,11 +45,9 @@ spec:
command:
{{- include "airflow.command" . | indent 12 }}
args:
- "bash"
- "-c"
- "exec airflow triggerer"
- "triggerer"
livenessProbe:
initialDelaySeconds: 10
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 60
failureThreshold: 5
Expand Down Expand Up @@ -86,4 +85,3 @@ spec:
{{- include "airflow.volumeMounts" . | indent 12 }}
volumes:
{{- include "airflow.volumes" . | indent 8 }}

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
name: {{ .Release.Name }}
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 60
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
initContainers:
{{- include "airflow.init_container.check_db" . | indent 8 }}
Expand All @@ -45,16 +46,14 @@ spec:
{{- include "airflow.envFrom" . | indent 12 }}
env:
{{- include "airflow.env" . | indent 12 }}
- name: _AIRFLOW_WWW_USER_CREATE
- name: _AIRFLOW_WWW_USER_CREATE
value: 'true'
command:
{{- include "airflow.command" . | indent 12 }}
args:
- "bash"
- "-c"
- "exec airflow webserver"
- "webserver"
livenessProbe: &probes
initialDelaySeconds: 30
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
Expand Down Expand Up @@ -98,4 +97,3 @@ spec:
secret:
secretName: {{ .Release.Name }}-webserver-config
defaultMode: 0644

3 changes: 1 addition & 2 deletions k8s/airflow/chart/airflow/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nfs:
repo: null
tag: null
persistence:
storageClass: standard
storageClass: null
size: 5Gi

metrics:
Expand All @@ -37,4 +37,3 @@ postgresql:
persistence:
storageClass: standard
size: 5Gi