From f0ceafa81e32e5369d64bed59d2506840649ee76 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Thu, 13 Feb 2020 12:54:32 +0100 Subject: [PATCH] reflect connectionPool validation in Go code and publish in manifests and chart --- .../crds/operatorconfigurations.yaml | 38 +++---- .../templates/configmap.yaml | 1 + .../templates/operatorconfiguration.yaml | 2 + charts/postgres-operator/values-crd.yaml | 11 ++ charts/postgres-operator/values.yaml | 12 ++ manifests/configmap.yaml | 9 ++ manifests/operatorconfiguration.crd.yaml | 38 +++---- ...gresql-operator-default-configuration.yaml | 10 ++ pkg/apis/acid.zalan.do/v1/crds.go | 104 ++++++++++++++++++ 9 files changed, 187 insertions(+), 38 deletions(-) diff --git a/charts/postgres-operator/crds/operatorconfigurations.yaml b/charts/postgres-operator/crds/operatorconfigurations.yaml index c99d4a811..a790125d1 100644 --- a/charts/postgres-operator/crds/operatorconfigurations.yaml +++ b/charts/postgres-operator/crds/operatorconfigurations.yaml @@ -321,24 +321,6 @@ spec: connection_pool: type: object properties: - connection_pool_schema: - type: string - #default: "pooler" - connection_pool_user: - type: string - #default: "pooler" - connection_pool_instances_number: - type: integer - #default: 1 - connection_pool_image: - type: string - #default: "pierone.stups.zalan.do/acid/pgbouncer:0.0.1" - connection_pool_mode: - type: string - enum: - - "session" - - "transaction" - #default: "transaction" connection_pool_default_cpu_limit: type: string pattern: '^(\d+m|\d+(\.\d{1,3})?)$' @@ -354,7 +336,25 @@ spec: connection_pool_default_memory_request: type: string pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$' - #default: "100m" + #default: "100Mi" + connection_pool_image: + type: string + #default: "pierone.stups.zalan.do/acid/pgbouncer:0.0.1" + connection_pool_instances_number: + type: integer + #default: 1 + connection_pool_mode: + type: string + enum: + - "session" + - "transaction" + #default: "transaction" + connection_pool_schema: + type: string + #default: "pooler" + connection_pool_user: + type: string + #default: "pooler" status: type: object additionalProperties: diff --git a/charts/postgres-operator/templates/configmap.yaml b/charts/postgres-operator/templates/configmap.yaml index 95eeb9546..634339795 100644 --- a/charts/postgres-operator/templates/configmap.yaml +++ b/charts/postgres-operator/templates/configmap.yaml @@ -20,4 +20,5 @@ data: {{ toYaml .Values.configDebug | indent 2 }} {{ toYaml .Values.configLoggingRestApi | indent 2 }} {{ toYaml .Values.configTeamsApi | indent 2 }} +{{ toYaml .Values.configConnectionPool | indent 2 }} {{- end }} diff --git a/charts/postgres-operator/templates/operatorconfiguration.yaml b/charts/postgres-operator/templates/operatorconfiguration.yaml index 6a301c1fb..55eb8fd4f 100644 --- a/charts/postgres-operator/templates/operatorconfiguration.yaml +++ b/charts/postgres-operator/templates/operatorconfiguration.yaml @@ -34,4 +34,6 @@ configuration: {{ toYaml .Values.configLoggingRestApi | indent 4 }} scalyr: {{ toYaml .Values.configScalyr | indent 4 }} + connection_pool: +{{ toYaml .Values.configConnectionPool | indent 4 }} {{- end }} diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index 1f9b5e495..17b62226a 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -261,6 +261,17 @@ configScalyr: # Memory request value for the Scalyr sidecar scalyr_memory_request: 50Mi +configConnectionPool: + connection_pool_default_cpu_limit: "1" + connection_pool_default_cpu_request: "1" + connection_pool_default_memory_limit: 100m + connection_pool_default_memory_request: "100Mi" + # connection_pool_image: "" + connection_pool_instances_number: 1 + connection_pool_mode: "transaction" + # connection_pool_schema: "pooler" + # connection_pool_user: "pooler" + rbac: # Specifies whether RBAC resources should be created create: true diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index 1be5851d2..f11619c8a 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -237,6 +237,18 @@ configTeamsApi: # URL of the Teams API service # teams_api_url: http://fake-teams-api.default.svc.cluster.local +# configure connection pooler deployment created by the operator +configConnectionPool: + connection_pool_default_cpu_limit: "1" + connection_pool_default_cpu_request: "1" + connection_pool_default_memory_limit: 100m + connection_pool_default_memory_request: "100Mi" + # connection_pool_image: "" + connection_pool_instances_number: 1 + connection_pool_mode: "transaction" + # connection_pool_schema: "pooler" + # connection_pool_user: "pooler" + rbac: # Specifies whether RBAC resources should be created create: true diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index d26c83edf..05f22a388 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -11,6 +11,15 @@ data: cluster_history_entries: "1000" cluster_labels: application:spilo cluster_name_label: version + # connection_pool_default_cpu_limit: "1" + # connection_pool_default_cpu_request: "1" + # connection_pool_default_memory_limit: 100m + # connection_pool_default_memory_request: "100Mi" + # connection_pool_image: "" + # connection_pool_instances_number: 1 + # connection_pool_mode: "transaction" + # connection_pool_schema: "pooler" + # connection_pool_user: "pooler" # custom_service_annotations: "keyx:valuez,keya:valuea" # custom_pod_annotations: "keya:valuea,keyb:valueb" db_hosted_zone: db.example.com diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index c44955771..f4224244d 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -297,24 +297,6 @@ spec: connection_pool: type: object properties: - connection_pool_schema: - type: string - #default: "pooler" - connection_pool_user: - type: string - #default: "pooler" - connection_pool_instances_number: - type: integer - #default: 1 - connection_pool_image: - type: string - #default: "pierone.stups.zalan.do/acid/pgbouncer:0.0.1" - connection_pool_mode: - type: string - enum: - - "session" - - "transaction" - #default: "transaction" connection_pool_default_cpu_limit: type: string pattern: '^(\d+m|\d+(\.\d{1,3})?)$' @@ -330,7 +312,25 @@ spec: connection_pool_default_memory_request: type: string pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$' - #default: "100m" + #default: "100Mi" + connection_pool_image: + type: string + #default: "pierone.stups.zalan.do/acid/pgbouncer:0.0.1" + connection_pool_instances_number: + type: integer + #default: 1 + connection_pool_mode: + type: string + enum: + - "session" + - "transaction" + #default: "transaction" + connection_pool_schema: + type: string + #default: "pooler" + connection_pool_user: + type: string + #default: "pooler" status: type: object additionalProperties: diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index efd1a5396..037ae5e35 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -121,3 +121,13 @@ configuration: scalyr_memory_limit: 500Mi scalyr_memory_request: 50Mi # scalyr_server_url: "" + connection_pool: + connection_pool_default_cpu_limit: "1" + connection_pool_default_cpu_request: "1" + connection_pool_default_memory_limit: 100m + connection_pool_default_memory_request: "100Mi" + # connection_pool_image: "" + connection_pool_instances_number: 1 + connection_pool_mode: "transaction" + # connection_pool_schema: "pooler" + # connection_pool_user: "pooler" diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 4cfc9a9e6..f760d63e5 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -176,6 +176,65 @@ var PostgresCRDResourceValidation = apiextv1beta1.CustomResourceValidation{ }, }, }, + "connectionPool": { + Type: "object", + Properties: map[string]apiextv1beta1.JSONSchemaProps{ + "dockerImage": { + Type: "string", + }, + "mode": { + Type: "string", + }, + "numberOfInstances": { + Type: "integer", + Minimum: &min1, + }, + "resources": { + Type: "object", + Required: []string{"requests", "limits"}, + Properties: map[string]apiextv1beta1.JSONSchemaProps{ + "limits": { + Type: "object", + Required: []string{"cpu", "memory"}, + Properties: map[string]apiextv1beta1.JSONSchemaProps{ + "cpu": { + Type: "string", + Description: "Decimal natural followed by m, or decimal natural followed by dot followed by up to three decimal digits (precision used by Kubernetes). Must be greater than 0", + Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$", + }, + "memory": { + Type: "string", + Description: "Plain integer or fixed-point integer using one of these suffixes: E, P, T, G, M, k (with or without a tailing i). Must be greater than 0", + Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$", + }, + }, + }, + "requests": { + Type: "object", + Required: []string{"cpu", "memory"}, + Properties: map[string]apiextv1beta1.JSONSchemaProps{ + "cpu": { + Type: "string", + Description: "Decimal natural followed by m, or decimal natural followed by dot followed by up to three decimal digits (precision used by Kubernetes). Must be greater than 0", + Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$", + }, + "memory": { + Type: "string", + Description: "Plain integer or fixed-point integer using one of these suffixes: E, P, T, G, M, k (with or without a tailing i). Must be greater than 0", + Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$", + }, + }, + }, + }, + }, + "schema": { + Type: "string", + }, + "user": { + Type: "string", + }, + }, + }, "databases": { Type: "object", AdditionalProperties: &apiextv1beta1.JSONSchemaPropsOrBool{ @@ -1037,6 +1096,51 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation }, }, }, + "connection_pool": { + Type: "object", + Properties: map[string]apiextv1beta1.JSONSchemaProps{ + "connection_pool_default_cpu_limit": { + Type: "string", + Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$", + }, + "connection_pool_default_cpu_request": { + Type: "string", + Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$", + }, + "connection_pool_default_memory_limit": { + Type: "string", + Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$", + }, + "connection_pool_default_memory_request": { + Type: "string", + Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$", + }, + "connection_pool_image": { + Type: "string", + }, + "connection_pool_instances_number": { + Type: "integer", + Minimum: &min1, + }, + "connection_pool_mode": { + Type: "string", + Enum: []apiextv1beta1.JSON{ + { + Raw: []byte(`"session"`), + }, + { + Raw: []byte(`"transaction"`), + }, + }, + }, + "connection_pool_schema": { + Type: "string", + }, + "connection_pool_user": { + Type: "string", + }, + }, + }, }, }, "status": {