Merge pull request #5962 from seanlaii/priorityclass

Add priorityClassName in PropagationPolicy & ClusterPropagationPolicy
This commit is contained in:
karmada-bot 2025-02-19 00:18:15 +08:00 committed by GitHub
commit 9f8d71e892
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 251 additions and 1 deletions

View File

@ -19211,6 +19211,10 @@
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ResourceSelector"
}
},
"schedulePriority": {
"description": "SchedulePriority defines how Karmada should resolve the priority and preemption policy for workload scheduling.\n\nThis setting is useful for controlling the scheduling behavior of offline workloads. By setting a higher or lower priority, users can control which workloads are scheduled first. Additionally, it allows specifying a preemption policy where higher-priority workloads can preempt lower-priority ones in scenarios of resource contention.\n\nNote: This feature is currently in the alpha stage. The priority-based scheduling functionality is controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is supported. Preemption functionality is not yet available and will be introduced in future releases as the feature matures.",
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SchedulePriority"
},
"schedulerName": {
"description": "SchedulerName represents which scheduler to proceed the scheduling. If specified, the policy will be dispatched by specified scheduler. If not specified, the policy will be dispatched by default scheduler.",
"type": "string"
@ -19289,6 +19293,23 @@
}
}
},
"com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SchedulePriority": {
"description": "SchedulePriority defines how Karmada should resolve the priority and preemption policy for workload scheduling.",
"type": "object",
"required": [
"priorityClassName"
],
"properties": {
"priorityClassName": {
"description": "PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:\n\nBehavior of PriorityClassName:\n\nFor KubePriorityClass: - When specified: Uses the named Kubernetes PriorityClass. - When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster). - If neither exists: Sets priority=0 and preemptionPolicy=Never.\n\nFor PodPriorityClass: - Uses PriorityClassName from the PodTemplate. - If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass\n (i.e., the PriorityClass marked as the global default in the cluster).\n- If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never. - Not yet implemented.\n\nFor FederatedPriorityClass: - Not yet implemented.",
"type": "string"
},
"priorityClassSource": {
"description": "PriorityClassSource specifies where Karmada should look for the PriorityClass definition. Available options: - KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1) - PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented) - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)",
"type": "string"
}
}
},
"com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SpreadConstraint": {
"description": "SpreadConstraint represents the spread constraints on resources.",
"type": "object",

View File

@ -864,6 +864,57 @@ spec:
type: object
minItems: 1
type: array
schedulePriority:
description: |-
SchedulePriority defines how Karmada should resolve the priority and preemption policy
for workload scheduling.
This setting is useful for controlling the scheduling behavior of offline workloads.
By setting a higher or lower priority, users can control which workloads are scheduled first.
Additionally, it allows specifying a preemption policy where higher-priority workloads can
preempt lower-priority ones in scenarios of resource contention.
Note: This feature is currently in the alpha stage. The priority-based scheduling functionality is
controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the
PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is
supported. Preemption functionality is not yet available and will be introduced in future
releases as the feature matures.
properties:
priorityClassName:
description: |-
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
Behavior of PriorityClassName:
For KubePriorityClass:
- When specified: Uses the named Kubernetes PriorityClass.
- When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster).
- If neither exists: Sets priority=0 and preemptionPolicy=Never.
For PodPriorityClass:
- Uses PriorityClassName from the PodTemplate.
- If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass
(i.e., the PriorityClass marked as the global default in the cluster).
- If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never.
- Not yet implemented.
For FederatedPriorityClass:
- Not yet implemented.
type: string
priorityClassSource:
default: KubePriorityClass
description: |-
PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
Available options:
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
- PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented)
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
enum:
- KubePriorityClass
type: string
required:
- priorityClassName
type: object
schedulerName:
default: default-scheduler
description: |-

View File

