From 4cd64535c25826214bea60da11f82aed509928dd Mon Sep 17 00:00:00 2001 From: Dmitriy Alekseev <1865999+dragoangel@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:17:59 +0200 Subject: [PATCH] feat(cluster): Add replication slots configuration Signed-off-by: Dmitriy Alekseev <1865999+dragoangel@users.noreply.github.com> --- charts/cluster/templates/cluster.yaml | 4 ++++ ..._default_configuration_cluster-assert.yaml | 5 +++++ .../01-non_default_configuration_cluster.yaml | 5 +++++ charts/cluster/values.schema.json | 19 +++++++++++++++++++ charts/cluster/values.yaml | 9 +++++++++ 5 files changed, 42 insertions(+) diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index 2dace8e343..22cc073fa7 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -51,6 +51,10 @@ spec: superuserSecret: name: {{ . }} {{ end }} + {{- with .Values.cluster.replicationSlots }} + replicationSlots: + {{- toYaml . | nindent 4 }} + {{ end }} postgresql: shared_preload_libraries: {{- if eq .Values.type "timescaledb" }} diff --git a/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml b/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml index 921d354aa5..7a8a7eb8b6 100644 --- a/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml +++ b/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml @@ -29,6 +29,11 @@ spec: - CREATE TABLE mytable (id serial PRIMARY KEY, name VARCHAR(255)); superuserSecret: name: supersecret-secret + replicationSlots: + highAvailability: + enabled: false + slotPrefix: _cnpg_cust_ + updateInterval: "60" enableSuperuserAccess: true certificates: serverCASecret: ca-secret diff --git a/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml b/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml index a68ef8df2d..31196ce75d 100644 --- a/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml +++ b/charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml @@ -42,6 +42,11 @@ cluster: clientCASecret: client-ca-secret enableSuperuserAccess: true superuserSecret: supersecret-secret + replicationSlots: + highAvailability: + enabled: false + slotPrefix: _cnpg_cust_ + updateInterval: "60" roles: - name: dante ensure: present diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index a2354a8f8f..850449a310 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -273,6 +273,25 @@ "superuserSecret": { "type": "string" }, + "replicationSlots": { + "type": "object", + "properties": { + "highAvailability": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "slotPrefix": { + "type": "string" + }, + "updateInterval": { + "type": "string" + } + } + } + } + } "walStorage": { "type": "object", "properties": { diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 7aa766d0fd..687e93f479 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -153,6 +153,15 @@ cluster: enableSuperuserAccess: true superuserSecret: "" + # -- This feature automatically manages physical replication slots for each hot standby replica in + # the High Availability cluster, both in the primary and the standby. + # See: https://cloudnative-pg.io/documentation/current/replication/#replication-slots-for-high-availability + replicationSlots: + highAvailability: + enabled: true + slotPrefix: _cnpg_ + updateInterval: "30" + # -- This feature enables declarative management of existing roles, as well as the creation of new roles if they are not # already present in the database. # See: https://cloudnative-pg.io/documentation/current/declarative_role_management/