From 2b934399a8007f56e76c421fb1c9a29d54c2e89e Mon Sep 17 00:00:00 2001 From: Gagan Trivedi Date: Fri, 29 Aug 2025 13:01:12 +0530 Subject: [PATCH 1/3] fix: replace Bitnami PostgreSQL chart with local StatefulSet --- charts/flagsmith/Chart.lock | 7 +--- charts/flagsmith/Chart.yaml | 5 --- charts/flagsmith/templates/_helpers.tpl | 14 ++----- .../flagsmith/templates/postgres-service.yaml | 12 ++++++ .../templates/postgres-statefulset.yaml | 39 +++++++++++++++++++ charts/flagsmith/values.yaml | 3 +- 6 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 charts/flagsmith/templates/postgres-service.yaml create mode 100644 charts/flagsmith/templates/postgres-statefulset.yaml diff --git a/charts/flagsmith/Chart.lock b/charts/flagsmith/Chart.lock index 0296d7dc..35679ac8 100644 --- a/charts/flagsmith/Chart.lock +++ b/charts/flagsmith/Chart.lock @@ -1,12 +1,9 @@ dependencies: -- name: postgresql - repository: https://charts.bitnami.com/bitnami - version: 12.5.8 - name: influxdb2 repository: https://helm.influxdata.com/ version: 2.1.1 - name: graphite repository: https://kiwigrid.github.io version: 0.7.3 -digest: sha256:6ed1b4fab608bb1039a42040c445cfdf6a74a32ac80d4b1137f420e86f08e481 -generated: "2023-06-20T13:58:28.286957382+01:00" +digest: sha256:bb4cb379afbfd0c1f4bca8a10786c9651ca0ebdc9a34c3c74efafbeb3e198c0a +generated: "2025-08-29T09:27:19.085559+05:30" diff --git a/charts/flagsmith/Chart.yaml b/charts/flagsmith/Chart.yaml index 91ac6c35..dd8295c7 100644 --- a/charts/flagsmith/Chart.yaml +++ b/charts/flagsmith/Chart.yaml @@ -5,11 +5,6 @@ type: application version: 0.77.1 appVersion: 2.194.0 dependencies: - - name: postgresql - repository: https://charts.bitnami.com/bitnami - version: 12.5.8 - condition: postgresql.enabled,devPostgresql.enabled - alias: devPostgresql - name: influxdb2 repository: https://helm.influxdata.com/ version: 2.1.1 diff --git a/charts/flagsmith/templates/_helpers.tpl b/charts/flagsmith/templates/_helpers.tpl index 975c3464..59d2c1ce 100644 --- a/charts/flagsmith/templates/_helpers.tpl +++ b/charts/flagsmith/templates/_helpers.tpl @@ -77,17 +77,9 @@ Common annotations 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 "flagsmith.postgresql.fullname" -}} -{{- if .Values.devPostgresql.fullnameOverride -}} -{{- .Values.devPostgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.devPostgresql.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name "bulletrain-postgresql" | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} +{{- printf "%s-%s" .Release.Name "flagsmith-postgres" | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* @@ -182,7 +174,7 @@ Set redis port Postgres hostname */}} {{- define "flagsmith.postgres.hostname" -}} -{{- printf "%s-%s" .Release.Name .Values.devPostgresql.nameOverride -}}.{{ .Release.Namespace }}.svc.cluster.local +{{- printf "%s-%s" .Release.Name "flagsmith-postgres" -}}.{{ .Release.Namespace }}.svc.cluster.local {{- end -}} {{/* diff --git a/charts/flagsmith/templates/postgres-service.yaml b/charts/flagsmith/templates/postgres-service.yaml new file mode 100644 index 00000000..a8a0e2c5 --- /dev/null +++ b/charts/flagsmith/templates/postgres-service.yaml @@ -0,0 +1,12 @@ +{{- if .Values.devPostgresql.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "flagsmith.fullname" . }}-postgres +spec: + ports: + - port: 5432 + targetPort: 5432 + selector: + app: {{ include "flagsmith.fullname" . }}-postgres +{{- end }} diff --git a/charts/flagsmith/templates/postgres-statefulset.yaml b/charts/flagsmith/templates/postgres-statefulset.yaml new file mode 100644 index 00000000..055d0072 --- /dev/null +++ b/charts/flagsmith/templates/postgres-statefulset.yaml @@ -0,0 +1,39 @@ +{{- if .Values.devPostgresql.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "flagsmith.fullname" . }}-postgres +spec: + serviceName: {{ include "flagsmith.fullname" . }}-postgres + replicas: 1 + selector: + matchLabels: + app: {{ include "flagsmith.fullname" . }}-postgres + template: + metadata: + labels: + app: {{ include "flagsmith.fullname" . }}-postgres + spec: + containers: + - name: postgres + image: postgres:15 + ports: + - containerPort: 5432 + env: + - name: POSTGRES_DB + value: {{ .Values.devPostgresql.auth.database}} + - name: POSTGRES_PASSWORD + value: {{ .Values.devPostgresql.auth.postgresPassword}} + + volumeMounts: + - name: data + mountPath: /var/lib/postgresql/data + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: {{ .Values.devPostgresql.storage }} +{{- end }} diff --git a/charts/flagsmith/values.yaml b/charts/flagsmith/values.yaml index e20a27e3..a2b108dd 100644 --- a/charts/flagsmith/values.yaml +++ b/charts/flagsmith/values.yaml @@ -251,7 +251,8 @@ devPostgresql: enabled: true serviceAccount: create: true - nameOverride: dev-postgresql + nameOverride: flagsmith-postgres + storage: 500m auth: postgresPassword: flagsmith database: flagsmith From 633b4b8cddd98cc3b228a2cf3d64745b3b006d0b Mon Sep 17 00:00:00 2001 From: Gagan Trivedi Date: Sun, 31 Aug 2025 08:24:59 +0530 Subject: [PATCH 2/3] remove bitnami postgres chart --- charts/flagsmith/values.yaml | 3 --- ct.yaml | 1 - 2 files changed, 4 deletions(-) diff --git a/charts/flagsmith/values.yaml b/charts/flagsmith/values.yaml index a2b108dd..448b3ccd 100644 --- a/charts/flagsmith/values.yaml +++ b/charts/flagsmith/values.yaml @@ -245,9 +245,6 @@ taskProcessor: extraSpec: {} # Will be added to `spec` for `flagsmith-task-processor` deployment. devPostgresql: - image: - repository: bitnamilegacy/postgresql - tag: 15.3.0-debian-11-r7 enabled: true serviceAccount: create: true diff --git a/ct.yaml b/ct.yaml index f5e4bdf5..22b30514 100644 --- a/ct.yaml +++ b/ct.yaml @@ -2,7 +2,6 @@ # See https://github.com/Flagsmith/flagsmith-charts/issues/105 chart-repos: - stable=https://charts.helm.sh/stable - - bitnami=https://charts.bitnami.com/bitnami - influxdata=https://helm.influxdata.com/ - kiwigrid=https://kiwigrid.github.io target-branch: main From e0489c204ec63f4cb3940791369c328b3846d4fe Mon Sep 17 00:00:00 2001 From: Gagan Trivedi Date: Mon, 1 Sep 2025 18:02:44 +0530 Subject: [PATCH 3/3] get rid of postgresql.host --- charts/flagsmith/templates/_helpers.tpl | 15 ++------------- charts/flagsmith/values.yaml | 3 --- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/charts/flagsmith/templates/_helpers.tpl b/charts/flagsmith/templates/_helpers.tpl index 59d2c1ce..fd0e396d 100644 --- a/charts/flagsmith/templates/_helpers.tpl +++ b/charts/flagsmith/templates/_helpers.tpl @@ -79,18 +79,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this */}} {{- define "flagsmith.postgresql.fullname" -}} -{{- printf "%s-%s" .Release.Name "flagsmith-postgres" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Set postgres host -*/}} -{{- define "flagsmith.postgresql.host" -}} -{{- if .Values.devPostgresql.enabled -}} -{{- template "flagsmith.postgresql.fullname" . -}} -{{- else -}} -{{- .Values.devPostgresql.postgresqlHost | quote -}} -{{- end -}} +{{ include "flagsmith.fullname" . }}-postgres {{- end -}} {{/* @@ -174,7 +163,7 @@ Set redis port Postgres hostname */}} {{- define "flagsmith.postgres.hostname" -}} -{{- printf "%s-%s" .Release.Name "flagsmith-postgres" -}}.{{ .Release.Namespace }}.svc.cluster.local +{{ include "flagsmith.fullname" . }}-postgres {{- end -}} {{/* diff --git a/charts/flagsmith/values.yaml b/charts/flagsmith/values.yaml index 448b3ccd..59d45668 100644 --- a/charts/flagsmith/values.yaml +++ b/charts/flagsmith/values.yaml @@ -246,9 +246,6 @@ taskProcessor: devPostgresql: enabled: true - serviceAccount: - create: true - nameOverride: flagsmith-postgres storage: 500m auth: postgresPassword: flagsmith