From ec87e9f460a71cefe34c610c47a2adee3e60fce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikke=20Schir=C3=A9n?= Date: Tue, 1 Aug 2023 23:39:31 +0200 Subject: [PATCH] take schema snapshot at init --- charts/directus/Chart.yaml | 2 +- charts/directus/README.md | 1 + charts/directus/templates/deployment.yaml | 32 +++++++++++++++++++++++ charts/directus/values.yaml | 3 +++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/charts/directus/Chart.yaml b/charts/directus/Chart.yaml index 71674d5..53aede9 100644 --- a/charts/directus/Chart.yaml +++ b/charts/directus/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.5.2 +version: 0.5.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/directus/README.md b/charts/directus/README.md index 5ad2e57..082c460 100644 --- a/charts/directus/README.md +++ b/charts/directus/README.md @@ -115,6 +115,7 @@ helm delete directus-release | `extraConfigMap.data`| Configmap data to add | `{}` | | `extraVolumes`| Extra volumes to add | `[]` | | `extraVolumeMounts`| Extra volumemounts to add | `[]` | +| `snapshot`| Take schema snapshot at init | `false` | ### External Database diff --git a/charts/directus/templates/deployment.yaml b/charts/directus/templates/deployment.yaml index 6c14ea4..a738037 100644 --- a/charts/directus/templates/deployment.yaml +++ b/charts/directus/templates/deployment.yaml @@ -43,6 +43,28 @@ spec: {{- if .Values.extraEnvVars }} {{- tpl (toYaml .Values.extraEnvVars) $ | nindent 12 }} {{- end }} + {{- if .Values.snapshot }} + - name: {{ .Chart.Name }}-schema-snapshot + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["node"] + args: ["/directus/cli.js", "schema", "snapshot", "--format", "yaml", "-y", "/startup-snapshot/snapshot.yaml"] + env: + {{- if .Values.ingress.enabled }} + - name: PUBLIC_URL + value: http{{ if .Values.ingress.tls }}s{{ end }}://{{(index .Values.ingress.hosts 0).host }} + {{- end }} + {{- if .Values.extraEnvVars }} + {{- tpl (toYaml .Values.extraEnvVars) $ | nindent 12 }} + {{- end }} + {{- if .Values.snapshot }} + volumeMounts: + - mountPath: /startup-snapshot + name: startup-snapshot +{{- end }} + {{- end }} {{- if .Values.initContainers }} {{ toYaml .Values.initContainers | indent 8 }} {{- end }} @@ -65,6 +87,11 @@ spec: {{- if .Values.extraEnvVars }} {{- tpl (toYaml .Values.extraEnvVars) $ | nindent 12 }} {{- end }} + volumeMounts: + {{- if .Values.snapshot }} + - mountPath: /startup-snapshot + name: startup-snapshot +{{- end }} {{- if .Values.extraVolumeMounts }} {{ toYaml .Values.extraVolumeMounts | indent 10 }} {{- end }} @@ -110,6 +137,11 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + volumes: +{{- if .Values.snapshot }} + - name: startup-snapshot + emptyDir: {} +{{- end }} {{- if .Values.extraVolumes }} {{ toYaml .Values.extraVolumes | indent 6 }} {{- end }} \ No newline at end of file diff --git a/charts/directus/values.yaml b/charts/directus/values.yaml index 915d9f8..4e3eceb 100644 --- a/charts/directus/values.yaml +++ b/charts/directus/values.yaml @@ -86,6 +86,9 @@ initContainers: [] # - "-c" # - "echo 'message from init container'" +snapshot: false +# take s snapshot of schema config in init container. + sidecars: [] # You can add any sidecar to the directus pod, like: # sidecars: