Skip to content

Commit 4bf165a

Browse files
committed
Add priorityClassName in PropagationPolicy & ClusterPropagationPolicy
Signed-off-by: wei-chenglai <qazwsx0939059006@gmail.com>
1 parent f555413 commit 4bf165a

File tree

6 files changed

+251
-1
lines changed

6 files changed

+251
-1
lines changed

api/openapi-spec/swagger.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19211,6 +19211,10 @@
1921119211
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ResourceSelector"
1921219212
}
1921319213
},
19214+
"schedulePriority": {
19215+
"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.",
19216+
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SchedulePriority"
19217+
},
1921419218
"schedulerName": {
1921519219
"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.",
1921619220
"type": "string"
@@ -19289,6 +19293,23 @@
1928919293
}
1929019294
}
1929119295
},
19296+
"com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SchedulePriority": {
19297+
"description": "SchedulePriority defines how Karmada should resolve the priority and preemption policy for workload scheduling.",
19298+
"type": "object",
19299+
"required": [
19300+
"priorityClassName"
19301+
],
19302+
"properties": {
19303+
"priorityClassName": {
19304+
"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.",
19305+
"type": "string"
19306+
},
19307+
"priorityClassSource": {
19308+
"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)",
19309+
"type": "string"
19310+
}
19311+
}
19312+
},
1929219313
"com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SpreadConstraint": {
1929319314
"description": "SpreadConstraint represents the spread constraints on resources.",
1929419315
"type": "object",

charts/karmada/_crds/bases/policy/policy.karmada.io_clusterpropagationpolicies.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,57 @@ spec:
864864
type: object
865865
minItems: 1
866866
type: array
867+
schedulePriority:
868+
description: |-
869+
SchedulePriority defines how Karmada should resolve the priority and preemption policy
870+
for workload scheduling.
871+
872+
This setting is useful for controlling the scheduling behavior of offline workloads.
873+
By setting a higher or lower priority, users can control which workloads are scheduled first.
874+
Additionally, it allows specifying a preemption policy where higher-priority workloads can
875+
preempt lower-priority ones in scenarios of resource contention.
876+
877+
Note: This feature is currently in the alpha stage. The priority-based scheduling functionality is
878+
controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the
879+
PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is
880+
supported. Preemption functionality is not yet available and will be introduced in future
881+
releases as the feature matures.
882+
properties:
883+
priorityClassName:
884+
description: |-
885+
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
886+
887+
Behavior of PriorityClassName:
888+
889+
For KubePriorityClass:
890+
- When specified: Uses the named Kubernetes PriorityClass.
891+
- When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster).
892+
- If neither exists: Sets priority=0 and preemptionPolicy=Never.
893+
894+
For PodPriorityClass:
895+
- Uses PriorityClassName from the PodTemplate.
896+
- If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass
897+
(i.e., the PriorityClass marked as the global default in the cluster).
898+
- If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never.
899+
- Not yet implemented.
900+
901+
For FederatedPriorityClass:
902+
- Not yet implemented.
903+
type: string
904+
priorityClassSource:
905+
default: KubePriorityClass
906+
description: |-
907+
PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
908+
Available options:
909+
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
910+
- PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented)
911+
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
912+
enum:
913+
- KubePriorityClass
914+
type: string
915+
required:
916+
- priorityClassName
917+
type: object
867918
schedulerName:
868919
default: default-scheduler
869920
description: |-

charts/karmada/_crds/bases/policy/policy.karmada.io_propagationpolicies.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,57 @@ spec:
861861
type: object
862862
minItems: 1
863863
type: array
864+
schedulePriority:
865+
description: |-
866+
SchedulePriority defines how Karmada should resolve the priority and preemption policy
867+
for workload scheduling.
868+
869+
This setting is useful for controlling the scheduling behavior of offline workloads.
870+
By setting a higher or lower priority, users can control which workloads are scheduled first.
871+
Additionally, it allows specifying a preemption policy where higher-priority workloads can
872+
preempt lower-priority ones in scenarios of resource contention.
873+
874+
Note: This feature is currently in the alpha stage. The priority-based scheduling functionality is
875+
controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the
876+
PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is
877+
supported. Preemption functionality is not yet available and will be introduced in future
878+
releases as the feature matures.
879+
properties:
880+
priorityClassName:
881+
description: |-
882+
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
883+
884+
Behavior of PriorityClassName:
885+
886+
For KubePriorityClass:
887+
- When specified: Uses the named Kubernetes PriorityClass.
888+
- When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster).
889+
- If neither exists: Sets priority=0 and preemptionPolicy=Never.
890+
891+
For PodPriorityClass:
892+
- Uses PriorityClassName from the PodTemplate.
893+
- If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass
894+
(i.e., the PriorityClass marked as the global default in the cluster).
895+
- If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never.
896+
- Not yet implemented.
897+
898+
For FederatedPriorityClass:
899+
- Not yet implemented.
900+
type: string
901+
priorityClassSource:
902+
default: KubePriorityClass
903+
description: |-
904+
PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
905+
Available options:
906+
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
907+
- PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented)
908+
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
909+
enum:
910+
- KubePriorityClass
911+
type: string
912+
required:
913+
- priorityClassName
914+
type: object
864915
schedulerName:
865916
default: default-scheduler
866917
description: |-

