diff --git a/api/v1/runtimecomponent_types.go b/api/v1/runtimecomponent_types.go index 9c875478..d7325f7d 100644 --- a/api/v1/runtimecomponent_types.go +++ b/api/v1/runtimecomponent_types.go @@ -163,6 +163,10 @@ type RuntimeComponentSpec struct { // DNS settings for the pod. // +operator-sdk:csv:customresourcedefinitions:order=29,type=spec,displayName="DNS" DNS *RuntimeComponentDNS `json:"dns,omitempty"` + + // Name of the PriorityClass for the pod. + // +operator-sdk:csv:customresourcedefinitions:order=30,type=spec,displayName="Priority Class Name" + PriorityClassName *string `json:"priorityClassName,omitempty"` } // Defines the DNS @@ -1072,6 +1076,10 @@ func (cr *RuntimeComponentTopologySpreadConstraints) GetDisableOperatorDefaults( return cr.DisableOperatorDefaults } +func (cr *RuntimeComponent) GetPriorityClassName() *string { + return cr.Spec.PriorityClassName +} + // Initialize the RuntimeComponent instance func (cr *RuntimeComponent) Initialize() { if cr.Spec.PullPolicy == nil { diff --git a/common/types.go b/common/types.go index c9232ad6..2dccb832 100644 --- a/common/types.go +++ b/common/types.go @@ -260,4 +260,5 @@ type BaseComponent interface { GetDisableServiceLinks() *bool GetTolerations() []corev1.Toleration GetDNS() BaseComponentDNS + GetPriorityClassName() *string } diff --git a/utils/utils.go b/utils/utils.go index 3d016372..ddabc207 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -785,6 +785,10 @@ func CustomizePodSpec(pts *corev1.PodTemplateSpec, ba common.BaseComponent) { } pts.Spec.Tolerations = ba.GetTolerations() + + if ba.GetPriorityClassName() != nil { + pts.Spec.PriorityClassName = *ba.GetPriorityClassName() + } } // Initialize an empty TopologySpreadConstraints list and optionally prefers scheduling across zones/hosts for pods with podMatchLabels