GHP publish
This commit is contained in:
59
nextcloud/charts/postgresql/templates/NOTES.txt
Normal file
59
nextcloud/charts/postgresql/templates/NOTES.txt
Normal file
@ -0,0 +1,59 @@
|
||||
** Please be patient while the chart is being deployed **
|
||||
|
||||
PostgreSQL can be accessed via port {{ template "postgresql.port" . }} on the following DNS name from within your cluster:
|
||||
|
||||
{{ template "postgresql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local - Read/Write connection
|
||||
{{- if .Values.replication.enabled }}
|
||||
{{ template "postgresql.fullname" . }}-read.{{ .Release.Namespace }}.svc.cluster.local - Read only connection
|
||||
{{- end }}
|
||||
|
||||
{{- if and (not (eq .Values.postgresqlUsername "postgres")) (or .Values.postgresqlPostgresPassword (include "postgresql.useExistingSecret" .)) }}
|
||||
|
||||
To get the password for "postgres" run:
|
||||
|
||||
export POSTGRES_ADMIN_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "postgresql.secretName" . }} -o jsonpath="{.data.postgresql-postgres-password}" | base64 --decode)
|
||||
{{- end }}
|
||||
|
||||
To get the password for "{{ template "postgresql.username" . }}" run:
|
||||
|
||||
export POSTGRES_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "postgresql.secretName" . }} -o jsonpath="{.data.postgresql-password}" | base64 --decode)
|
||||
|
||||
To connect to your database run the following command:
|
||||
|
||||
kubectl run {{ template "postgresql.fullname" . }}-client --rm --tty -i --restart='Never' --namespace {{ .Release.Namespace }} --image {{ template "postgresql.image" . }} --env="PGPASSWORD=$POSTGRES_PASSWORD" {{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
|
||||
--labels="{{ template "postgresql.fullname" . }}-client=true" {{- end }} --command -- psql --host {{ template "postgresql.fullname" . }} -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }} -p {{ template "postgresql.port" . }}
|
||||
|
||||
{{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
|
||||
Note: Since NetworkPolicy is enabled, only pods with label {{ template "postgresql.fullname" . }}-client=true" will be able to connect to this PostgreSQL cluster.
|
||||
{{- end }}
|
||||
|
||||
To connect to your database from outside the cluster execute the following commands:
|
||||
|
||||
{{- if contains "NodePort" .Values.service.type }}
|
||||
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "postgresql.fullname" . }})
|
||||
{{ if (include "postgresql.password" . ) }}PGPASSWORD="$POSTGRES_PASSWORD" {{ end }}psql --host $NODE_IP --port $NODE_PORT -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }}
|
||||
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "postgresql.fullname" . }}'
|
||||
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "postgresql.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
{{ if (include "postgresql.password" . ) }}PGPASSWORD="$POSTGRES_PASSWORD" {{ end }}psql --host $SERVICE_IP --port {{ template "postgresql.port" . }} -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }}
|
||||
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
|
||||
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "postgresql.fullname" . }} {{ template "postgresql.port" . }}:{{ template "postgresql.port" . }} &
|
||||
{{ if (include "postgresql.password" . ) }}PGPASSWORD="$POSTGRES_PASSWORD" {{ end }}psql --host 127.0.0.1 -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }} -p {{ template "postgresql.port" . }}
|
||||
|
||||
{{- end }}
|
||||
|
||||
{{- include "postgresql.validateValues" . -}}
|
||||
|
||||
{{- include "common.warnings.rollingTag" .Values.image -}}
|
||||
|
||||
{{- $passwordValidationErrors := include "common.validations.values.postgresql.passwords" (dict "secret" (include "postgresql.fullname" .) "context" $) -}}
|
||||
|
||||
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $passwordValidationErrors) "context" $) -}}
|
488
nextcloud/charts/postgresql/templates/_helpers.tpl
Normal file
488
nextcloud/charts/postgresql/templates/_helpers.tpl
Normal file
@ -0,0 +1,488 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "postgresql.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "postgresql.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "postgresql.master.fullname" -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- $fullname := default (printf "%s-%s" .Release.Name $name) .Values.fullnameOverride -}}
|
||||
{{- if .Values.replication.enabled -}}
|
||||
{{- printf "%s-%s" $fullname "master" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s" $fullname | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiVersion for networkpolicy.
|
||||
*/}}
|
||||
{{- define "postgresql.networkPolicy.apiVersion" -}}
|
||||
{{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
"extensions/v1beta1"
|
||||
{{- else if semverCompare "^1.7-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
"networking.k8s.io/v1"
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "postgresql.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper PostgreSQL image name
|
||||
*/}}
|
||||
{{- define "postgresql.image" -}}
|
||||
{{- $registryName := .Values.image.registry -}}
|
||||
{{- $repositoryName := .Values.image.repository -}}
|
||||
{{- $tag := .Values.image.tag | toString -}}
|
||||
{{/*
|
||||
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
||||
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
|
||||
Also, we can't use a single if because lazy evaluation is not an option
|
||||
*/}}
|
||||
{{- if .Values.global }}
|
||||
{{- if .Values.global.imageRegistry }}
|
||||
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return PostgreSQL postgres user password
|
||||
*/}}
|
||||
{{- define "postgresql.postgres.password" -}}
|
||||
{{- if .Values.global.postgresql.postgresqlPostgresPassword }}
|
||||
{{- .Values.global.postgresql.postgresqlPostgresPassword -}}
|
||||
{{- else if .Values.postgresqlPostgresPassword -}}
|
||||
{{- .Values.postgresqlPostgresPassword -}}
|
||||
{{- else -}}
|
||||
{{- randAlphaNum 10 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return PostgreSQL password
|
||||
*/}}
|
||||
{{- define "postgresql.password" -}}
|
||||
{{- if .Values.global.postgresql.postgresqlPassword }}
|
||||
{{- .Values.global.postgresql.postgresqlPassword -}}
|
||||
{{- else if .Values.postgresqlPassword -}}
|
||||
{{- .Values.postgresqlPassword -}}
|
||||
{{- else -}}
|
||||
{{- randAlphaNum 10 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return PostgreSQL replication password
|
||||
*/}}
|
||||
{{- define "postgresql.replication.password" -}}
|
||||
{{- if .Values.global.postgresql.replicationPassword }}
|
||||
{{- .Values.global.postgresql.replicationPassword -}}
|
||||
{{- else if .Values.replication.password -}}
|
||||
{{- .Values.replication.password -}}
|
||||
{{- else -}}
|
||||
{{- randAlphaNum 10 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return PostgreSQL username
|
||||
*/}}
|
||||
{{- define "postgresql.username" -}}
|
||||
{{- if .Values.global.postgresql.postgresqlUsername }}
|
||||
{{- .Values.global.postgresql.postgresqlUsername -}}
|
||||
{{- else -}}
|
||||
{{- .Values.postgresqlUsername -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/*
|
||||
Return PostgreSQL replication username
|
||||
*/}}
|
||||
{{- define "postgresql.replication.username" -}}
|
||||
{{- if .Values.global.postgresql.replicationUser }}
|
||||
{{- .Values.global.postgresql.replicationUser -}}
|
||||
{{- else -}}
|
||||
{{- .Values.replication.user -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return PostgreSQL port
|
||||
*/}}
|
||||
{{- define "postgresql.port" -}}
|
||||
{{- if .Values.global.postgresql.servicePort }}
|
||||
{{- .Values.global.postgresql.servicePort -}}
|
||||
{{- else -}}
|
||||
{{- .Values.service.port -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return PostgreSQL created database
|
||||
*/}}
|
||||
{{- define "postgresql.database" -}}
|
||||
{{- if .Values.global.postgresql.postgresqlDatabase }}
|
||||
{{- .Values.global.postgresql.postgresqlDatabase -}}
|
||||
{{- else if .Values.postgresqlDatabase -}}
|
||||
{{- .Values.postgresqlDatabase -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper image name to change the volume permissions
|
||||
*/}}
|
||||
{{- define "postgresql.volumePermissions.image" -}}
|
||||
{{- $registryName := .Values.volumePermissions.image.registry -}}
|
||||
{{- $repositoryName := .Values.volumePermissions.image.repository -}}
|
||||
{{- $tag := .Values.volumePermissions.image.tag | toString -}}
|
||||
{{/*
|
||||
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
||||
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
|
||||
Also, we can't use a single if because lazy evaluation is not an option
|
||||
*/}}
|
||||
{{- if .Values.global }}
|
||||
{{- if .Values.global.imageRegistry }}
|
||||
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper PostgreSQL metrics image name
|
||||
*/}}
|
||||
{{- define "postgresql.metrics.image" -}}
|
||||
{{- $registryName := default "docker.io" .Values.metrics.image.registry -}}
|
||||
{{- $repositoryName := .Values.metrics.image.repository -}}
|
||||
{{- $tag := default "latest" .Values.metrics.image.tag | toString -}}
|
||||
{{/*
|
||||
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
||||
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
|
||||
Also, we can't use a single if because lazy evaluation is not an option
|
||||
*/}}
|
||||
{{- if .Values.global }}
|
||||
{{- if .Values.global.imageRegistry }}
|
||||
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the password secret.
|
||||
*/}}
|
||||
{{- define "postgresql.secretName" -}}
|
||||
{{- if .Values.global.postgresql.existingSecret }}
|
||||
{{- printf "%s" (tpl .Values.global.postgresql.existingSecret $) -}}
|
||||
{{- else if .Values.existingSecret -}}
|
||||
{{- printf "%s" (tpl .Values.existingSecret $) -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s" (include "postgresql.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return true if we should use an existingSecret.
|
||||
*/}}
|
||||
{{- define "postgresql.useExistingSecret" -}}
|
||||
{{- if or .Values.global.postgresql.existingSecret .Values.existingSecret -}}
|
||||
{{- true -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return true if a secret object should be created
|
||||
*/}}
|
||||
{{- define "postgresql.createSecret" -}}
|
||||
{{- if not (include "postgresql.useExistingSecret" .) -}}
|
||||
{{- true -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the configuration ConfigMap name.
|
||||
*/}}
|
||||
{{- define "postgresql.configurationCM" -}}
|
||||
{{- if .Values.configurationConfigMap -}}
|
||||
{{- printf "%s" (tpl .Values.configurationConfigMap $) -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-configuration" (include "postgresql.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the extended configuration ConfigMap name.
|
||||
*/}}
|
||||
{{- define "postgresql.extendedConfigurationCM" -}}
|
||||
{{- if .Values.extendedConfConfigMap -}}
|
||||
{{- printf "%s" (tpl .Values.extendedConfConfigMap $) -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-extended-configuration" (include "postgresql.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return true if a configmap should be mounted with PostgreSQL configuration
|
||||
*/}}
|
||||
{{- define "postgresql.mountConfigurationCM" -}}
|
||||
{{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap }}
|
||||
{{- true -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the initialization scripts ConfigMap name.
|
||||
*/}}
|
||||
{{- define "postgresql.initdbScriptsCM" -}}
|
||||
{{- if .Values.initdbScriptsConfigMap -}}
|
||||
{{- printf "%s" (tpl .Values.initdbScriptsConfigMap $) -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-init-scripts" (include "postgresql.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the initialization scripts Secret name.
|
||||
*/}}
|
||||
{{- define "postgresql.initdbScriptsSecret" -}}
|
||||
{{- printf "%s" (tpl .Values.initdbScriptsSecret $) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the metrics ConfigMap name.
|
||||
*/}}
|
||||
{{- define "postgresql.metricsCM" -}}
|
||||
{{- printf "%s-metrics" (include "postgresql.fullname" .) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper Docker Image Registry Secret Names
|
||||
*/}}
|
||||
{{- define "postgresql.imagePullSecrets" -}}
|
||||
{{/*
|
||||
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
||||
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
|
||||
Also, we can not use a single if because lazy evaluation is not an option
|
||||
*/}}
|
||||
{{- if .Values.global }}
|
||||
{{- if .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- range .Values.global.imagePullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets .Values.volumePermissions.image.pullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- range .Values.image.pullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- range .Values.metrics.image.pullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- range .Values.volumePermissions.image.pullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets .Values.volumePermissions.image.pullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- range .Values.image.pullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- range .Values.metrics.image.pullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- range .Values.volumePermissions.image.pullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the readiness probe command
|
||||
*/}}
|
||||
{{- define "postgresql.readinessProbeCommand" -}}
|
||||
- |
|
||||
{{- if (include "postgresql.database" .) }}
|
||||
exec pg_isready -U {{ include "postgresql.username" . | quote }} -d "dbname={{ include "postgresql.database" . }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}{{- end }}" -h 127.0.0.1 -p {{ template "postgresql.port" . }}
|
||||
{{- else }}
|
||||
exec pg_isready -U {{ include "postgresql.username" . | quote }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} -d "sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}"{{- end }} -h 127.0.0.1 -p {{ template "postgresql.port" . }}
|
||||
{{- end }}
|
||||
{{- if contains "bitnami/" .Values.image.repository }}
|
||||
[ -f /opt/bitnami/postgresql/tmp/.initialized ] || [ -f /bitnami/postgresql/.initialized ]
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper Storage Class
|
||||
*/}}
|
||||
{{- define "postgresql.storageClass" -}}
|
||||
{{/*
|
||||
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
||||
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
|
||||
*/}}
|
||||
{{- if .Values.global -}}
|
||||
{{- if .Values.global.storageClass -}}
|
||||
{{- if (eq "-" .Values.global.storageClass) -}}
|
||||
{{- printf "storageClassName: \"\"" -}}
|
||||
{{- else }}
|
||||
{{- printf "storageClassName: %s" .Values.global.storageClass -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- if .Values.persistence.storageClass -}}
|
||||
{{- if (eq "-" .Values.persistence.storageClass) -}}
|
||||
{{- printf "storageClassName: \"\"" -}}
|
||||
{{- else }}
|
||||
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- if .Values.persistence.storageClass -}}
|
||||
{{- if (eq "-" .Values.persistence.storageClass) -}}
|
||||
{{- printf "storageClassName: \"\"" -}}
|
||||
{{- else }}
|
||||
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiVersion for statefulset.
|
||||
*/}}
|
||||
{{- define "postgresql.statefulset.apiVersion" -}}
|
||||
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
{{- print "apps/v1beta2" -}}
|
||||
{{- else -}}
|
||||
{{- print "apps/v1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Compile all warnings into a single message, and call fail.
|
||||
*/}}
|
||||
{{- define "postgresql.validateValues" -}}
|
||||
{{- $messages := list -}}
|
||||
{{- $messages := append $messages (include "postgresql.validateValues.ldapConfigurationMethod" .) -}}
|
||||
{{- $messages := append $messages (include "postgresql.validateValues.psp" .) -}}
|
||||
{{- $messages := append $messages (include "postgresql.validateValues.tls" .) -}}
|
||||
{{- $messages := without $messages "" -}}
|
||||
{{- $message := join "\n" $messages -}}
|
||||
|
||||
{{- if $message -}}
|
||||
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate values of Postgresql - If ldap.url is used then you don't need the other settings for ldap
|
||||
*/}}
|
||||
{{- define "postgresql.validateValues.ldapConfigurationMethod" -}}
|
||||
{{- if and .Values.ldap.enabled (and (not (empty .Values.ldap.url)) (not (empty .Values.ldap.server))) }}
|
||||
postgresql: ldap.url, ldap.server
|
||||
You cannot set both `ldap.url` and `ldap.server` at the same time.
|
||||
Please provide a unique way to configure LDAP.
|
||||
More info at https://www.postgresql.org/docs/current/auth-ldap.html
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate values of Postgresql - If PSP is enabled RBAC should be enabled too
|
||||
*/}}
|
||||
{{- define "postgresql.validateValues.psp" -}}
|
||||
{{- if and .Values.psp.create (not .Values.rbac.create) }}
|
||||
postgresql: psp.create, rbac.create
|
||||
RBAC should be enabled if PSP is enabled in order for PSP to work.
|
||||
More info at https://kubernetes.io/docs/concepts/policy/pod-security-policy/#authorizing-policies
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiVersion for podsecuritypolicy.
|
||||
*/}}
|
||||
{{- define "podsecuritypolicy.apiVersion" -}}
|
||||
{{- if semverCompare "<1.10-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
{{- print "extensions/v1beta1" -}}
|
||||
{{- else -}}
|
||||
{{- print "policy/v1beta1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate values of Postgresql TLS - When TLS is enabled, so must be VolumePermissions
|
||||
*/}}
|
||||
{{- define "postgresql.validateValues.tls" -}}
|
||||
{{- if and .Values.tls.enabled (not .Values.volumePermissions.enabled) }}
|
||||
postgresql: tls.enabled, volumePermissions.enabled
|
||||
When TLS is enabled you must enable volumePermissions as well to ensure certificates files have
|
||||
the right permissions.
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the cert file.
|
||||
*/}}
|
||||
{{- define "postgresql.tlsCert" -}}
|
||||
{{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/bitnami/postgresql/certs/%s" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the cert key file.
|
||||
*/}}
|
||||
{{- define "postgresql.tlsCertKey" -}}
|
||||
{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/bitnami/postgresql/certs/%s" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the CA cert file.
|
||||
*/}}
|
||||
{{- define "postgresql.tlsCACert" -}}
|
||||
{{- printf "/opt/bitnami/postgresql/certs/%s" .Values.tls.certCAFilename -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the CRL file.
|
||||
*/}}
|
||||
{{- define "postgresql.tlsCRL" -}}
|
||||
{{- if .Values.tls.crlFilename -}}
|
||||
{{- printf "/opt/bitnami/postgresql/certs/%s" .Values.tls.crlFilename -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
26
nextcloud/charts/postgresql/templates/configmap.yaml
Normal file
26
nextcloud/charts/postgresql/templates/configmap.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
{{ if and (or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration) (not .Values.configurationConfigMap) }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}-configuration
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
{{- if (.Files.Glob "files/postgresql.conf") }}
|
||||
{{ (.Files.Glob "files/postgresql.conf").AsConfig | indent 2 }}
|
||||
{{- else if .Values.postgresqlConfiguration }}
|
||||
postgresql.conf: |
|
||||
{{- range $key, $value := default dict .Values.postgresqlConfiguration }}
|
||||
{{ $key | snakecase }}={{ $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if (.Files.Glob "files/pg_hba.conf") }}
|
||||
{{ (.Files.Glob "files/pg_hba.conf").AsConfig | indent 2 }}
|
||||
{{- else if .Values.pgHbaConfiguration }}
|
||||
pg_hba.conf: |
|
||||
{{ .Values.pgHbaConfiguration | indent 4 }}
|
||||
{{- end }}
|
||||
{{ end }}
|
@ -0,0 +1,21 @@
|
||||
{{- if and (or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf) (not .Values.extendedConfConfigMap)}}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}-extended-configuration
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
{{- with .Files.Glob "files/conf.d/*.conf" }}
|
||||
{{ .AsConfig | indent 2 }}
|
||||
{{- end }}
|
||||
{{ with .Values.postgresqlExtendedConf }}
|
||||
override.conf: |
|
||||
{{- range $key, $value := . }}
|
||||
{{ $key | snakecase }}={{ $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
4
nextcloud/charts/postgresql/templates/extra-list.yaml
Normal file
4
nextcloud/charts/postgresql/templates/extra-list.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
{{- range .Values.extraDeploy }}
|
||||
---
|
||||
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
|
||||
{{- end }}
|
@ -0,0 +1,24 @@
|
||||
{{- if and (or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.initdbScripts) (not .Values.initdbScriptsConfigMap) }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}-init-scripts
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Files.Glob "files/docker-entrypoint-initdb.d/*.sql.gz" }}
|
||||
binaryData:
|
||||
{{- range $path, $bytes := . }}
|
||||
{{ base $path }}: {{ $.Files.Get $path | b64enc | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
data:
|
||||
{{- with .Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql}" }}
|
||||
{{ .AsConfig | indent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.initdbScripts }}
|
||||
{{ toYaml . | indent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
13
nextcloud/charts/postgresql/templates/metrics-configmap.yaml
Normal file
13
nextcloud/charts/postgresql/templates/metrics-configmap.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.customMetrics }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "postgresql.metricsCM" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
custom-metrics.yaml: {{ toYaml .Values.metrics.customMetrics | quote }}
|
||||
{{- end }}
|
25
nextcloud/charts/postgresql/templates/metrics-svc.yaml
Normal file
25
nextcloud/charts/postgresql/templates/metrics-svc.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
{{- if .Values.metrics.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}-metrics
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
annotations:
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- toYaml .Values.metrics.service.annotations | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.metrics.service.type }}
|
||||
{{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerIP }}
|
||||
loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http-metrics
|
||||
port: 9187
|
||||
targetPort: http-metrics
|
||||
selector:
|
||||
{{- include "common.labels.matchLabels" . | nindent 4 }}
|
||||
role: master
|
||||
{{- end }}
|
38
nextcloud/charts/postgresql/templates/networkpolicy.yaml
Normal file
38
nextcloud/charts/postgresql/templates/networkpolicy.yaml
Normal file
@ -0,0 +1,38 @@
|
||||
{{- if .Values.networkPolicy.enabled }}
|
||||
kind: NetworkPolicy
|
||||
apiVersion: {{ template "postgresql.networkPolicy.apiVersion" . }}
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
{{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
ingress:
|
||||
# Allow inbound connections
|
||||
- ports:
|
||||
- port: {{ template "postgresql.port" . }}
|
||||
{{- if not .Values.networkPolicy.allowExternal }}
|
||||
from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
{{ template "postgresql.fullname" . }}-client: "true"
|
||||
{{- if .Values.networkPolicy.explicitNamespacesSelector }}
|
||||
namespaceSelector:
|
||||
{{ toYaml .Values.networkPolicy.explicitNamespacesSelector | indent 12 }}
|
||||
{{- end }}
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
{{- include "common.labels.matchLabels" . | nindent 14 }}
|
||||
role: slave
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
# Allow prometheus scrapes
|
||||
- ports:
|
||||
- port: 9187
|
||||
{{- end }}
|
||||
{{- end }}
|
37
nextcloud/charts/postgresql/templates/podsecuritypolicy.yaml
Normal file
37
nextcloud/charts/postgresql/templates/podsecuritypolicy.yaml
Normal file
@ -0,0 +1,37 @@
|
||||
{{- if .Values.psp.create }}
|
||||
apiVersion: {{ include "podsecuritypolicy.apiVersion" . }}
|
||||
kind: PodSecurityPolicy
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
privileged: false
|
||||
volumes:
|
||||
- 'configMap'
|
||||
- 'secret'
|
||||
- 'persistentVolumeClaim'
|
||||
- 'emptyDir'
|
||||
- 'projected'
|
||||
hostNetwork: false
|
||||
hostIPC: false
|
||||
hostPID: false
|
||||
runAsUser:
|
||||
rule: 'RunAsAny'
|
||||
seLinux:
|
||||
rule: 'RunAsAny'
|
||||
supplementalGroups:
|
||||
rule: 'MustRunAs'
|
||||
ranges:
|
||||
- min: 1
|
||||
max: 65535
|
||||
fsGroup:
|
||||
rule: 'MustRunAs'
|
||||
ranges:
|
||||
- min: 1
|
||||
max: 65535
|
||||
readOnlyRootFilesystem: false
|
||||
{{- end }}
|
23
nextcloud/charts/postgresql/templates/prometheusrule.yaml
Normal file
23
nextcloud/charts/postgresql/templates/prometheusrule.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
{{- with .Values.metrics.prometheusRule.namespace }}
|
||||
namespace: {{ . }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- with .Values.metrics.prometheusRule.additionalLabels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.metrics.prometheusRule.rules }}
|
||||
groups:
|
||||
- name: {{ template "postgresql.name" $ }}
|
||||
rules: {{ tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
19
nextcloud/charts/postgresql/templates/role.yaml
Normal file
19
nextcloud/charts/postgresql/templates/role.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
{{- if .Values.rbac.create }}
|
||||
kind: Role
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- if .Values.psp.create }}
|
||||
- apiGroups: ["extensions"]
|
||||
resources: ["podsecuritypolicies"]
|
||||
verbs: ["use"]
|
||||
resourceNames:
|
||||
- {{ template "postgresql.fullname" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
19
nextcloud/charts/postgresql/templates/rolebinding.yaml
Normal file
19
nextcloud/charts/postgresql/templates/rolebinding.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
{{- if .Values.rbac.create }}
|
||||
kind: RoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ default (include "postgresql.fullname" . ) .Values.serviceAccount.name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
21
nextcloud/charts/postgresql/templates/secrets.yaml
Normal file
21
nextcloud/charts/postgresql/templates/secrets.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
{{- if (include "postgresql.createSecret" .) }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
type: Opaque
|
||||
data:
|
||||
postgresql-postgres-password: {{ include "postgresql.postgres.password" . | b64enc | quote }}
|
||||
postgresql-password: {{ include "postgresql.password" . | b64enc | quote }}
|
||||
{{- if .Values.replication.enabled }}
|
||||
postgresql-replication-password: {{ include "postgresql.replication.password" . | b64enc | quote }}
|
||||
{{- end }}
|
||||
{{- if (and .Values.ldap.enabled .Values.ldap.bind_password)}}
|
||||
postgresql-ldap-password: {{ .Values.ldap.bind_password | b64enc | quote }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
11
nextcloud/charts/postgresql/templates/serviceaccount.yaml
Normal file
11
nextcloud/charts/postgresql/templates/serviceaccount.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
{{- if and (.Values.serviceAccount.enabled) (not .Values.serviceAccount.name) }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
33
nextcloud/charts/postgresql/templates/servicemonitor.yaml
Normal file
33
nextcloud/charts/postgresql/templates/servicemonitor.yaml
Normal file
@ -0,0 +1,33 @@
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ include "postgresql.fullname" . }}
|
||||
{{- if .Values.metrics.serviceMonitor.namespace }}
|
||||
namespace: {{ .Values.metrics.serviceMonitor.namespace }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.metrics.serviceMonitor.additionalLabels }}
|
||||
{{- toYaml .Values.metrics.serviceMonitor.additionalLabels | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
|
||||
spec:
|
||||
endpoints:
|
||||
- port: http-metrics
|
||||
{{- if .Values.metrics.serviceMonitor.interval }}
|
||||
interval: {{ .Values.metrics.serviceMonitor.interval }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
|
||||
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
|
||||
{{- end }}
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- {{ .Release.Namespace }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
{{- end }}
|
403
nextcloud/charts/postgresql/templates/statefulset-slaves.yaml
Normal file
403
nextcloud/charts/postgresql/templates/statefulset-slaves.yaml
Normal file
@ -0,0 +1,403 @@
|
||||
{{- if .Values.replication.enabled }}
|
||||
{{- $slaveResources := coalesce .Values.slave.resources .Values.resources -}}
|
||||
apiVersion: {{ template "postgresql.statefulset.apiVersion" . }}
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: "{{ template "postgresql.fullname" . }}-slave"
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- with .Values.slave.labels }}
|
||||
{{ toYaml . | indent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.slave.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceName: {{ template "postgresql.fullname" . }}-headless
|
||||
replicas: {{ .Values.replication.slaveReplicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
role: slave
|
||||
template:
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 8 }}
|
||||
role: slave
|
||||
{{- with .Values.slave.podLabels }}
|
||||
{{ toYaml . | indent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.slave.podAnnotations }}
|
||||
annotations:
|
||||
{{ toYaml . | indent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.schedulerName }}
|
||||
schedulerName: "{{ .Values.schedulerName }}"
|
||||
{{- end }}
|
||||
{{- include "postgresql.imagePullSecrets" . | indent 6 }}
|
||||
{{- if .Values.slave.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.slave.nodeSelector | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.slave.affinity }}
|
||||
affinity:
|
||||
{{ toYaml .Values.slave.affinity | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.slave.tolerations }}
|
||||
tolerations:
|
||||
{{ toYaml .Values.slave.tolerations | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.terminationGracePeriodSeconds }}
|
||||
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
|
||||
{{- end }}
|
||||
{{- if .Values.securityContext.enabled }}
|
||||
securityContext: {{- omit .Values.securityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.serviceAccount.enabled }}
|
||||
serviceAccountName: {{ default (include "postgresql.fullname" . ) .Values.serviceAccount.name}}
|
||||
{{- end }}
|
||||
{{- if or .Values.slave.extraInitContainers (and .Values.volumePermissions.enabled (or .Values.persistence.enabled (and .Values.shmVolume.enabled .Values.shmVolume.chmod.enabled))) }}
|
||||
initContainers:
|
||||
{{- if and .Values.volumePermissions.enabled (or .Values.persistence.enabled (and .Values.shmVolume.enabled .Values.shmVolume.chmod.enabled) .Values.tls.enabled) }}
|
||||
- name: init-chmod-data
|
||||
image: {{ template "postgresql.volumePermissions.image" . }}
|
||||
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||
{{- if .Values.resources }}
|
||||
resources: {{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
command:
|
||||
- /bin/sh
|
||||
- -cx
|
||||
- |
|
||||
{{- if .Values.persistence.enabled }}
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
chown `id -u`:`id -G | cut -d " " -f2` {{ .Values.persistence.mountPath }}
|
||||
{{- else }}
|
||||
chown {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} {{ .Values.persistence.mountPath }}
|
||||
{{- end }}
|
||||
mkdir -p {{ .Values.persistence.mountPath }}/data {{- if (include "postgresql.mountConfigurationCM" .) }} {{ .Values.persistence.mountPath }}/conf {{- end }}
|
||||
chmod 700 {{ .Values.persistence.mountPath }}/data {{- if (include "postgresql.mountConfigurationCM" .) }} {{ .Values.persistence.mountPath }}/conf {{- end }}
|
||||
find {{ .Values.persistence.mountPath }} -mindepth 1 -maxdepth 1 {{- if not (include "postgresql.mountConfigurationCM" .) }} -not -name "conf" {{- end }} -not -name ".snapshot" -not -name "lost+found" | \
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
xargs chown -R `id -u`:`id -G | cut -d " " -f2`
|
||||
{{- else }}
|
||||
xargs chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and .Values.shmVolume.enabled .Values.shmVolume.chmod.enabled }}
|
||||
chmod -R 777 /dev/shm
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
cp /tmp/certs/* /opt/bitnami/postgresql/certs/
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
chown -R `id -u`:`id -G | cut -d " " -f2` /opt/bitnami/postgresql/certs/
|
||||
{{- else }}
|
||||
chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} /opt/bitnami/postgresql/certs/
|
||||
{{- end }}
|
||||
chmod 600 {{ template "postgresql.tlsCertKey" . }}
|
||||
{{- end }}
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
securityContext: {{- omit .Values.volumePermissions.securityContext "runAsUser" | toYaml | nindent 12 }}
|
||||
{{- else }}
|
||||
securityContext: {{- .Values.volumePermissions.securityContext | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{ if .Values.persistence.enabled }}
|
||||
- name: data
|
||||
mountPath: {{ .Values.persistence.mountPath }}
|
||||
subPath: {{ .Values.persistence.subPath }}
|
||||
{{- end }}
|
||||
{{- if .Values.shmVolume.enabled }}
|
||||
- name: dshm
|
||||
mountPath: /dev/shm
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: raw-certificates
|
||||
mountPath: /tmp/certs
|
||||
- name: postgresql-certificates
|
||||
mountPath: /opt/bitnami/postgresql/certs
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.slave.extraInitContainers }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.slave.extraInitContainers "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.slave.priorityClassName }}
|
||||
priorityClassName: {{ .Values.slave.priorityClassName }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ template "postgresql.fullname" . }}
|
||||
image: {{ template "postgresql.image" . }}
|
||||
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
|
||||
{{- if $slaveResources }}
|
||||
resources: {{- toYaml $slaveResources | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: BITNAMI_DEBUG
|
||||
value: {{ ternary "true" "false" .Values.image.debug | quote }}
|
||||
- name: POSTGRESQL_VOLUME_DIR
|
||||
value: "{{ .Values.persistence.mountPath }}"
|
||||
- name: POSTGRESQL_PORT_NUMBER
|
||||
value: "{{ template "postgresql.port" . }}"
|
||||
{{- if .Values.persistence.mountPath }}
|
||||
- name: PGDATA
|
||||
value: {{ .Values.postgresqlDataDir | quote }}
|
||||
{{- end }}
|
||||
- name: POSTGRES_REPLICATION_MODE
|
||||
value: "slave"
|
||||
- name: POSTGRES_REPLICATION_USER
|
||||
value: {{ include "postgresql.replication.username" . | quote }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: POSTGRES_REPLICATION_PASSWORD_FILE
|
||||
value: "/opt/bitnami/postgresql/secrets/postgresql-replication-password"
|
||||
{{- else }}
|
||||
- name: POSTGRES_REPLICATION_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-replication-password
|
||||
{{- end }}
|
||||
- name: POSTGRES_CLUSTER_APP_NAME
|
||||
value: {{ .Values.replication.applicationName }}
|
||||
- name: POSTGRES_MASTER_HOST
|
||||
value: {{ template "postgresql.fullname" . }}
|
||||
- name: POSTGRES_MASTER_PORT_NUMBER
|
||||
value: {{ include "postgresql.port" . | quote }}
|
||||
{{- if and (not (eq .Values.postgresqlUsername "postgres")) (or .Values.postgresqlPostgresPassword (include "postgresql.useExistingSecret" .)) }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: POSTGRES_POSTGRES_PASSWORD_FILE
|
||||
value: "/opt/bitnami/postgresql/secrets/postgresql-postgres-password"
|
||||
{{- else }}
|
||||
- name: POSTGRES_POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-postgres-password
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: POSTGRES_PASSWORD_FILE
|
||||
value: "/opt/bitnami/postgresql/secrets/postgresql-password"
|
||||
{{- else }}
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-password
|
||||
{{- end }}
|
||||
- name: POSTGRESQL_ENABLE_TLS
|
||||
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: POSTGRESQL_TLS_PREFER_SERVER_CIPHERS
|
||||
value: {{ ternary "yes" "no" .Values.tls.preferServerCiphers | quote }}
|
||||
- name: POSTGRESQL_TLS_CERT_FILE
|
||||
value: {{ template "postgresql.tlsCert" . }}
|
||||
- name: POSTGRESQL_TLS_KEY_FILE
|
||||
value: {{ template "postgresql.tlsCertKey" . }}
|
||||
{{- if .Values.tls.certCAFilename }}
|
||||
- name: POSTGRESQL_TLS_CA_FILE
|
||||
value: {{ template "postgresql.tlsCACert" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.crlFilename }}
|
||||
- name: POSTGRESQL_TLS_CRL_FILE
|
||||
value: {{ template "postgresql.tlsCRL" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: POSTGRESQL_LOG_HOSTNAME
|
||||
value: {{ .Values.audit.logHostname | quote }}
|
||||
- name: POSTGRESQL_LOG_CONNECTIONS
|
||||
value: {{ .Values.audit.logConnections | quote }}
|
||||
- name: POSTGRESQL_LOG_DISCONNECTIONS
|
||||
value: {{ .Values.audit.logDisconnections | quote }}
|
||||
{{- if .Values.audit.logLinePrefix }}
|
||||
- name: POSTGRESQL_LOG_LINE_PREFIX
|
||||
value: {{ .Values.audit.logLinePrefix | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.audit.logTimezone }}
|
||||
- name: POSTGRESQL_LOG_TIMEZONE
|
||||
value: {{ .Values.audit.logTimezone | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.audit.pgAuditLog }}
|
||||
- name: POSTGRESQL_PGAUDIT_LOG
|
||||
value: {{ .Values.audit.pgAuditLog | quote }}
|
||||
{{- end }}
|
||||
- name: POSTGRESQL_PGAUDIT_LOG_CATALOG
|
||||
value: {{ .Values.audit.pgAuditLogCatalog | quote }}
|
||||
- name: POSTGRESQL_CLIENT_MIN_MESSAGES
|
||||
value: {{ .Values.audit.clientMinMessages | quote }}
|
||||
- name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
|
||||
value: {{ .Values.postgresqlSharedPreloadLibraries | quote }}
|
||||
{{- if .Values.postgresqlMaxConnections }}
|
||||
- name: POSTGRESQL_MAX_CONNECTIONS
|
||||
value: {{ .Values.postgresqlMaxConnections | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlPostgresConnectionLimit }}
|
||||
- name: POSTGRESQL_POSTGRES_CONNECTION_LIMIT
|
||||
value: {{ .Values.postgresqlPostgresConnectionLimit | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlDbUserConnectionLimit }}
|
||||
- name: POSTGRESQL_USERNAME_CONNECTION_LIMIT
|
||||
value: {{ .Values.postgresqlDbUserConnectionLimit | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlTcpKeepalivesInterval }}
|
||||
- name: POSTGRESQL_TCP_KEEPALIVES_INTERVAL
|
||||
value: {{ .Values.postgresqlTcpKeepalivesInterval | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlTcpKeepalivesIdle }}
|
||||
- name: POSTGRESQL_TCP_KEEPALIVES_IDLE
|
||||
value: {{ .Values.postgresqlTcpKeepalivesIdle | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlStatementTimeout }}
|
||||
- name: POSTGRESQL_STATEMENT_TIMEOUT
|
||||
value: {{ .Values.postgresqlStatementTimeout | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlTcpKeealivesCount }}
|
||||
- name: POSTGRESQL_TCP_KEEPALIVES_COUNT
|
||||
value: {{ .Values.postgresqlTcpKeealivesCount | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlPghbaRemoveFilters }}
|
||||
- name: POSTGRESQL_PGHBA_REMOVE_FILTERS
|
||||
value: {{ .Values.postgresqlPghbaRemoveFilters | quote }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-postgresql
|
||||
containerPort: {{ template "postgresql.port" . }}
|
||||
{{- if .Values.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
{{- if (include "postgresql.database" .) }}
|
||||
- exec pg_isready -U {{ include "postgresql.username" . | quote }} -d "dbname={{ include "postgresql.database" . }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}{{- end }}" -h 127.0.0.1 -p {{ template "postgresql.port" . }}
|
||||
{{- else }}
|
||||
- exec pg_isready -U {{ include "postgresql.username" . | quote }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} -d "sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}"{{- end }} -h 127.0.0.1 -p {{ template "postgresql.port" . }}
|
||||
{{- end }}
|
||||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
|
||||
{{- else if .Values.customLivenessProbe }}
|
||||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- -e
|
||||
{{- include "postgresql.readinessProbeCommand" . | nindent 16 }}
|
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
||||
{{- else if .Values.customReadinessProbe }}
|
||||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: postgresql-password
|
||||
mountPath: /opt/bitnami/postgresql/secrets/
|
||||
{{- end }}
|
||||
{{- if .Values.shmVolume.enabled }}
|
||||
- name: dshm
|
||||
mountPath: /dev/shm
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.enabled }}
|
||||
- name: data
|
||||
mountPath: {{ .Values.persistence.mountPath }}
|
||||
subPath: {{ .Values.persistence.subPath }}
|
||||
{{ end }}
|
||||
{{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
|
||||
- name: postgresql-extended-config
|
||||
mountPath: /bitnami/postgresql/conf/conf.d/
|
||||
{{- end }}
|
||||
{{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap }}
|
||||
- name: postgresql-config
|
||||
mountPath: /bitnami/postgresql/conf
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: postgresql-certificates
|
||||
mountPath: /opt/bitnami/postgresql/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.slave.extraVolumeMounts }}
|
||||
{{- toYaml .Values.slave.extraVolumeMounts | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.slave.sidecars }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.slave.sidecars "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: postgresql-password
|
||||
secret:
|
||||
secretName: {{ template "postgresql.secretName" . }}
|
||||
{{- end }}
|
||||
{{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap}}
|
||||
- name: postgresql-config
|
||||
configMap:
|
||||
name: {{ template "postgresql.configurationCM" . }}
|
||||
{{- end }}
|
||||
{{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
|
||||
- name: postgresql-extended-config
|
||||
configMap:
|
||||
name: {{ template "postgresql.extendedConfigurationCM" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: raw-certificates
|
||||
secret:
|
||||
secretName: {{ required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret }}
|
||||
- name: postgresql-certificates
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.shmVolume.enabled }}
|
||||
- name: dshm
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 1Gi
|
||||
{{- end }}
|
||||
{{- if or (not .Values.persistence.enabled) (not .Values.slave.persistence.enabled) }}
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.slave.extraVolumes }}
|
||||
{{- toYaml .Values.slave.extraVolumes | nindent 8 }}
|
||||
{{- end }}
|
||||
updateStrategy:
|
||||
type: {{ .Values.updateStrategy.type }}
|
||||
{{- if (eq "Recreate" .Values.updateStrategy.type) }}
|
||||
rollingUpdate: null
|
||||
{{- end }}
|
||||
{{- if and .Values.persistence.enabled .Values.slave.persistence.enabled }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
{{- with .Values.persistence.annotations }}
|
||||
annotations:
|
||||
{{- range $key, $value := . }}
|
||||
{{ $key }}: {{ $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- range .Values.persistence.accessModes }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size | quote }}
|
||||
{{ include "postgresql.storageClass" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
580
nextcloud/charts/postgresql/templates/statefulset.yaml
Normal file
580
nextcloud/charts/postgresql/templates/statefulset.yaml
Normal file
@ -0,0 +1,580 @@
|
||||
apiVersion: {{ template "postgresql.statefulset.apiVersion" . }}
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ template "postgresql.master.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- with .Values.master.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.master.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceName: {{ template "postgresql.fullname" . }}-headless
|
||||
replicas: 1
|
||||
updateStrategy:
|
||||
type: {{ .Values.updateStrategy.type }}
|
||||
{{- if (eq "Recreate" .Values.updateStrategy.type) }}
|
||||
rollingUpdate: null
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
role: master
|
||||
template:
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 8 }}
|
||||
role: master
|
||||
{{- with .Values.master.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.master.podAnnotations }}
|
||||
annotations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.schedulerName }}
|
||||
schedulerName: "{{ .Values.schedulerName }}"
|
||||
{{- end }}
|
||||
{{- include "postgresql.imagePullSecrets" . | indent 6 }}
|
||||
{{- if .Values.master.nodeSelector }}
|
||||
nodeSelector: {{- toYaml .Values.master.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.affinity }}
|
||||
affinity: {{- toYaml .Values.master.affinity | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.tolerations }}
|
||||
tolerations: {{- toYaml .Values.master.tolerations | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.terminationGracePeriodSeconds }}
|
||||
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
|
||||
{{- end }}
|
||||
{{- if .Values.securityContext.enabled }}
|
||||
securityContext: {{- omit .Values.securityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.serviceAccount.enabled }}
|
||||
serviceAccountName: {{ default (include "postgresql.fullname" . ) .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- if or .Values.master.extraInitContainers (and .Values.volumePermissions.enabled (or .Values.persistence.enabled (and .Values.shmVolume.enabled .Values.shmVolume.chmod.enabled))) }}
|
||||
initContainers:
|
||||
{{- if and .Values.volumePermissions.enabled (or .Values.persistence.enabled (and .Values.shmVolume.enabled .Values.shmVolume.chmod.enabled) .Values.tls.enabled) }}
|
||||
- name: init-chmod-data
|
||||
image: {{ template "postgresql.volumePermissions.image" . }}
|
||||
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||
{{- if .Values.resources }}
|
||||
resources: {{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
command:
|
||||
- /bin/sh
|
||||
- -cx
|
||||
- |
|
||||
{{- if .Values.persistence.enabled }}
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
chown `id -u`:`id -G | cut -d " " -f2` {{ .Values.persistence.mountPath }}
|
||||
{{- else }}
|
||||
chown {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} {{ .Values.persistence.mountPath }}
|
||||
{{- end }}
|
||||
mkdir -p {{ .Values.persistence.mountPath }}/data {{- if (include "postgresql.mountConfigurationCM" .) }} {{ .Values.persistence.mountPath }}/conf {{- end }}
|
||||
chmod 700 {{ .Values.persistence.mountPath }}/data {{- if (include "postgresql.mountConfigurationCM" .) }} {{ .Values.persistence.mountPath }}/conf {{- end }}
|
||||
find {{ .Values.persistence.mountPath }} -mindepth 1 -maxdepth 1 {{- if not (include "postgresql.mountConfigurationCM" .) }} -not -name "conf" {{- end }} -not -name ".snapshot" -not -name "lost+found" | \
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
xargs chown -R `id -u`:`id -G | cut -d " " -f2`
|
||||
{{- else }}
|
||||
xargs chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and .Values.shmVolume.enabled .Values.shmVolume.chmod.enabled }}
|
||||
chmod -R 777 /dev/shm
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
cp /tmp/certs/* /opt/bitnami/postgresql/certs/
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
chown -R `id -u`:`id -G | cut -d " " -f2` /opt/bitnami/postgresql/certs/
|
||||
{{- else }}
|
||||
chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} /opt/bitnami/postgresql/certs/
|
||||
{{- end }}
|
||||
chmod 600 {{ template "postgresql.tlsCertKey" . }}
|
||||
{{- end }}
|
||||
{{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
|
||||
securityContext: {{- omit .Values.volumePermissions.securityContext "runAsUser" | toYaml | nindent 12 }}
|
||||
{{- else }}
|
||||
securityContext: {{- .Values.volumePermissions.securityContext | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- if .Values.persistence.enabled }}
|
||||
- name: data
|
||||
mountPath: {{ .Values.persistence.mountPath }}
|
||||
subPath: {{ .Values.persistence.subPath }}
|
||||
{{- end }}
|
||||
{{- if .Values.shmVolume.enabled }}
|
||||
- name: dshm
|
||||
mountPath: /dev/shm
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: raw-certificates
|
||||
mountPath: /tmp/certs
|
||||
- name: postgresql-certificates
|
||||
mountPath: /opt/bitnami/postgresql/certs
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.extraInitContainers }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.extraInitContainers "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.priorityClassName }}
|
||||
priorityClassName: {{ .Values.master.priorityClassName }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ template "postgresql.fullname" . }}
|
||||
image: {{ template "postgresql.image" . }}
|
||||
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
|
||||
{{- if .Values.resources }}
|
||||
resources: {{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: BITNAMI_DEBUG
|
||||
value: {{ ternary "true" "false" .Values.image.debug | quote }}
|
||||
- name: POSTGRESQL_PORT_NUMBER
|
||||
value: "{{ template "postgresql.port" . }}"
|
||||
- name: POSTGRESQL_VOLUME_DIR
|
||||
value: "{{ .Values.persistence.mountPath }}"
|
||||
{{- if .Values.postgresqlInitdbArgs }}
|
||||
- name: POSTGRES_INITDB_ARGS
|
||||
value: {{ .Values.postgresqlInitdbArgs | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlInitdbWalDir }}
|
||||
- name: POSTGRES_INITDB_WALDIR
|
||||
value: {{ .Values.postgresqlInitdbWalDir | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.initdbUser }}
|
||||
- name: POSTGRESQL_INITSCRIPTS_USERNAME
|
||||
value: {{ .Values.initdbUser }}
|
||||
{{- end }}
|
||||
{{- if .Values.initdbPassword }}
|
||||
- name: POSTGRESQL_INITSCRIPTS_PASSWORD
|
||||
value: {{ .Values.initdbPassword }}
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.mountPath }}
|
||||
- name: PGDATA
|
||||
value: {{ .Values.postgresqlDataDir | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.masterAsStandBy.enabled }}
|
||||
- name: POSTGRES_MASTER_HOST
|
||||
value: {{ .Values.masterAsStandBy.masterHost }}
|
||||
- name: POSTGRES_MASTER_PORT_NUMBER
|
||||
value: {{ .Values.masterAsStandBy.masterPort | quote }}
|
||||
{{- end }}
|
||||
{{- if or .Values.replication.enabled .Values.masterAsStandBy.enabled }}
|
||||
- name: POSTGRES_REPLICATION_MODE
|
||||
{{- if .Values.masterAsStandBy.enabled }}
|
||||
value: "slave"
|
||||
{{- else }}
|
||||
value: "master"
|
||||
{{- end }}
|
||||
- name: POSTGRES_REPLICATION_USER
|
||||
value: {{ include "postgresql.replication.username" . | quote }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: POSTGRES_REPLICATION_PASSWORD_FILE
|
||||
value: "/opt/bitnami/postgresql/secrets/postgresql-replication-password"
|
||||
{{- else }}
|
||||
- name: POSTGRES_REPLICATION_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-replication-password
|
||||
{{- end }}
|
||||
{{- if not (eq .Values.replication.synchronousCommit "off")}}
|
||||
- name: POSTGRES_SYNCHRONOUS_COMMIT_MODE
|
||||
value: {{ .Values.replication.synchronousCommit | quote }}
|
||||
- name: POSTGRES_NUM_SYNCHRONOUS_REPLICAS
|
||||
value: {{ .Values.replication.numSynchronousReplicas | quote }}
|
||||
{{- end }}
|
||||
- name: POSTGRES_CLUSTER_APP_NAME
|
||||
value: {{ .Values.replication.applicationName }}
|
||||
{{- end }}
|
||||
{{- if and (not (eq .Values.postgresqlUsername "postgres")) (or .Values.postgresqlPostgresPassword (include "postgresql.useExistingSecret" .)) }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: POSTGRES_POSTGRES_PASSWORD_FILE
|
||||
value: "/opt/bitnami/postgresql/secrets/postgresql-postgres-password"
|
||||
{{- else }}
|
||||
- name: POSTGRES_POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-postgres-password
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: POSTGRES_USER
|
||||
value: {{ include "postgresql.username" . | quote }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: POSTGRES_PASSWORD_FILE
|
||||
value: "/opt/bitnami/postgresql/secrets/postgresql-password"
|
||||
{{- else }}
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-password
|
||||
{{- end }}
|
||||
{{- if (include "postgresql.database" .) }}
|
||||
- name: POSTGRES_DB
|
||||
value: {{ (include "postgresql.database" .) | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.extraEnv }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnv "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
- name: POSTGRESQL_ENABLE_LDAP
|
||||
value: {{ ternary "yes" "no" .Values.ldap.enabled | quote }}
|
||||
{{- if .Values.ldap.enabled }}
|
||||
- name: POSTGRESQL_LDAP_SERVER
|
||||
value: {{ .Values.ldap.server }}
|
||||
- name: POSTGRESQL_LDAP_PORT
|
||||
value: {{ .Values.ldap.port | quote }}
|
||||
- name: POSTGRESQL_LDAP_SCHEME
|
||||
value: {{ .Values.ldap.scheme }}
|
||||
{{- if .Values.ldap.tls }}
|
||||
- name: POSTGRESQL_LDAP_TLS
|
||||
value: "1"
|
||||
{{- end }}
|
||||
- name: POSTGRESQL_LDAP_PREFIX
|
||||
value: {{ .Values.ldap.prefix | quote }}
|
||||
- name: POSTGRESQL_LDAP_SUFFIX
|
||||
value: {{ .Values.ldap.suffix | quote }}
|
||||
- name: POSTGRESQL_LDAP_BASE_DN
|
||||
value: {{ .Values.ldap.baseDN }}
|
||||
- name: POSTGRESQL_LDAP_BIND_DN
|
||||
value: {{ .Values.ldap.bindDN }}
|
||||
{{- if (not (empty .Values.ldap.bind_password)) }}
|
||||
- name: POSTGRESQL_LDAP_BIND_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-ldap-password
|
||||
{{- end}}
|
||||
- name: POSTGRESQL_LDAP_SEARCH_ATTR
|
||||
value: {{ .Values.ldap.search_attr }}
|
||||
- name: POSTGRESQL_LDAP_SEARCH_FILTER
|
||||
value: {{ .Values.ldap.search_filter }}
|
||||
- name: POSTGRESQL_LDAP_URL
|
||||
value: {{ .Values.ldap.url }}
|
||||
{{- end}}
|
||||
- name: POSTGRESQL_ENABLE_TLS
|
||||
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: POSTGRESQL_TLS_PREFER_SERVER_CIPHERS
|
||||
value: {{ ternary "yes" "no" .Values.tls.preferServerCiphers | quote }}
|
||||
- name: POSTGRESQL_TLS_CERT_FILE
|
||||
value: {{ template "postgresql.tlsCert" . }}
|
||||
- name: POSTGRESQL_TLS_KEY_FILE
|
||||
value: {{ template "postgresql.tlsCertKey" . }}
|
||||
{{- if .Values.tls.certCAFilename }}
|
||||
- name: POSTGRESQL_TLS_CA_FILE
|
||||
value: {{ template "postgresql.tlsCACert" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.crlFilename }}
|
||||
- name: POSTGRESQL_TLS_CRL_FILE
|
||||
value: {{ template "postgresql.tlsCRL" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: POSTGRESQL_LOG_HOSTNAME
|
||||
value: {{ .Values.audit.logHostname | quote }}
|
||||
- name: POSTGRESQL_LOG_CONNECTIONS
|
||||
value: {{ .Values.audit.logConnections | quote }}
|
||||
- name: POSTGRESQL_LOG_DISCONNECTIONS
|
||||
value: {{ .Values.audit.logDisconnections | quote }}
|
||||
{{- if .Values.audit.logLinePrefix }}
|
||||
- name: POSTGRESQL_LOG_LINE_PREFIX
|
||||
value: {{ .Values.audit.logLinePrefix | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.audit.logTimezone }}
|
||||
- name: POSTGRESQL_LOG_TIMEZONE
|
||||
value: {{ .Values.audit.logTimezone | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.audit.pgAuditLog }}
|
||||
- name: POSTGRESQL_PGAUDIT_LOG
|
||||
value: {{ .Values.audit.pgAuditLog | quote }}
|
||||
{{- end }}
|
||||
- name: POSTGRESQL_PGAUDIT_LOG_CATALOG
|
||||
value: {{ .Values.audit.pgAuditLogCatalog | quote }}
|
||||
- name: POSTGRESQL_CLIENT_MIN_MESSAGES
|
||||
value: {{ .Values.audit.clientMinMessages | quote }}
|
||||
- name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
|
||||
value: {{ .Values.postgresqlSharedPreloadLibraries | quote }}
|
||||
{{- if .Values.postgresqlMaxConnections }}
|
||||
- name: POSTGRESQL_MAX_CONNECTIONS
|
||||
value: {{ .Values.postgresqlMaxConnections | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlPostgresConnectionLimit }}
|
||||
- name: POSTGRESQL_POSTGRES_CONNECTION_LIMIT
|
||||
value: {{ .Values.postgresqlPostgresConnectionLimit | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlDbUserConnectionLimit }}
|
||||
- name: POSTGRESQL_USERNAME_CONNECTION_LIMIT
|
||||
value: {{ .Values.postgresqlDbUserConnectionLimit | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlTcpKeepalivesInterval }}
|
||||
- name: POSTGRESQL_TCP_KEEPALIVES_INTERVAL
|
||||
value: {{ .Values.postgresqlTcpKeepalivesInterval | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlTcpKeepalivesIdle }}
|
||||
- name: POSTGRESQL_TCP_KEEPALIVES_IDLE
|
||||
value: {{ .Values.postgresqlTcpKeepalivesIdle | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlStatementTimeout }}
|
||||
- name: POSTGRESQL_STATEMENT_TIMEOUT
|
||||
value: {{ .Values.postgresqlStatementTimeout | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlTcpKeealivesCount }}
|
||||
- name: POSTGRESQL_TCP_KEEPALIVES_COUNT
|
||||
value: {{ .Values.postgresqlTcpKeealivesCount | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.postgresqlPghbaRemoveFilters }}
|
||||
- name: POSTGRESQL_PGHBA_REMOVE_FILTERS
|
||||
value: {{ .Values.postgresqlPghbaRemoveFilters | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.extraEnvVarsCM }}
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: {{ tpl .Values.extraEnvVarsCM . }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-postgresql
|
||||
containerPort: {{ template "postgresql.port" . }}
|
||||
{{- if .Values.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
{{- if (include "postgresql.database" .) }}
|
||||
- exec pg_isready -U {{ include "postgresql.username" . | quote }} -d "dbname={{ include "postgresql.database" . }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}{{- end }}" -h 127.0.0.1 -p {{ template "postgresql.port" . }}
|
||||
{{- else }}
|
||||
- exec pg_isready -U {{ include "postgresql.username" . | quote }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} -d "sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}"{{- end }} -h 127.0.0.1 -p {{ template "postgresql.port" . }}
|
||||
{{- end }}
|
||||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
|
||||
{{- else if .Values.customLivenessProbe }}
|
||||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- -e
|
||||
{{- include "postgresql.readinessProbeCommand" . | nindent 16 }}
|
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
||||
{{- else if .Values.customReadinessProbe }}
|
||||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.initdbScriptsConfigMap .Values.initdbScripts }}
|
||||
- name: custom-init-scripts
|
||||
mountPath: /docker-entrypoint-initdb.d/
|
||||
{{- end }}
|
||||
{{- if .Values.initdbScriptsSecret }}
|
||||
- name: custom-init-scripts-secret
|
||||
mountPath: /docker-entrypoint-initdb.d/secret
|
||||
{{- end }}
|
||||
{{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
|
||||
- name: postgresql-extended-config
|
||||
mountPath: /bitnami/postgresql/conf/conf.d/
|
||||
{{- end }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: postgresql-password
|
||||
mountPath: /opt/bitnami/postgresql/secrets/
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: postgresql-certificates
|
||||
mountPath: /opt/bitnami/postgresql/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.shmVolume.enabled }}
|
||||
- name: dshm
|
||||
mountPath: /dev/shm
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.enabled }}
|
||||
- name: data
|
||||
mountPath: {{ .Values.persistence.mountPath }}
|
||||
subPath: {{ .Values.persistence.subPath }}
|
||||
{{- end }}
|
||||
{{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap }}
|
||||
- name: postgresql-config
|
||||
mountPath: /bitnami/postgresql/conf
|
||||
{{- end }}
|
||||
{{- if .Values.master.extraVolumeMounts }}
|
||||
{{- toYaml .Values.master.extraVolumeMounts | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.sidecars }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.sidecars "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
- name: metrics
|
||||
image: {{ template "postgresql.metrics.image" . }}
|
||||
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||
{{- if .Values.metrics.securityContext.enabled }}
|
||||
securityContext: {{- omit .Values.metrics.securityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
env:
|
||||
{{- $database := required "In order to enable metrics you need to specify a database (.Values.postgresqlDatabase or .Values.global.postgresql.postgresqlDatabase)" (include "postgresql.database" .) }}
|
||||
{{- $sslmode := ternary "require" "disable" .Values.tls.enabled }}
|
||||
{{- if and .Values.tls.enabled .Values.tls.certCAFilename }}
|
||||
- name: DATA_SOURCE_NAME
|
||||
value: {{ printf "host=127.0.0.1 port=%d user=%s sslmode=%s sslcert=%s sslkey=%s" (int (include "postgresql.port" .)) (include "postgresql.username" .) $sslmode (include "postgresql.tlsCert" .) (include "postgresql.tlsCertKey" .) }}
|
||||
{{- else }}
|
||||
- name: DATA_SOURCE_URI
|
||||
value: {{ printf "127.0.0.1:%d/%s?sslmode=%s" (int (include "postgresql.port" .)) $database $sslmode }}
|
||||
{{- end }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: DATA_SOURCE_PASS_FILE
|
||||
value: "/opt/bitnami/postgresql/secrets/postgresql-password"
|
||||
{{- else }}
|
||||
- name: DATA_SOURCE_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "postgresql.secretName" . }}
|
||||
key: postgresql-password
|
||||
{{- end }}
|
||||
- name: DATA_SOURCE_USER
|
||||
value: {{ template "postgresql.username" . }}
|
||||
{{- if .Values.metrics.extraEnvVars }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraEnvVars "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http-metrics
|
||||
initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
|
||||
{{- end }}
|
||||
{{- if .Values.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http-metrics
|
||||
initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: postgresql-password
|
||||
mountPath: /opt/bitnami/postgresql/secrets/
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: postgresql-certificates
|
||||
mountPath: /opt/bitnami/postgresql/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.customMetrics }}
|
||||
- name: custom-metrics
|
||||
mountPath: /conf
|
||||
readOnly: true
|
||||
args: ["--extend.query-path", "/conf/custom-metrics.yaml"]
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http-metrics
|
||||
containerPort: 9187
|
||||
{{- if .Values.metrics.resources }}
|
||||
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
{{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap}}
|
||||
- name: postgresql-config
|
||||
configMap:
|
||||
name: {{ template "postgresql.configurationCM" . }}
|
||||
{{- end }}
|
||||
{{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
|
||||
- name: postgresql-extended-config
|
||||
configMap:
|
||||
name: {{ template "postgresql.extendedConfigurationCM" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.usePasswordFile }}
|
||||
- name: postgresql-password
|
||||
secret:
|
||||
secretName: {{ template "postgresql.secretName" . }}
|
||||
{{- end }}
|
||||
{{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.initdbScriptsConfigMap .Values.initdbScripts }}
|
||||
- name: custom-init-scripts
|
||||
configMap:
|
||||
name: {{ template "postgresql.initdbScriptsCM" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.initdbScriptsSecret }}
|
||||
- name: custom-init-scripts-secret
|
||||
secret:
|
||||
secretName: {{ template "postgresql.initdbScriptsSecret" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: raw-certificates
|
||||
secret:
|
||||
secretName: {{ required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret }}
|
||||
- name: postgresql-certificates
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.master.extraVolumes }}
|
||||
{{- toYaml .Values.master.extraVolumes | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.customMetrics }}
|
||||
- name: custom-metrics
|
||||
configMap:
|
||||
name: {{ template "postgresql.metricsCM" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.shmVolume.enabled }}
|
||||
- name: dshm
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 1Gi
|
||||
{{- end }}
|
||||
{{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
{{- with .Values.persistence.existingClaim }}
|
||||
claimName: {{ tpl . $ }}
|
||||
{{- end }}
|
||||
{{- else if not .Values.persistence.enabled }}
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
{{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
{{- with .Values.persistence.annotations }}
|
||||
annotations:
|
||||
{{- range $key, $value := . }}
|
||||
{{ $key }}: {{ $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- range .Values.persistence.accessModes }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size | quote }}
|
||||
{{ include "postgresql.storageClass" . }}
|
||||
{{- end }}
|
27
nextcloud/charts/postgresql/templates/svc-headless.yaml
Normal file
27
nextcloud/charts/postgresql/templates/svc-headless.yaml
Normal file
@ -0,0 +1,27 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}-headless
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
# Use this annotation in addition to the actual publishNotReadyAddresses
|
||||
# field below because the annotation will stop being respected soon but the
|
||||
# field is broken in some versions of Kubernetes:
|
||||
# https://github.com/kubernetes/kubernetes/issues/58662
|
||||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
clusterIP: None
|
||||
# We want all pods in the StatefulSet to have their addresses published for
|
||||
# the sake of the other Postgresql pods even before they're ready, since they
|
||||
# have to be able to talk to each other in order to become ready.
|
||||
publishNotReadyAddresses: true
|
||||
ports:
|
||||
- name: tcp-postgresql
|
||||
port: {{ template "postgresql.port" . }}
|
||||
targetPort: tcp-postgresql
|
||||
selector:
|
||||
{{- include "common.labels.matchLabels" . | nindent 4 }}
|
42
nextcloud/charts/postgresql/templates/svc-read.yaml
Normal file
42
nextcloud/charts/postgresql/templates/svc-read.yaml
Normal file
@ -0,0 +1,42 @@
|
||||
{{- if .Values.replication.enabled }}
|
||||
{{- $serviceAnnotations := coalesce .Values.slave.service.annotations .Values.service.annotations -}}
|
||||
{{- $serviceType := coalesce .Values.slave.service.type .Values.service.type -}}
|
||||
{{- $serviceLoadBalancerIP := coalesce .Values.slave.service.loadBalancerIP .Values.service.loadBalancerIP -}}
|
||||
{{- $serviceLoadBalancerSourceRanges := coalesce .Values.slave.service.loadBalancerSourceRanges .Values.service.loadBalancerSourceRanges -}}
|
||||
{{- $serviceClusterIP := coalesce .Values.slave.service.clusterIP .Values.service.clusterIP -}}
|
||||
{{- $serviceNodePort := coalesce .Values.slave.service.nodePort .Values.service.nodePort -}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}-read
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
annotations:
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if $serviceAnnotations }}
|
||||
{{- include "common.tplvalues.render" (dict "value" $serviceAnnotations "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ $serviceType }}
|
||||
{{- if and $serviceLoadBalancerIP (eq $serviceType "LoadBalancer") }}
|
||||
loadBalancerIP: {{ $serviceLoadBalancerIP }}
|
||||
{{- end }}
|
||||
{{- if and (eq $serviceType "LoadBalancer") $serviceLoadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges: {{- include "common.tplvalues.render" (dict "value" $serviceLoadBalancerSourceRanges "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if and (eq $serviceType "ClusterIP") $serviceClusterIP }}
|
||||
clusterIP: {{ $serviceClusterIP }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-postgresql
|
||||
port: {{ template "postgresql.port" . }}
|
||||
targetPort: tcp-postgresql
|
||||
{{- if $serviceNodePort }}
|
||||
nodePort: {{ $serviceNodePort }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "common.labels.matchLabels" . | nindent 4 }}
|
||||
role: slave
|
||||
{{- end }}
|
40
nextcloud/charts/postgresql/templates/svc.yaml
Normal file
40
nextcloud/charts/postgresql/templates/svc.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
{{- $serviceAnnotations := coalesce .Values.master.service.annotations .Values.service.annotations -}}
|
||||
{{- $serviceType := coalesce .Values.master.service.type .Values.service.type -}}
|
||||
{{- $serviceLoadBalancerIP := coalesce .Values.master.service.loadBalancerIP .Values.service.loadBalancerIP -}}
|
||||
{{- $serviceLoadBalancerSourceRanges := coalesce .Values.master.service.loadBalancerSourceRanges .Values.service.loadBalancerSourceRanges -}}
|
||||
{{- $serviceClusterIP := coalesce .Values.master.service.clusterIP .Values.service.clusterIP -}}
|
||||
{{- $serviceNodePort := coalesce .Values.master.service.nodePort .Values.service.nodePort -}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "postgresql.fullname" . }}
|
||||
labels:
|
||||
{{- include "common.labels.standard" . | nindent 4 }}
|
||||
annotations:
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if $serviceAnnotations }}
|
||||
{{- include "common.tplvalues.render" (dict "value" $serviceAnnotations "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ $serviceType }}
|
||||
{{- if and $serviceLoadBalancerIP (eq $serviceType "LoadBalancer") }}
|
||||
loadBalancerIP: {{ $serviceLoadBalancerIP }}
|
||||
{{- end }}
|
||||
{{- if and (eq $serviceType "LoadBalancer") $serviceLoadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges: {{- include "common.tplvalues.render" (dict "value" $serviceLoadBalancerSourceRanges "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if and (eq $serviceType "ClusterIP") $serviceClusterIP }}
|
||||
clusterIP: {{ $serviceClusterIP }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-postgresql
|
||||
port: {{ template "postgresql.port" . }}
|
||||
targetPort: tcp-postgresql
|
||||
{{- if $serviceNodePort }}
|
||||
nodePort: {{ $serviceNodePort }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "common.labels.matchLabels" . | nindent 4 }}
|
||||
role: master
|
Reference in New Issue
Block a user