@@ -78,22 +78,22 @@ func needReplicaConnectionPoolerWorker(spec *acidv1.PostgresSpec) bool {
78
78
// have e.g. different `application` label, so that recreatePod operation will
79
79
// not interfere with it (it lists all the pods via labels, and if there would
80
80
// be no difference, it will recreate also pooler pods).
81
- func (c * Cluster ) connectionPoolerLabelsSelector (role PostgresRole ) * metav1.LabelSelector {
82
- connectionPoolerLabels := labels . Set ( map [ string ] string {} )
81
+ func (c * Cluster ) connectionPoolerLabels (role PostgresRole , addExtraLabels bool ) * metav1.LabelSelector {
82
+ poolerLabels := c . labelsSet ( addExtraLabels )
83
83
84
- extraLabels := labels .Set (map [string ]string {
85
- "connection-pooler" : c .connectionPoolerName (role ),
86
- "application" : "db-connection-pooler" ,
87
- "spilo-role" : string (role ),
88
- "cluster-name" : c .Name ,
89
- "Namespace" : c .Namespace ,
90
- })
84
+ // TODO should be config values
85
+ poolerLabels ["application" ] = "db-connection-pooler"
86
+ poolerLabels ["connection-pooler" ] = c .connectionPoolerName (role )
91
87
92
- connectionPoolerLabels = labels .Merge (connectionPoolerLabels , c .labelsSet (false ))
93
- connectionPoolerLabels = labels .Merge (connectionPoolerLabels , extraLabels )
88
+ if addExtraLabels {
89
+ extraLabels := map [string ]string {}
90
+ extraLabels ["spilo-role" ] = string (role )
91
+
92
+ poolerLabels = labels .Merge (poolerLabels , extraLabels )
93
+ }
94
94
95
95
return & metav1.LabelSelector {
96
- MatchLabels : connectionPoolerLabels ,
96
+ MatchLabels : poolerLabels ,
97
97
MatchExpressions : nil ,
98
98
}
99
99
}
@@ -284,7 +284,7 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) (
284
284
285
285
podTemplate := & v1.PodTemplateSpec {
286
286
ObjectMeta : metav1.ObjectMeta {
287
- Labels : c .connectionPoolerLabelsSelector (role ).MatchLabels ,
287
+ Labels : c .connectionPoolerLabels (role , true ).MatchLabels ,
288
288
Namespace : c .Namespace ,
289
289
Annotations : c .generatePodAnnotations (spec ),
290
290
},
@@ -338,7 +338,7 @@ func (c *Cluster) generateConnectionPoolerDeployment(connectionPooler *Connectio
338
338
ObjectMeta : metav1.ObjectMeta {
339
339
Name : connectionPooler .Name ,
340
340
Namespace : connectionPooler .Namespace ,
341
- Labels : c .connectionPoolerLabelsSelector (connectionPooler .Role ).MatchLabels ,
341
+ Labels : c .connectionPoolerLabels (connectionPooler .Role , true ).MatchLabels ,
342
342
Annotations : map [string ]string {},
343
343
// make StatefulSet object its owner to represent the dependency.
344
344
// By itself StatefulSet is being deleted with "Orphaned"
@@ -350,7 +350,7 @@ func (c *Cluster) generateConnectionPoolerDeployment(connectionPooler *Connectio
350
350
},
351
351
Spec : appsv1.DeploymentSpec {
352
352
Replicas : numberOfInstances ,
353
- Selector : c .connectionPoolerLabelsSelector (connectionPooler .Role ),
353
+ Selector : c .connectionPoolerLabels (connectionPooler .Role , false ),
354
354
Template : * podTemplate ,
355
355
},
356
356
}
@@ -389,7 +389,7 @@ func (c *Cluster) generateConnectionPoolerService(connectionPooler *ConnectionPo
389
389
ObjectMeta : metav1.ObjectMeta {
390
390
Name : connectionPooler .Name ,
391
391
Namespace : connectionPooler .Namespace ,
392
- Labels : c .connectionPoolerLabelsSelector (connectionPooler .Role ).MatchLabels ,
392
+ Labels : c .connectionPoolerLabels (connectionPooler .Role , false ).MatchLabels ,
393
393
Annotations : map [string ]string {},
394
394
// make StatefulSet object its owner to represent the dependency.
395
395
// By itself StatefulSet is being deleted with "Orphaned"
0 commit comments