mirror of
https://github.com/truecharts/charts.git
synced 2026-07-14 12:01:22 -03:00
feat(common): add mariadb support layer
This commit is contained in:
@@ -15,4 +15,4 @@ maintainers:
|
||||
name: common
|
||||
sources: null
|
||||
type: library
|
||||
version: 8.5.7
|
||||
version: 8.6.0
|
||||
|
||||
@@ -7,4 +7,7 @@
|
||||
|
||||
{{- /* Autogenerate redis passwords if needed */ -}}
|
||||
{{- include "common.dependencies.redis.injector" . }}
|
||||
|
||||
{{- /* Autogenerate mariadb passwords if needed */ -}}
|
||||
{{- include "common.dependencies.mariadb.injector" . }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
{{/*
|
||||
This template generates a random password and ensures it persists across updates/edits to the chart
|
||||
*/}}
|
||||
{{- define "common.dependencies.mariadb.injector" -}}
|
||||
{{- $pghost := printf "%v-%v" .Release.Name "mariadb" }}
|
||||
|
||||
{{- if .Values.mariadb.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "common.labels" . | nindent 4 }}
|
||||
name: mariamariadbcreds
|
||||
{{- $dbprevious := lookup "v1" "Secret" .Release.Namespace "mariadbcreds" }}
|
||||
{{- $dbPass := "" }}
|
||||
{{- $rootPass := "" }}
|
||||
data:
|
||||
{{- if $dbprevious }}
|
||||
{{- $dbPass = ( index $dbprevious.data "mariadb-password" ) | b64dec }}
|
||||
{{- $rootPass = ( index $dbprevious.data "mariadb-root-password" ) | b64dec }}
|
||||
mariadb-password: {{ ( index $dbprevious.data "mariadb-password" ) }}
|
||||
mariadb-root-password: {{ ( index $dbprevious.data "mariadb-root-password" ) }}
|
||||
{{- else }}
|
||||
{{- $dbPass = randAlphaNum 50 }}
|
||||
{{- $rootPass = randAlphaNum 50 }}
|
||||
mariadb-password: {{ $dbPass | b64enc | quote }}
|
||||
mariadb-root-password: {{ $rootPass | b64enc | quote }}
|
||||
{{- end }}
|
||||
url: {{ ( printf "sql://%v:%v@%v-mariadb:3306/%v" .Values.mariadb.mariadbUsername $dbPass .Release.Name .Values.mariadb.mariadbDatabase ) | b64enc | quote }}
|
||||
urlnossl: {{ ( printf "sql://%v:%v@%v-mariadb:3306/%v?sslmode=disable" .Values.mariadb.mariadbUsername $dbPass .Release.Name .Values.mariadb.mariadbDatabase ) | b64enc | quote }}
|
||||
plainporthost: {{ ( printf "%v-%v" .Release.Name "mariadb" ) | b64enc | quote }}
|
||||
plainhost: {{ ( printf "%v-%v" .Release.Name "mariadb" ) | b64enc | quote }}
|
||||
jdbc: {{ ( printf "jdbc:sqlserver://%v-mariadb:3306/%v" .Release.Name .Values.mariadb.mariadbDatabase ) | b64enc | quote }}
|
||||
type: Opaque
|
||||
{{- $_ := set .Values.mariadb "mariadbPassword" ( $dbPass | quote ) }}
|
||||
{{- $_ := set .Values.mariadb "mariadbRootPassword" ( $rootPass | quote ) }}
|
||||
{{- $_ := set .Values.mariadb.url "plain" ( ( printf "%v-%v" .Release.Name "mariadb" ) | quote ) }}
|
||||
{{- $_ := set .Values.mariadb.url "plainhost" ( ( printf "%v-%v" .Release.Name "mariadb" ) | quote ) }}
|
||||
{{- $_ := set .Values.mariadb.url "plainport" ( ( printf "%v-%v:3306" .Release.Name "mariadb" ) | quote ) }}
|
||||
{{- $_ := set .Values.mariadb.url "plainporthost" ( ( printf "%v-%v:3306" .Release.Name "mariadb" ) | quote ) }}
|
||||
{{- $_ := set .Values.mariadb.url "complete" ( ( printf "sql://%v:%v@%v-mariadb:3306/%v" .Values.mariadb.mariadbUsername $dbPass .Release.Name .Values.mariadb.mariadbDatabase ) | quote ) }}
|
||||
{{- $_ := set .Values.mariadb.url "jdbc" ( ( printf "jdbc:sqlserver://%v-mariadb:3306/%v" .Release.Name .Values.mariadb.mariadbDatabase ) | quote ) }}
|
||||
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -954,3 +954,11 @@ redis:
|
||||
existingSecret: "rediscreds"
|
||||
# -- can be used to make an easy accessable note which URLS to use to access the DB.
|
||||
url: {}
|
||||
|
||||
# -- mariadb dependency configuration
|
||||
# @default -- See below
|
||||
mariadb:
|
||||
enabled: false
|
||||
existingSecret: "mariadbcreds"
|
||||
# -- can be used to make an easy accessable note which URLS to use to access the DB.
|
||||
url: {}
|
||||
|
||||
Reference in New Issue
Block a user