(feat) move postgresql init and password-generator to common (#1113)

* Move Postgresql initcontainer to common

* bump common

* Handle postgres password generation in common and inject into values.yaml for use in Apps

* (refactor) adapt apps using postgresql to common init and password generator

* no message
This commit is contained in:
Kjeld Schouten-Lebbing
2021-10-09 19:24:45 +02:00
committed by GitHub
parent ce48246b9b
commit 2679fc1108
21 changed files with 93 additions and 305 deletions
@@ -9,11 +9,6 @@ image:
pullPolicy: IfNotPresent
tag: v1.22.2@sha256:8693c057298731f507128a395395172d60093be9b299f6bf9e5c35512a74d457
postgresqlImage:
repository: bitnami/postgresql
pullPolicy: IfNotPresent
tag: 13.4.0@sha256:e7526fc32deec708740784d907bcea2ef6c78bc5ab5265026eff96e70082a54a
envTpl:
DOMAIN: "https://{{ if .Values.ingress }}{{ if .Values.ingress.main.enabled }}{{ ( index .Values.ingress.main.hosts 0 ).host }}{{ else }}placeholder.com{{ end }}{{ else }}placeholder.com{{ end }}"
@@ -24,21 +19,6 @@ envFrom:
- secretRef:
name: vaultwardensecret
initContainers:
init-postgresdb:
image: "{{ .Values.postgresqlImage.repository }}:{{ .Values.postgresqlImage.tag }}"
command:
- "sh"
- "-c"
- "until pg_isready -U authelia -h ${pghost} ; do sleep 2 ; done"
imagePullPolicy: IfNotPresent
env:
- name: pghost
valueFrom:
secretKeyRef:
name: dbcreds
key: plainhost
envValueFrom:
DATABASE_URL:
@@ -63,7 +43,6 @@ postgresql:
enabled: true
postgresqlUsername: vaultwarden
postgresqlDatabase: vaultwarden
existingSecret: dbcreds
persistence:
db:
storageClass: "SCALE-ZFS"
@@ -33,28 +33,4 @@ data:
YUBICO_CLIENT_ID: {{ $yubicoClientId }}
YUBICO_SECRET_KEY: {{ required "Yubico Secret Key required" .Values.vaultwarden.yubico.secretKey | b64enc | quote }}
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "common.labels" . | nindent 4 }}
name: dbcreds
{{- $previous := lookup "v1" "Secret" .Release.Namespace "dbcreds" }}
{{- $dbPass := "" }}
data:
{{- if $previous }}
{{- $dbPass = ( index $previous.data "postgresql-password" ) | b64dec }}
postgresql-password: {{ ( index $previous.data "postgresql-password" ) }}
postgresql-postgres-password: {{ ( index $previous.data "postgresql-postgres-password" ) }}
{{- else }}
{{- $dbPass = randAlphaNum 50 }}
postgresql-password: {{ $dbPass | b64enc | quote }}
postgresql-postgres-password: {{ randAlphaNum 50 | b64enc | quote }}
{{- end }}
url: {{ ( printf "%v%v:%v@%v-%v:%v/%v" "postgresql://" .Values.postgresql.postgresqlUsername $dbPass .Release.Name "postgresql" "5432" .Values.postgresql.postgresqlDatabase ) | b64enc | quote }}
plainhost: {{ ( printf "%v-%v" .Release.Name "postgresql" ) | b64enc | quote }}
type: Opaque
{{- end -}}
-21
View File
@@ -5,11 +5,6 @@ image:
pullPolicy: IfNotPresent
tag: v1.22.2@sha256:8693c057298731f507128a395395172d60093be9b299f6bf9e5c35512a74d457
postgresqlImage:
repository: bitnami/postgresql
pullPolicy: IfNotPresent
tag: 13.4.0@sha256:e7526fc32deec708740784d907bcea2ef6c78bc5ab5265026eff96e70082a54a
service:
main:
ports:
@@ -91,21 +86,6 @@ ingress:
# hosts:
# - chart-example.local
initContainers:
init-postgresdb:
image: "{{ .Values.postgresqlImage.repository }}:{{ .Values.postgresqlImage.tag }}"
command:
- "sh"
- "-c"
- "until pg_isready -U authelia -h ${pghost} ; do sleep 2 ; done"
imagePullPolicy: IfNotPresent
env:
- name: pghost
valueFrom:
secretKeyRef:
name: dbcreds
key: plainhost
envTpl:
DOMAIN: "https://{{ if .Values.ingress }}{{ if .Values.ingress.main.enabled }}{{ ( index .Values.ingress.main.hosts 0 ).host }}{{ else }}placeholder.com{{ end }}{{ else }}placeholder.com{{ end }}"
@@ -243,4 +223,3 @@ postgresql:
enabled: true
postgresqlUsername: vaultwarden
postgresqlDatabase: vaultwarden
existingSecret: dbcreds