diff --git a/charts/cluster/README.md b/charts/cluster/README.md index 6dfa43eab7..0c708d0d64 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -282,7 +282,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | 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[].serviceTemplate | [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. | diff --git a/charts/cluster/README.md.gotmpl b/charts/cluster/README.md.gotmpl index 66e5256c85..4236f6c7f8 100644 --- a/charts/cluster/README.md.gotmpl +++ b/charts/cluster/README.md.gotmpl @@ -131,7 +131,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | 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[].serviceTemplate | [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. | diff --git a/charts/cluster/templates/pooler.yaml b/charts/cluster/templates/pooler.yaml index f97e8d9e10..95cc94e7e7 100644 --- a/charts/cluster/templates/pooler.yaml +++ b/charts/cluster/templates/pooler.yaml @@ -46,4 +46,8 @@ spec: template: {{- . | toYaml | nindent 4 }} {{- end }} + {{- with .serviceTemplate }} + serviceTemplate: + {{- . | toYaml | nindent 4 }} + {{- end }} {{- end }} diff --git a/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml b/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml index db23167c7e..d18fe38968 100644 --- a/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml +++ b/charts/cluster/test/pooler/01-pooler_cluster-assert.yaml @@ -12,6 +12,13 @@ metadata: status: readyReplicas: 2 --- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: pooler-cluster-pooler-lb-rw +status: + readyReplicas: 2 +--- apiVersion: postgresql.cnpg.io/v1 kind: Pooler metadata: @@ -35,3 +42,23 @@ spec: pgbouncer: poolMode: session type: ro +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Pooler +metadata: + name: pooler-cluster-pooler-lb-rw +spec: + cluster: + name: pooler-cluster + instances: 2 + pgbouncer: + poolMode: transaction + type: rw + serviceTemplate: + metadata: + annotations: + metallb.universe.tf/address-pool: loadbalanced + metallb.universe.tf/allow-shared-ip: loadbalanced + metallb.universe.tf/ip-allocated-from-pool: loadbalanced + spec: + type: LoadBalancer diff --git a/charts/cluster/test/pooler/01-pooler_cluster.yaml b/charts/cluster/test/pooler/01-pooler_cluster.yaml index 8fcbf6555d..60e962e9ee 100644 --- a/charts/cluster/test/pooler/01-pooler_cluster.yaml +++ b/charts/cluster/test/pooler/01-pooler_cluster.yaml @@ -15,3 +15,15 @@ poolers: - name: ro type: ro instances: 2 + - name: lb-rw + type: rw + instances: 2 + poolMode: transaction + serviceTemplate: + metadata: + annotations: + metallb.universe.tf/address-pool: loadbalanced + metallb.universe.tf/allow-shared-ip: loadbalanced + metallb.universe.tf/ip-allocated-from-pool: loadbalanced + spec: + type: LoadBalancer diff --git a/charts/cluster/test/pooler/chainsaw-test.yaml b/charts/cluster/test/pooler/chainsaw-test.yaml index 427b84eb45..a466935555 100644 --- a/charts/cluster/test/pooler/chainsaw-test.yaml +++ b/charts/cluster/test/pooler/chainsaw-test.yaml @@ -8,7 +8,7 @@ metadata: spec: timeouts: apply: 1s - assert: 20s + assert: 2m cleanup: 30s steps: - name: Install the non-default configuration cluster diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 991eacd67e..bab34e0505 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -480,6 +480,9 @@ poolers: [] # # -- Custom PgBouncer deployment template. # # Use to override image, specify resources, etc. # template: {} + # # -- Custom PgBouncer service template. + # # Use to override service type, annotations, etc. + # serviceTemplate: {} # - # # -- Pooler name # name: ro @@ -502,3 +505,6 @@ poolers: [] # # -- Custom PgBouncer deployment template. # # Use to override image, specify resources, etc. # template: {} + # # -- Custom PgBouncer service template. + # # Use to override service type, annotations, etc. + # serviceTemplate: {}