pkg/apis/policy/v1alpha1/propagation_types.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ type PropagationSpec struct {
200200
//
201201
// +optional
202202
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`
203+
204+
// SchedulePriority defines how Karmada should resolve the priority and preemption policy
205+
// for workload scheduling.
206+
//
207+
// This setting is useful for controlling the scheduling behavior of offline workloads.
208+
// By setting a higher or lower priority, users can control which workloads are scheduled first.
209+
// Additionally, it allows specifying a preemption policy where higher-priority workloads can
210+
// preempt lower-priority ones in scenarios of resource contention.
211+
//
212+
// Note: This feature is currently in the alpha stage. The priority-based scheduling functionality is
213+
// controlled by the PriorityBasedScheduling feature gate, and preemption is controlled by the
214+
// PriorityBasedPreemptiveScheduling feature gate. Currently, only priority-based scheduling is
215+
// supported. Preemption functionality is not yet available and will be introduced in future
216+
// releases as the feature matures.
217+
//
218+
// +optional
219+
SchedulePriority *SchedulePriority `json:"schedulePriority,omitempty"`
203220
}
204221

205222
// ResourceSelector the resources will be selected.
@@ -660,6 +677,60 @@ const (
660677
LazyActivation ActivationPreference = "Lazy"
661678
)
662679

680+
// SchedulePriority defines how Karmada should resolve the priority and preemption policy
681+
// for workload scheduling.
682+
type SchedulePriority struct {
683+
// PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
684+
// Available options:
685+
// - KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
686+
// - PodPriorityClass: Uses PriorityClassName from PodTemplate: PodSpec.PriorityClassName (not yet implemented)
687+
// - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
688+
//
689+
// +kubebuilder:default="KubePriorityClass"
690+
// +kubebuilder:validation:Enum=KubePriorityClass
691+
// +optional
692+
PriorityClassSource PriorityClassSource `json:"priorityClassSource,omitempty"`
693+
694+
// PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
695+
//
696+
// Behavior of PriorityClassName:
697+
//
698+
// For KubePriorityClass:
699+
// - When specified: Uses the named Kubernetes PriorityClass.
700+
// - When empty: Uses the cluster's default PriorityClass (i.e., the PriorityClass marked as the global default in the cluster).
701+
// - If neither exists: Sets priority=0 and preemptionPolicy=Never.
702+
//
703+
// For PodPriorityClass:
704+
// - Uses PriorityClassName from the PodTemplate.
705+
// - If the specified PriorityClass is not found, falls back to the cluster's default PriorityClass
706+
// (i.e., the PriorityClass marked as the global default in the cluster).
707+
// - If no valid PriorityClass is found: Sets priority=0 and preemptionPolicy=Never.
708+
// - Not yet implemented.
709+
//
710+
// For FederatedPriorityClass:
711+
// - Not yet implemented.
712+
//
713+
// +required
714+
PriorityClassName string `json:"priorityClassName,omitempty"`
715+
}
716+
717+
// PriorityClassSource defines the type for PriorityClassSource field.
718+
type PriorityClassSource string
719+
720+
const (
721+
// FederatedPriorityClass specifies to use Karmada FederatedPriorityClass for priority resolution.
722+
// This feature is planned for future releases and is currently not implemented.
723+
FederatedPriorityClass PriorityClassSource = "FederatedPriorityClass"
724+
725+
// KubePriorityClass specifies to use Kubernetes native PriorityClass (scheduling.k8s.io/v1)
726+
// for priority resolution. This is the default source.
727+
KubePriorityClass PriorityClassSource = "KubePriorityClass"
728+
729+
// PodPriorityClass specifies to use the PriorityClassName defined in the workload's
730+
// PodTemplate for priority resolution.
731+
PodPriorityClass PriorityClassSource = "PodPriorityClass"
732+
)
733+
663734
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
664735

665736
// PropagationPolicyList contains a list of PropagationPolicy.

pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)