Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: support priorityClassName for pooler pods #2497

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/postgres-operator/crds/postgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ spec:
numberOfInstances:
type: integer
minimum: 1
priorityClassName:
type: string
resources:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions manifests/complete-postgres-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ spec:
# schema: "pooler"
# user: "pooler"
# maxDBConnections: 60
# priorityClassName: ""
# resources:
# requests:
# cpu: 300m
Expand Down
1 change: 1 addition & 0 deletions manifests/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data:
# connection_pooler_number_of_instances: 2
# connection_pooler_schema: "pooler"
# connection_pooler_user: "pooler"
# connection_pooler_priority_class_name: ""
crd_categories: "all"
# custom_service_annotations: "keyx:valuez,keya:valuea"
# custom_pod_annotations: "keya:valuea,keyb:valueb"
Expand Down
2 changes: 2 additions & 0 deletions manifests/postgresql.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ spec:
numberOfInstances:
type: integer
minimum: 1
priorityClassName:
type: string
resources:
type: object
properties:
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/acid.zalan.do/v1/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
Type: "integer",
Minimum: &min1,
},

"priorityClassName": {
Type: "string",
},
"resources": {
Type: "object",
Properties: map[string]apiextv1.JSONSchemaProps{
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/acid.zalan.do/v1/operator_configuration_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ type ConnectionPoolerConfiguration struct {
DefaultMemoryRequest string `json:"connection_pooler_default_memory_request,omitempty"`
DefaultCPULimit string `json:"connection_pooler_default_cpu_limit,omitempty"`
DefaultMemoryLimit string `json:"connection_pooler_default_memory_limit,omitempty"`
PriorityClassName string `json:"connection_pooler_priority_class_name,omitempty"`
}

// OperatorLogicalBackupConfiguration defines configuration for logical backup
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/acid.zalan.do/v1/postgresql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ type ConnectionPooler struct {
Mode string `json:"mode,omitempty"`
DockerImage string `json:"dockerImage,omitempty"`
MaxDBConnections *int32 `json:"maxDBConnections,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`

*Resources `json:"resources,omitempty"`
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/cluster/connection_pooler.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) (
securityContext.FSGroup = effectiveFSGroup
}

effectivePriorityClassName := util.Coalesce(
connectionPoolerSpec.PriorityClassName,
c.OpConfig.ConnectionPooler.ConnectionPoolerPriorityClassName)

podTemplate := &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: c.connectionPoolerLabels(role, true).MatchLabels,
Expand All @@ -407,6 +411,7 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) (
Volumes: poolerVolumes,
SecurityContext: &securityContext,
ServiceAccountName: c.OpConfig.PodServiceAccountName,
PriorityClassName: effectivePriorityClassName,
},
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/operator_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
fromCRD.ConnectionPooler.MaxDBConnections,
k8sutil.Int32ToPointer(constants.ConnectionPoolerMaxDBConnections))

result.ConnectionPooler.ConnectionPoolerPriorityClassName = fromCRD.ConnectionPooler.PriorityClassName

return result
}
1 change: 1 addition & 0 deletions pkg/util/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ type ConnectionPooler struct {
ConnectionPoolerDefaultMemoryRequest string `name:"connection_pooler_default_memory_request"`
ConnectionPoolerDefaultCPULimit string `name:"connection_pooler_default_cpu_limit"`
ConnectionPoolerDefaultMemoryLimit string `name:"connection_pooler_default_memory_limit"`
ConnectionPoolerPriorityClassName string `name:"connection_pooler_priority_class_name"`
}

// Config describes operator config
Expand Down
Loading