[bitnami/postgresql-ha] Add diagnostic mode (#6906)

* [bitnami/postgresql-ha] Add diagnostic mode

* default value

* DEBUG

* debug
This commit is contained in:
Javier J. Salmerón-García
2021-07-12 12:56:04 +02:00
committed by GitHub
parent 7b2b45a757
commit 0be22a199a
6 changed files with 85 additions and 9 deletions

View File

@@ -27,4 +27,4 @@ name: postgresql-ha
sources:
- https://github.com/bitnami/bitnami-docker-postgresql
- https://www.postgresql.org/
version: 7.7.3
version: 7.8.0

View File

@@ -68,6 +68,9 @@ The following table lists the configurable parameters of the PostgreSQL HA chart
| `fullnameOverride` | String to fully override postgres-ha.fullname template with a string | `nil` |
| `clusterDomain` | Default Kubernetes cluster domain | `cluster.local` |
| `extraDeploy` | Array of extra objects to deploy with the release (evaluated as a template). | `nil` |
| `diagnosticMode.enabled` | Enable diagnostic mode (all probes will be disabled and the command will be overridden). | `false` |
| `diagnosticMode.command` | Command to override all containers in the deployment. | `sleep` |
| `diagnosticMode.args` | Args to override all containers in the deployment. | `infinity` |
| `serviceAccount.enabled` | Enable service account (Note: Service Account will only be automatically created if `serviceAccount.name` is not set) | `false` |
| `serviceAccount.name` | Name of existing service account | `nil` |
| **PostgreSQL with Repmgr** | | |

View File

@@ -1,6 +1,31 @@
{{- $clusterDomain:= .Values.clusterDomain }}
** Please be patient while the chart is being deployed **
{{- if .Values.diagnosticMode.enabled }}
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
Get the list of pods by executing:
kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }}
Access the pod you want to debug by executing
kubectl exec --namespace {{ .Release.Namespace }} -ti <NAME OF THE POD> -- bash
In order to replicate the container startup scripts, check the /opt/bitnami/scripts folder.
Default PostgreSQL startup command
/opt/bitnami/scripts/postgresql-repmgr/entrypoint.sh /opt/bitnami/scripts/postgresql-repmgr/run.sh
Default PgPool startup command
/opt/bitnami/scripts/pgpool/entrypoint.sh /opt/bitnami/scripts/pgpool/run.sh
{{- else }}
PostgreSQL can be accessed through Pgpool via port {{ .Values.service.port }} on the following DNS name from within your cluster:
{{ include "postgresql-ha.pgpool" . }}.{{ .Release.Namespace }}.svc.{{ $clusterDomain }}
@@ -48,6 +73,7 @@ To connect to your database from outside the cluster execute the following comma
psql -h 127.0.0.1 -p {{ .Values.service.port }} -U {{ include "postgresql-ha.postgresqlUsername" . }}{{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} -d {{ include "postgresql-ha.postgresqlDatabase" . }}{{- end }}
{{- end }}
{{- end }}
{{- include "postgresql-ha.validateValues" . }}
{{- include "postgresql-ha.checkRollingTags" . }}
@@ -68,4 +94,4 @@ To connect to your database from outside the cluster execute the following comma
{{- end }}
{{- $passwordValidationErrors = include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .) -}}
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $) -}}
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $) -}}

View File

