From 4fb10b7873eff5bf5abe346d3cbb7a43c47899cf Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Wed, 16 Oct 2024 13:48:20 +0300 Subject: [PATCH] Added pooler parameters and documentation (#416) Signed-off-by: Itay Grudev --- charts/cluster/README.md | 23 +++++++++++-------- charts/cluster/README.md.gotmpl | 13 ++++++++++- charts/cluster/templates/pooler.yaml | 12 ++++++++++ .../test/pooler/01-pooler_cluster-assert.yaml | 2 +- .../test/pooler/01-pooler_cluster.yaml | 1 + charts/cluster/values.yaml | 1 + 6 files changed, 40 insertions(+), 12 deletions(-) diff --git a/charts/cluster/README.md b/charts/cluster/README.md index 134588a77..c6e8bad69 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -191,16 +191,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | imageCatalog.images | list | `[]` | List of images to be provisioned in an image catalog. | | mode | string | `"standalone"` | Cluster mode of operation. Available modes: * `standalone` - default mode. Creates new or updates an existing CNPG cluster. * `replica` - Creates a replica cluster from an existing CNPG cluster. # TODO * `recovery` - Same as standalone but creates a cluster from a backup, object store or via pg_basebackup. | | nameOverride | string | `""` | Override the name of the chart | -| pooler.enabled | bool | `false` | Whether to enable PgBouncer | -| pooler.instances | int | `3` | Number of PgBouncer instances | -| pooler.monitoring.enabled | bool | `false` | Whether to enable monitoring | -| pooler.monitoring.podMonitor.enabled | bool | `true` | Whether to enable the PodMonitor | -| pooler.monitoring.podMonitor.metricRelabelings | list | `[]` | The list of metric relabelings for the PodMonitor. Applied to samples before ingestion. | -| pooler.monitoring.podMonitor.relabelings | list | `[]` | The list of relabelings for the PodMonitor. Applied to samples before scraping. | -| pooler.parameters | object | `{"default_pool_size":"25","max_client_conn":"1000"}` | PgBouncer configuration parameters | -| pooler.poolMode | string | `"transaction"` | PgBouncer pooling mode | -| pooler.template | object | `{}` | Custom PgBouncer deployment template. Use to override image, specify resources, etc. | -| pooler.type | string | `"rw"` | PgBouncer type of service to forward traffic to. | +| poolers | list | `[]` | List of PgBouncer poolers | | recovery.azure.connectionString | string | `""` | | | recovery.azure.containerName | string | `""` | | | recovery.azure.inheritFromAzureAD | bool | `false` | | @@ -251,6 +242,18 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | version.postgis | string | `"3.4"` | If using PostGIS, specify the version | | version.postgresql | string | `"16"` | PostgreSQL major version to use | | version.timescaledb | string | `"2.15"` | If using TimescaleDB, specify the version | +| poolers[].name | string | `` | Name of the pooler resource | +| poolers[].instances | number | `1` | The number of replicas we want | +| poolers[].type | [PoolerType][PoolerType] | `rw` | Type of service to forward traffic to. Default: `rw`. | +| poolers[].poolMode | [PgBouncerPoolMode][PgBouncerPoolMode] | `session` | The pool mode. Default: `session`. | +| poolers[].authQuerySecret | [LocalObjectReference][LocalObjectReference] | `{}` | The credentials of the user that need to be used for the authentication query. | +| poolers[].authQuery | string | `{}` | The credentials of the user that need to be used for the authentication query. | +| poolers[].parameters | map[string]string | `{}` | Additional parameters to be passed to PgBouncer - please check the CNPG documentation for a list of options you can configure | +| poolers[].template | [PodTemplateSpec][PodTemplateSpec] | `{}` | The template of the Pod to be created | +| poolers[].template | [ServiceTemplateSpec][ServiceTemplateSpec] | `{}` | Template for the Service to be created | +| poolers[].pg_hba | []string | `{}` | PostgreSQL Host Based Authentication rules (lines to be appended to the pg_hba.conf file) | +| poolers[].monitoring.enabled | bool | `false` | Whether to enable monitoring for the Pooler. | +| poolers[].monitoring.podMonitor.enabled | bool | `true` | Create a podMonitor for the Pooler. | ## Maintainers diff --git a/charts/cluster/README.md.gotmpl b/charts/cluster/README.md.gotmpl index e1a4d2f05..1ca7bebaa 100644 --- a/charts/cluster/README.md.gotmpl +++ b/charts/cluster/README.md.gotmpl @@ -123,7 +123,18 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat {{ template "chart.valuesSection" . }} - +| poolers[].name | string | `` | Name of the pooler resource | +| poolers[].instances | number | `1` | The number of replicas we want | +| poolers[].type | [PoolerType][PoolerType] | `rw` | Type of service to forward traffic to. Default: `rw`. | +| poolers[].poolMode | [PgBouncerPoolMode][PgBouncerPoolMode] | `session` | The pool mode. Default: `session`. | +| poolers[].authQuerySecret | [LocalObjectReference][LocalObjectReference] | `{}` | The credentials of the user that need to be used for the authentication query. | +| poolers[].authQuery | string | `{}` | The credentials of the user that need to be used for the authentication query. | +| poolers[].parameters | map[string]string | `{}` | Additional parameters to be passed to PgBouncer - please check the CNPG documentation for a list of options you can configure | +| poolers[].template | [PodTemplateSpec][PodTemplateSpec] | `{}` | The template of the Pod to be created | +| poolers[].template | [ServiceTemplateSpec][ServiceTemplateSpec] | `{}` | Template for the Service to be created | +| poolers[].pg_hba | []string | `{}` | PostgreSQL Host Based Authentication rules (lines to be appended to the pg_hba.conf file) | +| poolers[].monitoring.enabled | bool | `false` | Whether to enable monitoring for the Pooler. | +| poolers[].monitoring.podMonitor.enabled | bool | `true` | Create a podMonitor for the Pooler. | {{ template "chart.maintainersSection" . }} diff --git a/charts/cluster/templates/pooler.yaml b/charts/cluster/templates/pooler.yaml index 8e1b8f9ee..13a5a0681 100644 --- a/charts/cluster/templates/pooler.yaml +++ b/charts/cluster/templates/pooler.yaml @@ -11,10 +11,22 @@ spec: type: {{ default "rw" .type }} pgbouncer: poolMode: {{ default "session" .poolMode }} + {{- with .authQuerySecret }} + authQuerySecret: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- with .authQuery }} + authQuery: + {{- toYaml . | nindent 6 }} + {{- end }} {{- with .parameters }} parameters: {{- toYaml . | nindent 6 }} {{- end }} + {{- with .pg_hba }} + pg_hba: + {{- toYaml . | nindent 6 }} + {{- end }} {{ with .monitoring }} monitoring: {{- if not (empty .podMonitor) }} diff --git a/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml b/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml index 4a27037ca..db23167c7 100644 --- a/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml +++ b/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml @@ -21,7 +21,7 @@ spec: name: pooler-cluster instances: 2 pgbouncer: - poolMode: session + poolMode: transaction type: rw --- apiVersion: postgresql.cnpg.io/v1 diff --git a/charts/cluster/test/pooler/01-pooler_cluster.yaml b/charts/cluster/test/pooler/01-pooler_cluster.yaml index 8933e3d75..8fcbf6555 100644 --- a/charts/cluster/test/pooler/01-pooler_cluster.yaml +++ b/charts/cluster/test/pooler/01-pooler_cluster.yaml @@ -11,6 +11,7 @@ poolers: - name: rw type: rw instances: 2 + poolMode: transaction - name: ro type: ro instances: 2 diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index ca0927255..cb8b73b4a 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -375,6 +375,7 @@ imageCatalog: # - image: ghcr.io/your_repo/your_image:your_tag # major: 16 +# -- List of PgBouncer poolers poolers: [] # - # # -- Pooler name