Add postgresql deployment
This commit is contained in:
parent
eb3c7a6ae6
commit
43ab3e05fe
|
@ -62,6 +62,22 @@ Retrieve host path defined in volume
|
|||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Retrieve backup postgresql host path defined in volume
|
||||
*/}}
|
||||
{{- define "configuredBackupPostgresHostPath" -}}
|
||||
{{- $backupVolDict := first .Values.postgresql.backupVolume -}}
|
||||
{{- $backupVolDict.hostPath -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Retrieve postgresql data host path defined in volume
|
||||
*/}}
|
||||
{{- define "configuredPostgresHostPath" -}}
|
||||
{{- $dataVolDict := first .Values.postgresql.dataVolume -}}
|
||||
{{- $dataVolDict.hostPath -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ template "nextcloud.fullname" . }}-postgres
|
||||
labels:
|
||||
helm.sh/chart: {{ include "nextcloud.chart" . }}
|
||||
{{- include "nextcloud.postgres.selectorLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
app.kubernetes.io/component: database
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: {{ .Values.nextcloud.strategy }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "nextcloud.postgres.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: database
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "nextcloud.postgres.selectorLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: database
|
||||
annotations:
|
||||
rollme: {{ randAlphaNum 5 | quote }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}-postgres
|
||||
image: "postgres:13.1"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-details
|
||||
key: db-password
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: postgres-backup
|
||||
mountPath: /postgres_backups
|
||||
ports:
|
||||
- name: postgres-tcp
|
||||
containerPort: 5432
|
||||
protocol: TCP
|
||||
volumes:
|
||||
- name: postgres-data
|
||||
hostPath:
|
||||
path: {{ template "configuredPostgresHostPath" . }}
|
||||
- name: postgres-backup
|
||||
hostPath:
|
||||
path: {{ template "configuredBackupPostgresHostPath" . }}
|
|
@ -0,0 +1,12 @@
|
|||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: db-details
|
||||
data:
|
||||
{{- if .Release.IsInstall }}
|
||||
db-password: {{ randAlphaNum 15 | b64enc | quote }}
|
||||
{{ else }}
|
||||
# `index` function is necessary because the property name contains a dash.
|
||||
# Otherwise (...).data.db_password would have worked too.
|
||||
db-password: {{ index (lookup "v1" "Secret" .Release.Namespace "db-details").data "db-password" }}
|
||||
{{ end }}
|
Loading…
Reference in New Issue