Skip to content

Commit 1249626

Browse files
ReSearchITEngFxKu
andauthored
kubernetes_use_configmap (zalando#887)
* kubernetes_use_configmap * Update manifests/postgresql-operator-default-configuration.yaml Co-Authored-By: Felix Kunde <[email protected]> * Update manifests/configmap.yaml Co-Authored-By: Felix Kunde <[email protected]> * Update charts/postgres-operator/values.yaml Co-Authored-By: Felix Kunde <[email protected]> * go.fmt Co-authored-by: Felix Kunde <[email protected]>
1 parent b43b22d commit 1249626

File tree

13 files changed

+41
-6
lines changed

13 files changed

+41
-6
lines changed

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ spec:
6666
type: boolean
6767
etcd_host:
6868
type: string
69+
kubernetes_use_configmaps:
70+
type: boolean
6971
max_instances:
7072
type: integer
7173
minimum: -1 # -1 = disabled

charts/postgres-operator/values-crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ configGeneral:
2323
enable_shm_volume: true
2424
# etcd connection string for Patroni. Empty uses K8s-native DCS.
2525
etcd_host: ""
26+
# Select if setup uses endpoints (default), or configmaps to manage leader (DCS=k8s)
27+
# kubernetes_use_configmaps: false
2628
# Spilo docker image
2729
docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2
2830
# max number of instances in Postgres cluster. -1 = no limit

charts/postgres-operator/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ configGeneral:
2323
enable_shm_volume: "true"
2424
# etcd connection string for Patroni. Empty uses K8s-native DCS.
2525
etcd_host: ""
26+
# Select if setup uses endpoints (default), or configmaps to manage leader (DCS=k8s)
27+
# kubernetes_use_configmaps: "false"
2628
# Spilo docker image
2729
docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2
2830
# max number of instances in Postgres cluster. -1 = no limit

docs/reference/operator_parameters.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ Those are top-level keys, containing both leaf keys and groups.
8080
Patroni native Kubernetes support is used. The default is empty (use
8181
Kubernetes-native DCS).
8282

83+
* **kubernetes_use_configmaps**
84+
Select if setup uses endpoints (default), or configmaps to manage leader when
85+
DCS is kubernetes (not etcd or similar). In OpenShift it is not possible to
86+
use endpoints option, and configmaps is required. By default,
87+
`kubernetes_use_configmaps: false`, meaning endpoints will be used.
88+
8389
* **docker_image**
8490
Spilo Docker image for Postgres instances. For production, don't rely on the
8591
default image, as it might be not the most up-to-date one. Instead, build

manifests/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ data:
4343
# enable_team_superuser: "false"
4444
enable_teams_api: "false"
4545
# etcd_host: ""
46+
# kubernetes_use_configmaps: "false"
4647
# infrastructure_roles_secret_name: postgresql-infrastructure-roles
4748
# inherited_labels: application,environment
4849
# kube_iam_role: ""

manifests/operatorconfiguration.crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ spec:
4242
type: boolean
4343
etcd_host:
4444
type: string
45+
kubernetes_use_configmaps:
46+
type: boolean
4547
max_instances:
4648
type: integer
4749
minimum: -1 # -1 = disabled

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
configuration:
66
# enable_crd_validation: true
77
etcd_host: ""
8+
# kubernetes_use_configmaps: false
89
docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2
910
# enable_shm_volume: true
1011
max_instances: -1

pkg/apis/acid.zalan.do/v1/crds.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,9 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation
727727
"etcd_host": {
728728
Type: "string",
729729
},
730+
"kubernetes_use_configmaps": {
731+
Type: "boolean",
732+
},
730733
"max_instances": {
731734
Type: "integer",
732735
Description: "-1 = disabled",

pkg/apis/acid.zalan.do/v1/operator_configuration_type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ type OperatorLogicalBackupConfiguration struct {
183183
type OperatorConfigurationData struct {
184184
EnableCRDValidation *bool `json:"enable_crd_validation,omitempty"`
185185
EtcdHost string `json:"etcd_host,omitempty"`
186+
KubernetesUseConfigMaps bool `json:"kubernetes_use_configmaps,omitempty"`
186187
DockerImage string `json:"docker_image,omitempty"`
187188
Workers uint32 `json:"workers,omitempty"`
188189
MinInstances int32 `json:"min_instances,omitempty"`

pkg/cluster/k8sres.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,10 @@ func (c *Cluster) generateSpiloPodEnvVars(uid types.UID, spiloConfiguration stri
672672
envVars = append(envVars, v1.EnvVar{Name: "ETCD_HOST", Value: c.OpConfig.EtcdHost})
673673
}
674674

675+
if c.patroniKubernetesUseConfigMaps() {
676+
envVars = append(envVars, v1.EnvVar{Name: "KUBERNETES_USE_CONFIGMAPS", Value: "true"})
677+
}
678+
675679
if cloneDescription.ClusterName != "" {
676680
envVars = append(envVars, c.generateCloneEnvironment(cloneDescription)...)
677681
}
@@ -1406,7 +1410,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec)
14061410
Type: v1.ServiceTypeClusterIP,
14071411
}
14081412

1409-
if role == Replica {
1413+
if role == Replica || c.patroniKubernetesUseConfigMaps() {
14101414
serviceSpec.Selector = c.roleLabelsSet(false, role)
14111415
}
14121416

0 commit comments

Comments
 (0)