diff --git a/k8s/airflow/Makefile b/k8s/airflow/Makefile index dd972c91d3..e65bce7b7a 100644 --- a/k8s/airflow/Makefile +++ b/k8s/airflow/Makefile @@ -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 diff --git a/k8s/airflow/apptest/tester/Dockerfile b/k8s/airflow/apptest/tester/Dockerfile index c3e99bfa9b..505e551799 100644 --- a/k8s/airflow/apptest/tester/Dockerfile +++ b/k8s/airflow/apptest/tester/Dockerfile @@ -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 @@ -15,4 +16,3 @@ COPY tester.sh /tester.sh WORKDIR / ENTRYPOINT ["/tester.sh"] - diff --git a/k8s/airflow/chart/airflow/templates/_helpers/pods.tpl b/k8s/airflow/chart/airflow/templates/_helpers/pods.tpl index 16b02b2029..9164badba8 100644 --- a/k8s/airflow/chart/airflow/templates/_helpers/pods.tpl +++ b/k8s/airflow/chart/airflow/templates/_helpers/pods.tpl @@ -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 }} @@ -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 }} diff --git a/k8s/airflow/chart/airflow/templates/db-migrations/db-migrations-deployment.yaml b/k8s/airflow/chart/airflow/templates/db-migrations/db-migrations-deployment.yaml index 261271975d..eb4dd36948 100644 --- a/k8s/airflow/chart/airflow/templates/db-migrations/db-migrations-deployment.yaml +++ b/k8s/airflow/chart/airflow/templates/db-migrations/db-migrations-deployment.yaml @@ -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 }} @@ -38,9 +39,8 @@ spec: env: {{- include "airflow.env" . | indent 12 }} command: - {{- include "airflow.command" . | indent 12 }} + - python args: - - "python" - "-u" - "/mnt/scripts/db_migrations.py" volumeMounts: @@ -48,9 +48,12 @@ spec: - 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 - diff --git a/k8s/airflow/chart/airflow/templates/nfs/nfs_clusterip_service.yaml b/k8s/airflow/chart/airflow/templates/nfs/nfs_clusterip_service.yaml index cde76d628a..5a525e76a3 100644 --- a/k8s/airflow/chart/airflow/templates/nfs/nfs_clusterip_service.yaml +++ b/k8s/airflow/chart/airflow/templates/nfs/nfs_clusterip_service.yaml @@ -8,7 +8,7 @@ spec: port: 2049 protocol: TCP - name: mountd - port: 20048 + port: 55038 protocol: TCP selector: role: nfs-server diff --git a/k8s/airflow/chart/airflow/templates/nfs/nfs_server_deployment.yaml b/k8s/airflow/chart/airflow/templates/nfs/nfs_server_deployment.yaml index 6d72c0e573..c27c989e13 100644 --- a/k8s/airflow/chart/airflow/templates/nfs/nfs_server_deployment.yaml +++ b/k8s/airflow/chart/airflow/templates/nfs/nfs_server_deployment.yaml @@ -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 @@ -29,7 +29,7 @@ spec: - name: nfs containerPort: 2049 - name: mountd - containerPort: 20048 + containerPort: 55038 securityContext: privileged: true volumeMounts: diff --git a/k8s/airflow/chart/airflow/templates/nfs/nfs_server_pvc.yaml b/k8s/airflow/chart/airflow/templates/nfs/nfs_server_pvc.yaml index 7748aeeb05..a494e595af 100644 --- a/k8s/airflow/chart/airflow/templates/nfs/nfs_server_pvc.yaml +++ b/k8s/airflow/chart/airflow/templates/nfs/nfs_server_pvc.yaml @@ -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 @@ -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: "/" - diff --git a/k8s/airflow/chart/airflow/templates/scheduler/scheduler-deployment.yaml b/k8s/airflow/chart/airflow/templates/scheduler/scheduler-deployment.yaml index f1b652204d..6e87d71536 100644 --- a/k8s/airflow/chart/airflow/templates/scheduler/scheduler-deployment.yaml +++ b/k8s/airflow/chart/airflow/templates/scheduler/scheduler-deployment.yaml @@ -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 }} @@ -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 @@ -91,4 +92,3 @@ spec: - name: pod-template configMap: name: {{ .Release.Name }}-pod-template - diff --git a/k8s/airflow/chart/airflow/templates/triggerer/triggerer-deployment.yaml b/k8s/airflow/chart/airflow/templates/triggerer/triggerer-deployment.yaml index 293c79c2c3..793dd41098 100644 --- a/k8s/airflow/chart/airflow/templates/triggerer/triggerer-deployment.yaml +++ b/k8s/airflow/chart/airflow/templates/triggerer/triggerer-deployment.yaml @@ -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 }} @@ -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 @@ -86,4 +85,3 @@ spec: {{- include "airflow.volumeMounts" . | indent 12 }} volumes: {{- include "airflow.volumes" . | indent 8 }} - diff --git a/k8s/airflow/chart/airflow/templates/webserver/webserver-deployment.yaml b/k8s/airflow/chart/airflow/templates/webserver/webserver-deployment.yaml index 1e0160ee62..62e09fc99a 100644 --- a/k8s/airflow/chart/airflow/templates/webserver/webserver-deployment.yaml +++ b/k8s/airflow/chart/airflow/templates/webserver/webserver-deployment.yaml @@ -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 }} @@ -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 @@ -98,4 +97,3 @@ spec: secret: secretName: {{ .Release.Name }}-webserver-config defaultMode: 0644 - diff --git a/k8s/airflow/chart/airflow/values.yaml b/k8s/airflow/chart/airflow/values.yaml index d728260499..2c5f1c0549 100644 --- a/k8s/airflow/chart/airflow/values.yaml +++ b/k8s/airflow/chart/airflow/values.yaml @@ -20,7 +20,7 @@ nfs: repo: null tag: null persistence: - storageClass: standard + storageClass: null size: 5Gi metrics: @@ -37,4 +37,3 @@ postgresql: persistence: storageClass: standard size: 5Gi -