Skip to content

Commit

Permalink
take schema snapshot at init
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkeschiren committed Aug 1, 2023
1 parent 730bdab commit ec87e9f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/directus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions charts/directus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 32 additions & 0 deletions charts/directus/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
3 changes: 3 additions & 0 deletions charts/directus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ec87e9f

Please sign in to comment.