@ -861,6 +861,57 @@ spec:
type: object
minItems: 1
type: array
schedulePriority:
description: |-
SchedulePriority defines how Karmada should resolve the priority and preemption policy
for workload scheduling.
This setting is useful for controlling the scheduling behavior of offline workloads.
By setting a higher or lower priority, users can control which workloads are scheduled first.
Additionally, it allows specifying a preemption policy where higher-priority workloads can
preempt lower-priority ones in scenarios of resource contention.
Note: This feature is currently in the alpha stage. The priority-based scheduling functionality is
controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the
PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is
supported. Preemption functionality is not yet available and will be introduced in future
releases as the feature matures.
properties:
priorityClassName:
description: |-
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
Behavior of PriorityClassName:
For KubePriorityClass:
- When specified: Uses the named Kubernetes PriorityClass.
- When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster).
- If neither exists: Sets priority=0 and preemptionPolicy=Never.
For PodPriorityClass:
- Uses PriorityClassName from the PodTemplate.
- If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass
(i.e., the PriorityClass marked as the global default in the cluster).
- If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never.
- Not yet implemented.
For FederatedPriorityClass:
- Not yet implemented.
type: string
priorityClassSource:
default: KubePriorityClass
description: |-
PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
Available options:
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
- PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented)
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
enum:
- KubePriorityClass
type: string
required:
- priorityClassName
type: object
schedulerName:
default: default-scheduler
description: |-

View File

