@@ -69,6 +69,7 @@ const (
69
69
SpiloRoleLabelValueMaster = "master"
70
70
SpiloRoleLabelValueStandbyLeader = "standby_leader"
71
71
StatefulsetPodNameLabelName = "statefulset.kubernetes.io/pod-name"
72
+ ClusterNameLabelName = "cluster-name"
72
73
73
74
teamIDPrefix = "pg"
74
75
@@ -84,6 +85,7 @@ const (
84
85
defaultPostgresParamValueWalKeepSegments = "64"
85
86
defaultPostgresParamValueWalKeepSize = "1GB"
86
87
defaultPostgresParamValuePGStatStatementsMax = "500"
88
+ defaultSelectorDisableValue = "selector-disabled"
87
89
defaultPostgresParamValuePasswordEncryption = "scram-sha-256" // nolint
88
90
defaultPostgresParamValueLogMinErrorStatement = "WARNING"
89
91
defaultPostgresParamValueLogErrorVerbosity = "VERBOSE"
@@ -211,6 +213,9 @@ type PostgresSpec struct {
211
213
212
214
// DedicatedLoadBalancerPort The port to use for the load balancer
213
215
DedicatedLoadBalancerPort * int32 `json:"dedicatedLoadBalancerPort,omitempty"`
216
+
217
+ // DisableLoadBalancers enable or disable the Load Balancers (Services)
218
+ DisableLoadBalancers * bool `json:"disableLoadBalancers,omitempty"`
214
219
}
215
220
216
221
// AccessList defines the type of restrictions to access the database
@@ -385,7 +390,7 @@ func (p *Postgres) ToSharedSvcLB(lbIP string, lbPort int32, enableStandbyLeaderS
385
390
386
391
lb .Spec .Selector = map [string ]string {
387
392
ApplicationLabelName : ApplicationLabelValue ,
388
- "cluster-name" : p .ToPeripheralResourceName (),
393
+ ClusterNameLabelName : p .ToPeripheralResourceName (),
389
394
"team" : p .generateTeamID (),
390
395
}
391
396
if p .IsReplicationPrimaryOrStandalone () {
@@ -401,6 +406,9 @@ func (p *Postgres) ToSharedSvcLB(lbIP string, lbPort int32, enableStandbyLeaderS
401
406
lb .Spec .Selector [StatefulsetPodNameLabelName ] = p .ToPeripheralResourceName () + "-0"
402
407
}
403
408
}
409
+ if p .DisableLoadBalancers () {
410
+ lb .Spec .Selector [ClusterNameLabelName ] = defaultSelectorDisableValue
411
+ }
404
412
405
413
if len (lbIP ) > 0 {
406
414
// if no ip is set, a new loadbalancer will be created automatically
@@ -479,7 +487,7 @@ func (p *Postgres) ToDedicatedSvcLB(lbIP string, lbPort int32, standbyClustersSo
479
487
480
488
lb .Spec .Selector = map [string ]string {
481
489
ApplicationLabelName : ApplicationLabelValue ,
482
- "cluster-name" : p .ToPeripheralResourceName (),
490
+ ClusterNameLabelName : p .ToPeripheralResourceName (),
483
491
"team" : p .generateTeamID (),
484
492
}
485
493
if p .IsReplicationPrimaryOrStandalone () {
@@ -488,6 +496,9 @@ func (p *Postgres) ToDedicatedSvcLB(lbIP string, lbPort int32, standbyClustersSo
488
496
// select the first pod in the statefulset
489
497
lb .Spec .Selector [StatefulsetPodNameLabelName ] = p .ToPeripheralResourceName () + "-0"
490
498
}
499
+ if p .DisableLoadBalancers () {
500
+ lb .Spec .Selector [ClusterNameLabelName ] = defaultSelectorDisableValue
501
+ }
491
502
492
503
if len (lbIP ) > 0 {
493
504
lb .Spec .LoadBalancerIP = lbIP
@@ -1068,3 +1079,11 @@ func (p *Postgres) ToStandbyClusterEgressCWNP() (*firewall.ClusterwideNetworkPol
1068
1079
1069
1080
return standbyEgressCWNP , nil
1070
1081
}
1082
+
1083
+ func (p * Postgres ) DisableLoadBalancers () bool {
1084
+ if p .Spec .DisableLoadBalancers == nil {
1085
+ return false
1086
+ }
1087
+
1088
+ return * p .Spec .DisableLoadBalancers
1089
+ }
0 commit comments