@@ -103,18 +103,24 @@ spec:
{{- if .Values.pgpool.securityContext.enabled }}
securityContext: {{- omit .Values.pgpool.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.pgpool.command }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
{{- else if .Values.pgpool.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.pgpool.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.pgpool.args }}
{{- if .Values.diagnosticMode.enabled }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else if .Values.pgpool.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.pgpool.args "context" $) | nindent 12 }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.pgpool.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.pgpool.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
{{- end }}
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" .Values.pgpoolImage.debug | quote }}
value: {{ ternary "true" "false" (or .Values.pgpoolImage.debug .Values.diagnosticMode.enabled) | quote }}
{{- if or .Values.pgpool.customUsersSecret .Values.pgpool.customUsers }}
- name: PGPOOL_POSTGRES_CUSTOM_USERS
valueFrom:
@@ -267,6 +273,7 @@ spec:
- name: postgresql
containerPort: 5432
protocol: TCP
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.pgpool.livenessProbe.enabled }}
livenessProbe:
exec:
@@ -280,6 +287,8 @@ spec:
{{- else if .Values.pgpool.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.pgpool.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.pgpool.readinessProbe.enabled }}
readinessProbe:
exec:
@@ -295,6 +304,8 @@ spec:
{{- else if .Values.pgpool.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.pgpool.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.pgpool.startupProbe.enabled }}
startupProbe:
exec:
@@ -308,6 +319,7 @@ spec:
{{- else if .Values.pgpool.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.pgpool.customStartupProbe "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.pgpool.resources }}
resources: {{- toYaml .Values.pgpool.resources | nindent 12 }}
{{- end }}

View File

@@ -121,6 +121,7 @@ spec:
{{- end }}
containers:
- name: postgresql
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.postgresql.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.lifecycleHooks "context" $) | nindent 12 }}
{{- else }}
@@ -130,10 +131,15 @@ spec:
command:
- /pre-stop.sh
{{- end }}
{{- if .Values.postgresql.command }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
{{- else if .Values.postgresql.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.postgresql.args }}
{{- if .Values.diagnosticMode.enabled }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else if .Values.postgresql.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.args "context" $) | nindent 12 }}
{{- end }}
image: {{ include "postgresql-ha.postgresqlImage" . }}
@@ -148,7 +154,7 @@ spec:
{{- $clusterDomain:= .Values.clusterDomain }}
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" .Values.postgresqlImage.debug | quote }}
value: {{ ternary "true" "false" (or .Values.postgresqlImage.debug .Values.diagnosticMode.enabled) | quote }}
# PostgreSQL configuration
- name: POSTGRESQL_VOLUME_DIR
value: {{ .Values.persistence.mountPath | quote }}
@@ -325,6 +331,7 @@ spec:
- name: postgresql
containerPort: 5432
protocol: TCP
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.postgresql.livenessProbe.enabled }}
livenessProbe:
exec:
@@ -340,6 +347,8 @@ spec:
{{- else if .Values.postgresql.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.postgresql.readinessProbe.enabled }}
readinessProbe:
exec:
@@ -355,6 +364,8 @@ spec:
{{- else if .Values.postgresql.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.postgresql.startupProbe.enabled }}
startupProbe:
exec:
@@ -370,6 +381,7 @@ spec:
{{- else if .Values.postgresql.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.customStartupProbe "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.postgresql.resources }}
resources: {{- toYaml .Values.postgresql.resources | nindent 12 }}
{{- end }}
@@ -435,6 +447,7 @@ spec:
- name: metrics
containerPort: 9187
protocol: TCP
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe:
httpGet:
@@ -446,6 +459,8 @@ spec:
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
{{- end }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe:
httpGet:
@@ -457,6 +472,8 @@ spec:
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
{{- end }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.metrics.startupProbe.enabled }}
startupProbe:
httpGet:
@@ -468,6 +485,7 @@ spec:
successThreshold: {{ .Values.metrics.startupProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.startupProbe.failureThreshold }}
{{- end }}
{{- end }}
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
{{- end }}
@@ -480,8 +498,16 @@ spec:
- name: custom-metrics
mountPath: /conf
readOnly: true
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
args: ["--extend.query-path", "/conf/custom-metrics.yaml"]
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.postgresql.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.sidecars "context" $) | nindent 8 }}

View File

@@ -1178,3 +1178,12 @@ networkPolicy:
## Array with extra yaml to deploy with the chart. Evaluated as a template
##
extraDeploy: []
## Enable diagnostic mode in the deployment
##
diagnosticMode:
enabled: false
command:
- sleep
args:
- infinity