@ -200,6 +200,23 @@ type PropagationSpec struct {
//
// +optional
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`
// SchedulePriority defines how Karmada should resolve the priority and preemption policy
// for workload scheduling.
//
// This setting is useful for controlling the scheduling behavior of offline workloads.
// By setting a higher or lower priority, users can control which workloads are scheduled first.
// Additionally, it allows specifying a preemption policy where higher-priority workloads can
// preempt lower-priority ones in scenarios of resource contention.
//
// Note: This feature is currently in the alpha stage. The priority-based scheduling functionality is
// controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the
// PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is
// supported. Preemption functionality is not yet available and will be introduced in future
// releases as the feature matures.
//
// +optional
SchedulePriority *SchedulePriority `json:"schedulePriority,omitempty"`
}
// ResourceSelector the resources will be selected.
@ -660,6 +677,60 @@ const (
LazyActivation ActivationPreference = "Lazy"
)
// SchedulePriority defines how Karmada should resolve the priority and preemption policy
// for workload scheduling.
type SchedulePriority struct {
// PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
// Available options:
// - KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
// - PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented)
// - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
//
// +kubebuilder:default="KubePriorityClass"
// +kubebuilder:validation:Enum=KubePriorityClass
// +optional
PriorityClassSource PriorityClassSource `json:"priorityClassSource,omitempty"`
// PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
//
// Behavior of PriorityClassName:
//
// For KubePriorityClass:
// - When specified: Uses the named Kubernetes PriorityClass.
// - When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster).
// - If neither exists: Sets priority=0 and preemptionPolicy=Never.
//
// For PodPriorityClass:
// - Uses PriorityClassName from the PodTemplate.
// - If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass
// (i.e., the PriorityClass marked as the global default in the cluster).
// - If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never.
// - Not yet implemented.
//
// For FederatedPriorityClass:
// - Not yet implemented.
//
// +required
PriorityClassName string `json:"priorityClassName,omitempty"`
}
// PriorityClassSource defines the type for PriorityClassSource field.
type PriorityClassSource string
const (
// FederatedPriorityClass specifies to use Karmada FederatedPriorityClass for priority resolution.
// This feature is planned for future releases and is currently not implemented.
FederatedPriorityClass PriorityClassSource = "FederatedPriorityClass"
// KubePriorityClass specifies to use Kubernetes native PriorityClass (scheduling.k8s.io/v1)
// for priority resolution. This is the default source.
KubePriorityClass PriorityClassSource = "KubePriorityClass"
// PodPriorityClass specifies to use the PriorityClassName defined in the workload's
// PodTemplate for priority resolution.
PodPriorityClass PriorityClassSource = "PodPriorityClass"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PropagationPolicyList contains a list of PropagationPolicy.

View File

@ -907,6 +907,11 @@ func (in *PropagationSpec) DeepCopyInto(out *PropagationSpec) {
*out = new(bool)
**out = **in
}
if in.SchedulePriority != nil {
in, out := &in.SchedulePriority, &out.SchedulePriority
*out = new(SchedulePriority)
**out = **in
}
return
}
@ -984,6 +989,22 @@ func (in *RuleWithCluster) DeepCopy() *RuleWithCluster {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SchedulePriority) DeepCopyInto(out *SchedulePriority) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchedulePriority.
func (in *SchedulePriority) DeepCopy() *SchedulePriority {
if in == nil {
return nil
}
out := new(SchedulePriority)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SpreadConstraint) DeepCopyInto(out *SpreadConstraint) {
*out = *in

View File

@ -128,6 +128,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ReplicaSchedulingStrategy": schema_pkg_apis_policy_v1alpha1_ReplicaSchedulingStrategy(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ResourceSelector": schema_pkg_apis_policy_v1alpha1_ResourceSelector(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.RuleWithCluster": schema_pkg_apis_policy_v1alpha1_RuleWithCluster(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SchedulePriority": schema_pkg_apis_policy_v1alpha1_SchedulePriority(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SpreadConstraint": schema_pkg_apis_policy_v1alpha1_SpreadConstraint(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.StatePreservation": schema_pkg_apis_policy_v1alpha1_StatePreservation(ref),
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.StatePreservationRule": schema_pkg_apis_policy_v1alpha1_StatePreservationRule(ref),
@ -5008,12 +5009,18 @@ func schema_pkg_apis_policy_v1alpha1_PropagationSpec(ref common.ReferenceCallbac
Format: "",
},
},
"schedulePriority": {
SchemaProps: spec.SchemaProps{
Description: "SchedulePriority defines how Karmada should resolve the priority and preemption policy for workload scheduling.\n\nThis setting is useful for controlling the scheduling behavior of offline workloads. By setting a higher or lower priority, users can control which workloads are scheduled first. Additionally, it allows specifying a preemption policy where higher-priority workloads can preempt lower-priority ones in scenarios of resource contention.\n\nNote: This feature is currently in the alpha stage. The priority-based scheduling functionality is controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is supported. Preemption functionality is not yet available and will be introduced in future releases as the feature matures.",
Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SchedulePriority"),
},
},
},
Required: []string{"resourceSelectors"},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FailoverBehavior", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.Placement", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ResourceSelector", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.Suspension"},
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FailoverBehavior", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.Placement", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ResourceSelector", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SchedulePriority", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.Suspension"},
}
}
@ -5133,6 +5140,34 @@ func schema_pkg_apis_policy_v1alpha1_RuleWithCluster(ref common.ReferenceCallbac
}
}
func schema_pkg_apis_policy_v1alpha1_SchedulePriority(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "SchedulePriority defines how Karmada should resolve the priority and preemption policy for workload scheduling.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"priorityClassSource": {
SchemaProps: spec.SchemaProps{
Description: "PriorityClassSource specifies where Karmada should look for the PriorityClass definition. Available options: - KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1) - PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented) - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)",
Type: []string{"string"},
Format: "",
},
},
"priorityClassName": {
SchemaProps: spec.SchemaProps{
Description: "PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:\n\nBehavior of PriorityClassName:\n\nFor KubePriorityClass: - When specified: Uses the named Kubernetes PriorityClass. - When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster). - If neither exists: Sets priority=0 and preemptionPolicy=Never.\n\nFor PodPriorityClass: - Uses PriorityClassName from the PodTemplate. - If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass\n (i.e., the PriorityClass marked as the global default in the cluster).\n- If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never. - Not yet implemented.\n\nFor FederatedPriorityClass: - Not yet implemented.",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"priorityClassName"},
},
},
}
}
func schema_pkg_apis_policy_v1alpha1_SpreadConstraint(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{