initial work on single-container postgresql app (#758)
* initial work on single-container postgresql app * update * some more polish * use new common version for postgresql * fix a mistake * moar fixup * whoops * fixes * more fixing * add pre-upgrade backup hook * also add backup storage to questions.yaml
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: "postgres-backup-hook-config-map"
|
||||
annotations:
|
||||
rollme: {{ randAlphaNum 5 | quote }}
|
||||
data:
|
||||
entrypoint.sh: |-
|
||||
#!/bin/sh
|
||||
cmd="/docker-entrypoint.sh postgres"
|
||||
eval "${cmd}" & disown;
|
||||
until pg_isready; do
|
||||
sleep 5;
|
||||
done;
|
||||
pg_dump -U $POSTGRES_USER -d {{ .Values.postgresqlDatabase }} > /backups/$BACKUP_NAME;
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
{{ include "common.all" . }}
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
{{- with .Values.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
type: Opaque
|
||||
data:
|
||||
postgresql-password: {{ ( .Values.postgresqlPassword | default "empty" ) | b64enc | quote }}
|
||||
@@ -0,0 +1,58 @@
|
||||
{{- if .Values.ixChartContext -}}
|
||||
{{- if .Values.ixChartContext.isUpgrade -}}
|
||||
{{- $upgradeDict := .Values.ixChartContext.upgradeMetadata -}}
|
||||
{{ $values := (. | mustDeepCopy) }}
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: "pre-upgrade-hook2"
|
||||
annotations:
|
||||
"helm.sh/hook": pre-upgrade
|
||||
"helm.sh/hook-weight": "1"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded
|
||||
rollme: {{ randAlphaNum 5 | quote }}
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
name: "pre-upgrade-hook2"
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}-postgres-backup
|
||||
image: {{ printf "%v:%v" .Values.image.repository .Values.image.tag}}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env:
|
||||
- name: BACKUP_NAME
|
||||
value: {{- printf "postgres-backup-from-%s-to-%s-revision-%d" $upgradeDict.oldChartVersion $upgradeDict.newChartVersion (int64 $upgradeDict.preUpgradeRevision) -}}
|
||||
- name: PGDATA
|
||||
value: {{ .Values.pgdatapath | quote }}
|
||||
- name: POSTGRES_USER
|
||||
value: {{ .Values.postgresqlUsername | quote }}
|
||||
- name: POSTGRES_DB
|
||||
value: {{ .Values.postgresqlDatabase | quote }}
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ ( .Values.existingSecret | default ( include "common.names.fullname" . ) ) | quote }}
|
||||
key: "postgresql-password"
|
||||
command:
|
||||
- "/bin/backup_entrypoint.sh"
|
||||
volumeMounts:
|
||||
- name: backup-script-configmap
|
||||
mountPath: /bin/backup_entrypoint.sh
|
||||
readOnly: true
|
||||
subPath: entrypoint.sh
|
||||
{{- with (include "common.controller.volumeMounts" . | trim) }}
|
||||
{{ nindent 4 . }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: backup-script-configmap
|
||||
configMap:
|
||||
defaultMode: 0700
|
||||
name: "postgres-backup-hook-config-map"
|
||||
{{- with (include "common.controller.volumes" . | trim) }}
|
||||
{{- nindent 2 . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user