diff --git a/api/v1/runtimecomponent_types.go b/api/v1/runtimecomponent_types.go index 583268d0..c472fc17 100644 --- a/api/v1/runtimecomponent_types.go +++ b/api/v1/runtimecomponent_types.go @@ -149,6 +149,9 @@ type RuntimeComponentSpec struct { // +operator-sdk:csv:customresourcedefinitions:order=26,type=spec,displayName="Topology Spread Constraints" TopologySpreadConstraints *RuntimeComponentTopologySpreadConstraints `json:"topologySpreadConstraints,omitempty"` + + // +operator-sdk:csv:customresourcedefinitions:order=27,type=spec,displayName="Priority Class Name" + PriorityClassName *string `json:"priorityClassName,omitempty"` } // Defines the topology spread constraints @@ -703,6 +706,13 @@ func (cr *RuntimeComponent) GetDeployment() common.BaseComponentDeployment { return cr.Spec.Deployment } +func (cr *RuntimeComponent) GetPriorityClassName() *string { + if cr.Spec.PriorityClassName == nil { + return nil + } + return cr.Spec.PriorityClassName +} + // GetDeploymentStrategy returns deployment strategy struct func (cr *RuntimeComponentDeployment) GetDeploymentUpdateStrategy() *appsv1.DeploymentStrategy { return cr.UpdateStrategy diff --git a/common/types.go b/common/types.go index 7c8c141c..0e96e996 100644 --- a/common/types.go +++ b/common/types.go @@ -233,4 +233,5 @@ type BaseComponent interface { GetTopologySpreadConstraints() BaseComponentTopologySpreadConstraints GetSecurityContext() *corev1.SecurityContext GetManageTLS() *bool + GetPriorityClassName() *string } diff --git a/utils/utils.go b/utils/utils.go index 7d2bf1ca..401f16ed 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -745,6 +745,12 @@ func CustomizePodSpec(pts *corev1.PodTemplateSpec, ba common.BaseComponent) { } } pts.Spec.AutomountServiceAccountToken = &mount + + if ba.GetPriorityClassName() != nil { + pts.Spec.PriorityClassName = *ba.GetPriorityClassName() + } else { + pts.Spec.PriorityClassName = "" + } } // Initialize an empty TopologySpreadConstraints list and optionally prefers scheduling across zones/hosts for pods with podMatchLabels