diff --git a/charts/postgres-operator/crds/operatorconfigurations.yaml b/charts/postgres-operator/crds/operatorconfigurations.yaml index 0a1e74613..a2436b894 100644 --- a/charts/postgres-operator/crds/operatorconfigurations.yaml +++ b/charts/postgres-operator/crds/operatorconfigurations.yaml @@ -327,6 +327,12 @@ spec: pod_role_label: type: string default: "spilo-role" + pod_leader_label_value: + type: string + default: "master" + pod_standby_leader_label_value: + type: string + default: "master" pod_service_account_definition: type: string default: "" diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index 472be7443..d88660862 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -194,6 +194,8 @@ configKubernetes: pod_management_policy: "ordered_ready" # label assigned to the Postgres pods (and services/endpoints) pod_role_label: spilo-role + pod_leader_label_value: master + pod_standby_leader_label_value: master # service account definition as JSON/YAML string to be used by postgres cluster pods # pod_service_account_definition: "" diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 4d4d16cdb..a72c776e0 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -437,6 +437,14 @@ configuration they are grouped under the `kubernetes` key. name of the label assigned to the Postgres pods (and services/endpoints) by the operator. The default is `spilo-role`. +* **pod_leader_label_value** + value of the pod label if Postgres role is primary when running on Kubernetes. + The default is 'master'. + +* **pod_standby_leader_label_value** + value of the pod label if Postgres role is standby_leader when running on Kubernetes. + The default is 'master'. + * **cluster_labels** list of `name:value` pairs for additional labels assigned to the cluster objects. The default is `application:spilo`. diff --git a/e2e/tests/test_e2e.py b/e2e/tests/test_e2e.py index 807a070a3..f89e2fb86 100644 --- a/e2e/tests/test_e2e.py +++ b/e2e/tests/test_e2e.py @@ -12,9 +12,9 @@ from kubernetes import client from tests.k8s_api import K8s from kubernetes.client.rest import ApiException -SPILO_CURRENT = "container-registry-test.zalando.net/acid/spilo-cdp-pr1050-16:4.0-p4" +SPILO_CURRENT = "registry.opensource.zalan.do/acid/spilo-16-e2e:0.1" SPILO_LAZY = "registry.opensource.zalan.do/acid/spilo-16-e2e:0.2" -SPILO_FULL_IMAGE = "container-registry-test.zalando.net/acid/spilo-cdp-pr1050-16:4.0-p4" +SPILO_FULL_IMAGE = "ghcr.io/zalando/spilo-16:3.2-p3" def to_selector(labels): diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index a133c8093..b9ce21084 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -135,7 +135,7 @@ data: # pod_priority_class_name: "postgres-pod-priority" pod_role_label: spilo-role pod_leader_label_value: master - pod_standby_leader_label_value: standby_leader + pod_standby_leader_label_value: master pod_service_account_definition: "" pod_service_account_name: "postgres-pod" pod_service_account_role_binding_definition: "" diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index a7b1a7280..3f1444f62 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -325,6 +325,12 @@ spec: pod_role_label: type: string default: "spilo-role" + pod_leader_label_value: + type: string + default: "master" + pod_standby_leader_label_value: + type: string + default: "master" pod_service_account_definition: type: string default: "" diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index ecb7a03de..f702b3c83 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -99,6 +99,8 @@ configuration: pod_management_policy: "ordered_ready" # pod_priority_class_name: "postgres-pod-priority" pod_role_label: spilo-role + pod_leader_label_value: master + pod_standby_leader_label_value: master # pod_service_account_definition: "" pod_service_account_name: postgres-pod # pod_service_account_role_binding_definition: "" diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index c5c4b2706..27b7057b8 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -1497,6 +1497,12 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{ "pod_role_label": { Type: "string", }, + "pod_leader_label_value": { + Type: "string", + }, + "pod_standby_leader_label_value": { + Type: "string", + }, "pod_service_account_definition": { Type: "string", }, diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index eb01d450c..65506313e 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -81,6 +81,8 @@ type KubernetesMetaConfiguration struct { InfrastructureRolesSecretName spec.NamespacedName `json:"infrastructure_roles_secret_name,omitempty"` InfrastructureRolesDefs []*config.InfrastructureRole `json:"infrastructure_roles_secrets,omitempty"` PodRoleLabel string `json:"pod_role_label,omitempty"` + PodLeaderLabelValue string `json:"pod_leader_label_value,omitempty"` + PodStandbyLeaderLabelValue string `json:"pod_standby_leader_label_value,omitempty"` ClusterLabels map[string]string `json:"cluster_labels,omitempty"` InheritedLabels []string `json:"inherited_labels,omitempty"` InheritedAnnotations []string `json:"inherited_annotations,omitempty"` diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 4e67dbd94..cbcbb897a 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -950,6 +950,14 @@ func (c *Cluster) generateSpiloPodEnvVars( Name: "KUBERNETES_ROLE_LABEL", Value: c.OpConfig.PodRoleLabel, }, + { + Name: "KUBERNETES_LEADER_LABEL_VALUE", + Value: c.OpConfig.PodLeaderLabelValue, + }, + { + Name: "KUBERNETES_STANDBY_LEADER_LABEL_VALUE", + Value: c.OpConfig.PodStandbyLeaderLabelValue, + } { Name: "PGPASSWORD_SUPERUSER", ValueFrom: &v1.EnvVarSource{ diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 4c7b8db10..452ce9645 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -48,6 +48,8 @@ type Resources struct { DeleteAnnotationDateKey string `name:"delete_annotation_date_key"` DeleteAnnotationNameKey string `name:"delete_annotation_name_key"` PodRoleLabel string `name:"pod_role_label" default:"spilo-role"` + PodLeaderLabelValue string `name:"pod_leader_label_value" default:"master"` + PodStandbyLeaderLabelValue string `name:"pod_standby_leader_label_value" default:"master"` PodToleration map[string]string `name:"toleration" default:""` DefaultCPURequest string `name:"default_cpu_request"` DefaultMemoryRequest string `name:"default_memory_request"`