Skip to content

Commit cadfa3a

Browse files
[Fixes #237]: "Feature: make postgres-operator manifest configuration more flexible"
1 parent 6f68102 commit cadfa3a

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
lines changed

charts/geonode/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,21 @@ Helm Chart for Geonode. Supported versions: Geonode: 4.4.0, Geoserver: 2.24.4-v1
203203
| postgres.external.ssl | string | `"prefer"` | |
204204
| postgres.geodata_databasename_and_username | string | `"geodata"` | geoserver database name and username |
205205
| postgres.geonode_databasename_and_username | string | `"geonode"` | geonode database name and username |
206+
| postgres.operator.allowedSourceRanges | list | `[]` | when one or more load balancers are enabled for the cluster, this parameter defines the comma-separated range of IP networks (in CIDR-notation). The corresponding load balancer is accessible only to the networks defined by this parameter. Optional, when empty the load balancer service becomes inaccessible from outside of the Kubernetes cluster. |
207+
| postgres.operator.annotations | object | `{}` | additional annotation for postgresql object |
208+
| postgres.operator.clone | object | `{}` | |
209+
| postgres.operator.enableMasterLoadBalancer | string | `nil` | boolean flag to override the operator defaults (set by the enable_master_load_balancer parameter) to define whether to enable the load balancer pointing to the Postgres primary. Optional. |
210+
| postgres.operator.env | list | `[]` | a dictionary of environment variables. Use usual Kubernetes definition (https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/) for environment variables. Optional. |
206211
| postgres.operator.numberOfInstances | int | `1` | number of database instances |
207-
| postgres.operator.parameters.max_connections | int | `200` | |
208-
| postgres.operator.parameters.shared_buffers | string | `"1Gb"` | |
209-
| postgres.operator.parameters.work_mem | string | `"64Mb"` | |
212+
| postgres.operator.parameters | object | `{"max_connections":"20","shared_buffers":"250MB","work_mem":"12.5Mb"}` | postgres parameters resources |
213+
| postgres.operator.patroni | object | `{}` | patroni related configuration (https://patroni.readthedocs.io/en/master/patroni_configuration.html) |
210214
| postgres.operator.pod_name | string | `"postgresql"` | pod name for postgres containers == teamID for mainifest |
211215
| postgres.operator.postgres_version | int | `15` | postgres version |
216+
| postgres.operator.resources | object | `{"limits":{"cpu":"400m","memory":"1Gi"},"requests":{"cpu":"100m","memory":"0.5Gi"}}` | Those parameters define CPU and memory requests and limits for the Postgres container. They are grouped under the resources top-level key with subgroups requests and limits |
217+
| postgres.operator.resources.limits.cpu | string | `"400m"` | limit cpu as in resource.requests.cpu (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
218+
| postgres.operator.resources.limits.memory | string | `"1Gi"` | limits memory as in resource.limits.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
219+
| postgres.operator.resources.requests.cpu | string | `"100m"` | requested cpu as in resource.requests.cpu (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
220+
| postgres.operator.resources.requests.memory | string | `"0.5Gi"` | requested memory as in resource.requests.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
212221
| postgres.operator.storageClass | string | `nil` | postgress pv storageclass |
213222
| postgres.operator.storageSize | string | `"3Gi"` | Database storage size |
214223
| postgres.schema | string | `"public"` | database schema |

charts/geonode/templates/postgres/postgresql-operator.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ apiVersion: "acid.zalan.do/v1"
44
kind: postgresql
55
metadata:
66
name: "{{ include "postgres_pod_name" . }}"
7+
{{- if .Values.postgres.operator.annotations }}
8+
annotations:
9+
{{- toYaml .Values.postgres.operator.annotations | nindent 4 }}
10+
{{- end }}
711
spec:
12+
{{ if .Values.postgres.operator.env }}
13+
env:
14+
{{- toYaml .Values.postgres.operator.env | nindent 4 }}
15+
{{- end }}
816
teamId: {{ .Release.Name | quote }}
917
volume:
1018
size: {{ .Values.postgres.operator.storageSize }}
1119
storageClass: {{ .Values.postgres.operator.storageClass }}
20+
enableMasterLoadBalancer: {{ .Values.postgres.operator.enableMasterLoadBalancer }}
21+
allowedSourceRanges: {{- toYaml .Values.postgres.operator.allowedSourceRanges | nindent 4 }}
1222
numberOfInstances: {{ int .Values.postgres.operator.numberOfInstances }}
1323
users:
1424
{{ .Values.postgres.username }}:
@@ -38,9 +48,15 @@ spec:
3848
pg_partman: {{ .Values.postgres.schema }}
3949
postgis: {{ .Values.postgres.schema }}
4050
postgresql:
41-
parameters:
42-
max_connections: {{ .Values.postgres.operator.parameters.max_connections | quote }}
43-
shared_buffers: {{ .Values.postgres.operator.parameters.shared_buffers }}
44-
work_mem: {{ .Values.postgres.operator.parameters.work_mem }}
51+
{{- if .Values.postgres.operator.parameters }}
52+
parameters: {{- toYaml .Values.postgres.operator.parameters | nindent 6 }}
53+
{{- end }}
4554
version: {{ .Values.postgres.operator.postgres_version | quote }}
55+
{{- if .Values.postgres.operator.patroni }}
56+
patroni: {{- toYaml .Values.postgres.operator.patroni | nindent 4 }}
57+
{{- end }}
58+
resources: {{ toYaml .Values.postgres.operator.resources | nindent 4 }}
59+
{{- if .Values.postgres.operator.clone }}
60+
clone: {{- toYaml .Values.postgres.operator.clone | nindent 4 }}
61+
{{- end }}
4662
{{ end }}

charts/geonode/values.yaml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ postgres:
697697
# -- geoserver database name and username
698698
geodata_databasename_and_username: geodata
699699

700-
# configuration for postgres operator database manifest
700+
# configuration for postgres operator database manifest (https://github.com/zalando/postgres-operator/blob/master/docs/reference/cluster_manifest.md)
701701
operator:
702702
# -- pod name for postgres containers == teamID for mainifest
703703
pod_name: postgresql
@@ -709,13 +709,39 @@ postgres:
709709
numberOfInstances: 1
710710
# -- postgres version
711711
postgres_version: 15
712-
# database passwords are set randomly
713-
# infos @ https://postgres-operator.readthedocs.io/en/refactoring-sidecars/user/
714-
# get password after creation via: kubectl get secret {{ .Release.name }}.{{ .Release.name }}-{{ container_name }}.credentials -o 'jsonpath={.data.password}' | base64 -d
712+
# -- boolean flag to override the operator defaults (set by the enable_master_load_balancer parameter) to define whether to enable the load balancer pointing to the Postgres primary. Optional.
713+
enableMasterLoadBalancer:
714+
# -- when one or more load balancers are enabled for the cluster, this parameter defines the comma-separated range of IP networks (in CIDR-notation).
715+
# The corresponding load balancer is accessible only to the networks defined by this parameter.
716+
# Optional, when empty the load balancer service becomes inaccessible from outside of the Kubernetes cluster.
717+
allowedSourceRanges: []
718+
# -- a dictionary of environment variables. Use usual Kubernetes definition (https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/)
719+
# for environment variables. Optional.
720+
env: []
721+
# -- additional annotation for postgresql object
722+
annotations: {}
723+
# -- patroni related configuration (https://patroni.readthedocs.io/en/master/patroni_configuration.html)
724+
patroni: {}
725+
# -- postgres parameters resources
715726
parameters:
716-
max_connections: 200
717-
shared_buffers: 1Gb
718-
work_mem: 64Mb
727+
max_connections: "20"
728+
shared_buffers: 250MB
729+
work_mem: 12.5Mb
730+
# --
731+
clone: {}
732+
# -- Those parameters define CPU and memory requests and limits for the Postgres container. They are grouped under the resources top-level key with subgroups requests and limits
733+
resources:
734+
requests:
735+
# -- requested memory as in resource.requests.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
736+
memory: "0.5Gi"
737+
# -- requested cpu as in resource.requests.cpu (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
738+
cpu: "100m"
739+
limits:
740+
# -- limits memory as in resource.limits.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
741+
memory: "1Gi"
742+
# -- limit cpu as in resource.requests.cpu (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
743+
cpu: "400m"
744+
719745
external:
720746
hostname: my-external-postgres.com
721747
port: 5432

0 commit comments

Comments
 (0)