mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-09 08:56:37 +02:00
make pooler labels configurable and change defaults
This commit is contained in:
@@ -1782,6 +1782,8 @@ func TestCrossNamespacedSecrets(t *testing.T) {
|
||||
Config{
|
||||
OpConfig: config.Config{
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
|
||||
@@ -115,8 +115,9 @@ func (c *Cluster) poolerUser(spec *acidv1.PostgresSpec) string {
|
||||
func (c *Cluster) poolerLabelsSet(addExtraLabels bool) labels.Set {
|
||||
poolerLabels := c.labelsSet(addExtraLabels)
|
||||
|
||||
// TODO should be config values
|
||||
poolerLabels["application"] = "db-connection-pooler"
|
||||
for k, v := range c.OpConfig.ConnectionPooler.Labels {
|
||||
poolerLabels[k] = v
|
||||
}
|
||||
|
||||
return poolerLabels
|
||||
}
|
||||
@@ -134,7 +135,7 @@ func (c *Cluster) connectionPoolerLabels(role PostgresRole, addExtraLabels bool)
|
||||
|
||||
if addExtraLabels {
|
||||
extraLabels := map[string]string{}
|
||||
extraLabels[c.OpConfig.PodRoleLabel] = string(role)
|
||||
extraLabels[c.OpConfig.ConnectionPooler.RoleLabel] = string(role)
|
||||
|
||||
poolerLabelsSet = labels.Merge(poolerLabelsSet, extraLabels)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func deploymentUpdated(cluster *Cluster, err error, reason SyncReason) error {
|
||||
for _, role := range [2]PostgresRole{Master, Replica} {
|
||||
|
||||
poolerLabels := cluster.labelsSet(false)
|
||||
poolerLabels["application"] = "db-connection-pooler"
|
||||
poolerLabels["component"] = "db-connection-pooler"
|
||||
poolerLabels["connection-pooler"] = cluster.connectionPoolerName(role)
|
||||
|
||||
if cluster.ConnectionPooler[role] != nil && cluster.ConnectionPooler[role].Deployment != nil &&
|
||||
@@ -65,7 +65,7 @@ func objectsAreSaved(cluster *Cluster, err error, reason SyncReason) error {
|
||||
|
||||
for _, role := range []PostgresRole{Master, Replica} {
|
||||
poolerLabels := cluster.labelsSet(false)
|
||||
poolerLabels["application"] = "db-connection-pooler"
|
||||
poolerLabels["component"] = "db-connection-pooler"
|
||||
poolerLabels["connection-pooler"] = cluster.connectionPoolerName(role)
|
||||
|
||||
if cluster.ConnectionPooler[role].Deployment == nil || !util.MapContains(cluster.ConnectionPooler[role].Deployment.Labels, poolerLabels) {
|
||||
@@ -86,7 +86,7 @@ func MasterObjectsAreSaved(cluster *Cluster, err error, reason SyncReason) error
|
||||
}
|
||||
|
||||
poolerLabels := cluster.labelsSet(false)
|
||||
poolerLabels["application"] = "db-connection-pooler"
|
||||
poolerLabels["component"] = "db-connection-pooler"
|
||||
poolerLabels["connection-pooler"] = cluster.connectionPoolerName(Master)
|
||||
|
||||
if cluster.ConnectionPooler[Master].Deployment == nil || !util.MapContains(cluster.ConnectionPooler[Master].Deployment.Labels, poolerLabels) {
|
||||
@@ -106,7 +106,7 @@ func ReplicaObjectsAreSaved(cluster *Cluster, err error, reason SyncReason) erro
|
||||
}
|
||||
|
||||
poolerLabels := cluster.labelsSet(false)
|
||||
poolerLabels["application"] = "db-connection-pooler"
|
||||
poolerLabels["component"] = "db-connection-pooler"
|
||||
poolerLabels["connection-pooler"] = cluster.connectionPoolerName(Replica)
|
||||
|
||||
if cluster.ConnectionPooler[Replica].Deployment == nil || !util.MapContains(cluster.ConnectionPooler[Replica].Deployment.Labels, poolerLabels) {
|
||||
@@ -170,6 +170,8 @@ func TestNeedConnectionPooler(t *testing.T) {
|
||||
ReplicationUsername: replicationUserName,
|
||||
},
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
@@ -301,6 +303,8 @@ func TestConnectionPoolerCreateDeletion(t *testing.T) {
|
||||
Config{
|
||||
OpConfig: config.Config{
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
@@ -336,7 +340,7 @@ func TestConnectionPoolerCreateDeletion(t *testing.T) {
|
||||
}
|
||||
for _, role := range [2]PostgresRole{Master, Replica} {
|
||||
poolerLabels := cluster.labelsSet(false)
|
||||
poolerLabels["application"] = "db-connection-pooler"
|
||||
poolerLabels["component"] = "db-connection-pooler"
|
||||
poolerLabels["connection-pooler"] = cluster.connectionPoolerName(role)
|
||||
|
||||
if cluster.ConnectionPooler[role] != nil {
|
||||
@@ -409,6 +413,8 @@ func TestConnectionPoolerSync(t *testing.T) {
|
||||
Config{
|
||||
OpConfig: config.Config{
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
@@ -678,6 +684,8 @@ func TestConnectionPoolerPodSpec(t *testing.T) {
|
||||
PodServiceAccountName: "postgres-pod",
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
MaxDBConnections: k8sutil.Int32ToPointer(60),
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
@@ -789,6 +797,8 @@ func TestConnectionPoolerDeploymentSpec(t *testing.T) {
|
||||
ReplicationUsername: replicationUserName,
|
||||
},
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
@@ -1003,6 +1013,8 @@ func TestPoolerTLS(t *testing.T) {
|
||||
SpiloFSGroup: &spiloFSGroup,
|
||||
},
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
@@ -1072,6 +1084,8 @@ func TestConnectionPoolerServiceSpec(t *testing.T) {
|
||||
ReplicationUsername: replicationUserName,
|
||||
},
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
|
||||
@@ -3022,6 +3022,8 @@ func TestEnableLoadBalancers(t *testing.T) {
|
||||
subTest: "LBs enabled in config, disabled in manifest",
|
||||
config: config.Config{
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
@@ -3069,6 +3071,8 @@ func TestEnableLoadBalancers(t *testing.T) {
|
||||
subTest: "LBs enabled in manifest, disabled in config",
|
||||
config: config.Config{
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
|
||||
@@ -192,6 +192,8 @@ func TestPodAnnotationsSync(t *testing.T) {
|
||||
PodManagementPolicy: "ordered_ready",
|
||||
CustomPodAnnotations: customPodAnnotations,
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
|
||||
@@ -301,6 +301,8 @@ func newInheritedAnnotationsCluster(client k8sutil.KubernetesClient) (*Cluster,
|
||||
PatroniAPICheckTimeout: time.Duration(5),
|
||||
KubernetesUseConfigMaps: true,
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
Labels: map[string]string{"component": "db-connection-pooler"},
|
||||
RoleLabel: "pooler-role",
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
ConnectionPoolerDefaultMemoryRequest: "100Mi",
|
||||
|
||||
Reference in New Issue
Block a user