diff --git a/common/postgresql-ng/Chart.yaml b/common/postgresql-ng/Chart.yaml index c36d2b89a8..058af15d74 100644 --- a/common/postgresql-ng/Chart.yaml +++ b/common/postgresql-ng/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: postgresql-ng -version: 1.0.28 # this version number is SemVer as it gets used to auto bump +version: 1.0.29 # this version number is SemVer as it gets used to auto bump description: Chart for PostgreSQL keywords: - postgresql diff --git a/common/postgresql-ng/templates/configmap.yaml b/common/postgresql-ng/templates/configmap.yaml index b8978e3fd9..063a456ff5 100644 --- a/common/postgresql-ng/templates/configmap.yaml +++ b/common/postgresql-ng/templates/configmap.yaml @@ -1,3 +1,13 @@ +{{- if .Values.crontab }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "postgres.fullname" . }}-crontab +data: + root: | + {{ .Values.crontab }} +{{- end }} --- apiVersion: v1 kind: ConfigMap diff --git a/common/postgresql-ng/templates/deployment.yaml b/common/postgresql-ng/templates/deployment.yaml index fa9e0ba7b8..5640b84308 100644 --- a/common/postgresql-ng/templates/deployment.yaml +++ b/common/postgresql-ng/templates/deployment.yaml @@ -131,6 +131,19 @@ spec: - name: dev-shm mountPath: /dev/shm {{- end }} + {{- if .Values.crontab }} + - name: cron + image: "{{ include "preferredRegistry" . }}/shared-app-images/alpine-psql:3.20-latest" + command: + - /bin/sh + - -c + - | + /usr/bin/crontab /crontab/root + exec crond -f -d8 + volumeMounts: + - name: crontab + mountPath: /crontab + {{- end }} serviceAccountName: {{ template "postgres.fullname" . }} volumes: - name: postgres-etc @@ -143,7 +156,12 @@ spec: {{- else }} emptyDir: {} {{- end }} - {{- if .Values.sqlOnCreate }} + {{- if .Values.crontab }} + - name: crontab + configMap: + name: {{ template "postgres.fullname" . }}-crontab + {{- end }} + {{- if .Values.sqlOnCreate }} - name: sql-on-create configMap: name: {{ template "postgres.fullname" . }}-sql-on-create diff --git a/common/postgresql-ng/values.yaml b/common/postgresql-ng/values.yaml index abea2996a5..24fa5d867e 100644 --- a/common/postgresql-ng/values.yaml +++ b/common/postgresql-ng/values.yaml @@ -50,6 +50,11 @@ users: createMetricsUser: true +# crontab to run in a side container to execute routine maintenance tasks +# example: +# 42 23 * * * psql -tAd acme-db -c "VACUUM ANALYZE" +crontab: "" + # Persist data to a persistent volume persistence: enabled: true diff --git a/openstack/keppel/values.yaml b/openstack/keppel/values.yaml index aecd697d3b..bd397b18bd 100644 --- a/openstack/keppel/values.yaml +++ b/openstack/keppel/values.yaml @@ -103,6 +103,8 @@ postgresql: # We previously had 128, which should technically be enough for 6 API pods and 1 janitor pod (with max. 16 conns each) # as well as the pgmetrics and pgbackup pods with 1-2 conns each, but we still had a "too many clients already" issue regardless. max_connections: 160 + crontab: | + 30 14 * * 1,2,3,4,5 psql -tAd keppel -c "VACUUM ANALYZE" persistence: enabled: true accessMode: ReadWriteOnce # compatibility to allow easy upgrades