From cf20e9d9d97b89ccd055f4d9bd5e9d96b419852d Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski <janne@kuschku.de> Date: Fri, 23 May 2025 17:53:00 +0200 Subject: [PATCH] feat: add auto updater to postgres --- postgresql/Chart.yaml | 4 +-- postgresql/templates/statefulset.yaml | 38 +++++++++++++++++++++++++++ postgresql/values.yaml | 6 +++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/postgresql/Chart.yaml b/postgresql/Chart.yaml index b61c383..d9c8e14 100644 --- a/postgresql/Chart.yaml +++ b/postgresql/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: postgresql description: Helm Chart for postgresql type: application -version: 1.4.0 -appVersion: "15" +version: 1.7.0 +appVersion: "17" diff --git a/postgresql/templates/statefulset.yaml b/postgresql/templates/statefulset.yaml index ff4496b..ce0a8ce 100644 --- a/postgresql/templates/statefulset.yaml +++ b/postgresql/templates/statefulset.yaml @@ -6,6 +6,10 @@ metadata: {{- include "postgresql-helm.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} + updateStrategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: "100%" serviceName: {{ include "postgresql-helm.fullname" . }} selector: matchLabels: @@ -41,6 +45,40 @@ spec: - emptyDir: medium: Memory name: shm + {{- if .Values.updater.enabled }} + initContainers: + - name: updater + image: "{{ .Values.updater.repository }}:{{ .Values.updater.tag | default (printf "%s-alpine" .Chart.AppVersion) }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: PGAUTO_ONESHOT + value: "yes" + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + key: "postgres-password" + name: {{ include "postgresql-helm.fullname" . }} + securityContext: + runAsUser: 0 + volumeMounts: + - mountPath: "/var/lib/postgresql/data" + name: data + subPath: "{{ .Chart.AppVersion }}/data" + - mountPath: "/configs" + name: config + - mountPath: "/dev/shm" + name: shm + {{ if .Values.tls.enabled -}} + - mountPath: "/certs/tls.crt" + name: certs + subPath: tls.crt + - mountPath: "/certs/tls.key" + name: certs + subPath: tls.key + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- end }} containers: - name: postgresql securityContext: diff --git a/postgresql/values.yaml b/postgresql/values.yaml index 68115af..723439b 100644 --- a/postgresql/values.yaml +++ b/postgresql/values.yaml @@ -5,6 +5,12 @@ image: pullPolicy: IfNotPresent tag: "" +updater: + enabled: false + repository: pgautoupgrade/pgautoupgrade + pullPolicy: IfNotPresent + tag: "" + imagePullSecrets: [ ] nameOverride: "" fullnameOverride: "" -- GitLab