From 816744a067a4603d1469cdecd0b1719153a17de7 Mon Sep 17 00:00:00 2001 From: Robert Raicu Date: Fri, 27 Dec 2024 01:31:28 +0100 Subject: [PATCH] Add service magement to chart --- charts/cluster/README.md | 1 + charts/cluster/templates/cluster.yaml | 6 +++++- .../01-non_default_configuration_cluster-assert.yaml | 12 ++++++++++++ .../01-non_default_configuration_cluster.yaml | 12 ++++++++++++ charts/cluster/values.schema.json | 3 +++ charts/cluster/values.yaml | 3 +++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index 8e8279e66..75ff0fd96 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -181,6 +181,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | cluster.primaryUpdateStrategy | string | `"unsupervised"` | Strategy to follow to upgrade the primary server during a rolling update procedure, after all replicas have been successfully updated: it can be automated (unsupervised - default) or manual (supervised) | | cluster.priorityClassName | string | `""` | | | cluster.resources | object | `{}` | Resources requirements of every generated Pod. Please refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for more information. We strongly advise you use the same setting for limits and requests so that your cluster pods are given a Guaranteed QoS. See: https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/ | +| cluster.services | object | `{}` | Customization of service definions. Please refer to https://cloudnative-pg.io/documentation/current/service_management/ | | cluster.roles | list | `[]` | 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/ | | cluster.serviceAccountTemplate | object | `{}` | Configure the metadata of the generated service account | | cluster.storage.size | string | `"8Gi"` | | diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index 715cf0094..6cbe052af 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -86,8 +86,12 @@ spec: {{- toYaml . | nindent 6 }} {{- end }} - {{- if not (empty .Values.cluster.roles) }} + {{- if not (and empty .Values.cluster.roles empty .Values.cluster.services) }} managed: + {{- with .Values.cluster.services }} + services: + {{- toYaml . | nindent 6 }} + {{ end }} {{- with .Values.cluster.roles }} roles: {{- toYaml . | nindent 6 }} 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 b8ff318d5..5ad5ec8fa 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 @@ -84,6 +84,18 @@ spec: inRoles: - pg_monitor - pg_signal_backend + services: + additional: + - selectorType: rw + serviceTemplate: + metadata: + name: "test-lb" + labels: + test-label: "true" + annotations: + test-annotation: "true" + spec: + type: LoadBalancer serviceAccountTemplate: metadata: annotations: 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 68ccba903..c6624cd87 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 @@ -45,6 +45,18 @@ cluster: enableSuperuserAccess: true superuserSecret: supersecret-secret enablePDB: false + services: + additional: + - selectorType: rw + serviceTemplate: + metadata: + name: "test-lb" + labels: + test-label: "true" + annotations: + test-annotation: "true" + spec: + type: LoadBalancer roles: - name: dante ensure: present diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index cb181a737..e7aab5c9f 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -294,6 +294,9 @@ "roles": { "type": "array" }, + "services": { + "type": "object" + }, "serviceAccountTemplate": { "type": "object" }, diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 1d650806b..a7bd4fb2e 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -162,6 +162,9 @@ cluster: # -- The GID of the postgres user inside the image, defaults to 26 postgresGID: -1 + # -- Customization of service definions. Please refer to https://cloudnative-pg.io/documentation/1.24/service_management/ + services: {} + # -- Resources requirements of every generated Pod. # Please refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for more information. # We strongly advise you use the same setting for limits and requests so that your cluster pods are given a Guaranteed QoS.