Skip to content

Commit

Permalink
🔧(helm) use pre-install helm hooks for migrations and staticfiles
Browse files Browse the repository at this point in the history
Using pre-install hooks for migrating the database and collecting static
files before a deployment seems to be the best choice.
  • Loading branch information
wilbrdt committed Mar 4, 2024
1 parent c543e45 commit 8986e5d
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/helm/warren/charts/api/templates/configmap-database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: warren-api-database
labels:
{{- include "api.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_API_DB_ENGINE: {{ .Values.database.engine | quote }}
WARREN_API_DB_HOST: {{ .Values.database.host | quote }}
Expand Down
2 changes: 2 additions & 0 deletions src/helm/warren/charts/api/templates/configmap-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: warren-api-env
labels:
{{- include "api.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_API_SERVER_PORT: {{ .Values.service.port | quote}}
WARREN_APP_SIGNING_ALGORITHM: {{ .Values.signing.algorithm | quote }}
Expand Down
2 changes: 2 additions & 0 deletions src/helm/warren/charts/api/templates/configmap-logging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: "{{ .Values.loggingConfigConfigMap }}"
labels:
{{- include "api.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
{{ with .Values.loggingConfig }}
logging-config.yaml: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ $.Values.database.passwordSecretName }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_API_DB_PASSWORD: {{ $.Values.database.password | b64enc }}
{{- end }}
2 changes: 2 additions & 0 deletions src/helm/warren/charts/api/templates/secret-lrs-password.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ $.Values.lrs.passwordSecretName }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_LRS_AUTH_BASIC_PASSWORD: {{ $.Values.lrs.password | b64enc }}
{{- end }}
2 changes: 2 additions & 0 deletions src/helm/warren/charts/api/templates/secret-signing-key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ $.Values.signing.keySecretName }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_APP_SIGNING_KEY: {{ $.Values.signing.key | b64enc }}
{{- end }}
2 changes: 2 additions & 0 deletions src/helm/warren/charts/app/templates/configmap-database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: warren-app-database
labels:
{{- include "app.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_APP_DB_HOST: {{ .Values.database.host | quote }}
WARREN_APP_DB_PORT: {{ .Values.database.port | quote }}
Expand Down
2 changes: 2 additions & 0 deletions src/helm/warren/charts/app/templates/configmap-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: warren-app-env
labels:
{{- include "app.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
DJANGO_SETTINGS_MODULE: {{ .Values.djangoSettingsModule | quote }}
DJANGO_CONFIGURATION: {{ .Values.djangoConfiguration | quote }}
Expand Down
4 changes: 4 additions & 0 deletions src/helm/warren/charts/app/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
name: {{ include "app.fullname" . }}-media
labels:
{{- include "app.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
spec:
accessModes:
{{ with .Values.persistence.accessModes }}
Expand All @@ -24,6 +26,8 @@ metadata:
name: {{ include "app.fullname" . }}-static
labels:
{{- include "app.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
spec:
accessModes:
{{ with .Values.persistence.accessModes }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ $.Values.database.passwordSecretName }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_APP_DB_PASSWORD: {{ $.Values.database.password | b64enc }}
{{- end }}
2 changes: 2 additions & 0 deletions src/helm/warren/charts/app/templates/secret-secret-key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ $.Values.secretKeySecretName }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_APP_SECRET_KEY: {{ $.Values.secretKey | b64enc }}
{{- end }}
2 changes: 2 additions & 0 deletions src/helm/warren/charts/app/templates/secret-signing-key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ $.Values.signing.keySecretName }}
annotations:
"helm.sh/hook": pre-install, pre-upgrade
data:
WARREN_APP_SIGNING_KEY: {{ $.Values.signing.key | b64enc }}
{{- end }}

0 comments on commit 8986e5d

Please sign in to comment.