Skip to content

Commit 25e0f40

Browse files
committed
Add priorityClassName in PropagationPolicy & ClusterPropagationPolicy
Signed-off-by: wei-chenglai <qazwsx0939059006@gmail.com>
1 parent 5bfdf61 commit 25e0f40

File tree

6 files changed

+274
-1
lines changed

6 files changed

+274
-1
lines changed

api/openapi-spec/swagger.json

Lines changed: 18 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\nValid options for PriorityClassSource are: - KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1) - PodPriorityClass: Uses PriorityClassName from PodTemplate (PodSpec.PriorityClassName) - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)\n\nPriorityClassName behavior:\n\nFor KubePriorityClass: - If specified: Uses the named Kubernetes PriorityClass - If empty: Uses cluster's global default PriorityClass - If neither exists: Sets priority=0 and preemptionPolicy=Never\n\nFor PodPriorityClass: - Uses PriorityClassName from PodTemplate - Falls back to global default if not found - If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never\n\nFor FederatedPriorityClass: - Reserved for future use - Current behavior undefined",
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,20 @@
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+
"properties": {
19300+
"priorityClassName": {
19301+
"description": "PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:\n\nPriorityClassName behavior:\n\nFor KubePriorityClass: - If specified: Uses the named Kubernetes PriorityClass - If empty: Uses cluster's global default PriorityClass - If neither exists: Sets priority=0 and preemptionPolicy=Never\n\nFor PodPriorityClass: - Uses PriorityClassName from PodTemplate - Falls back to global default if not found - If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never\n\nFor FederatedPriorityClass: - Reserved for future use - Current behavior undefined",
19302+
"type": "string"
19303+
},
19304+
"priorityClassSource": {
19305+
"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) - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)",
19306+
"type": "string"
19307+
}
19308+
}
19309+
},
1929219310
"com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.SpreadConstraint": {
1929319311
"description": "SpreadConstraint represents the spread constraints on resources.",
1929419312
"type": "object",

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,66 @@ 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+
Valid options for PriorityClassSource are:
873+
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
874+
- PodPriorityClass: Uses PriorityClassName from PodTemplate (PodSpec.PriorityClassName)
875+
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
876+
877+
PriorityClassName behavior:
878+
879+
For KubePriorityClass:
880+
- If specified: Uses the named Kubernetes PriorityClass
881+
- If empty: Uses cluster's global default PriorityClass
882+
- If neither exists: Sets priority=0 and preemptionPolicy=Never
883+
884+
For PodPriorityClass:
885+
- Uses PriorityClassName from PodTemplate
886+
- Falls back to global default if not found
887+
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
888+
889+
For FederatedPriorityClass:
890+
- Reserved for future use
891+
- Current behavior undefined
892+
properties:
893+
priorityClassName:
894+
description: |-
895+
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
896+
897+
PriorityClassName behavior:
898+
899+
For KubePriorityClass:
900+
- If specified: Uses the named Kubernetes PriorityClass
901+
- If empty: Uses cluster's global default PriorityClass
902+
- If neither exists: Sets priority=0 and preemptionPolicy=Never
903+
904+
For PodPriorityClass:
905+
- Uses PriorityClassName from PodTemplate
906+
- Falls back to global default if not found
907+
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
908+
909+
For FederatedPriorityClass:
910+
- Reserved for future use
911+
- Current behavior undefined
912+
type: string
913+
priorityClassSource:
914+
default: KubePriorityClass
915+
description: |-
916+
PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
917+
Available options:
918+
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
919+
- PodPriorityClass: Uses PriorityClassName from PodTemplate (PodSpec.PriorityClassName)
920+
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
921+
enum:
922+
- FederatedPriorityClass
923+
- KubePriorityClass
924+
- PodPriorityClass
925+
type: string
926+
type: object
867927
schedulerName:
868928
default: default-scheduler
869929
description: |-

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,66 @@ 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+
Valid options for PriorityClassSource are:
870+
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
871+
- PodPriorityClass: Uses PriorityClassName from PodTemplate (PodSpec.PriorityClassName)
872+
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
873+
874+
PriorityClassName behavior:
875+
876+
For KubePriorityClass:
877+
- If specified: Uses the named Kubernetes PriorityClass
878+
- If empty: Uses cluster's global default PriorityClass
879+
- If neither exists: Sets priority=0 and preemptionPolicy=Never
880+
881+
For PodPriorityClass:
882+
- Uses PriorityClassName from PodTemplate
883+
- Falls back to global default if not found
884+
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
885+
886+
For FederatedPriorityClass:
887+
- Reserved for future use
888+
- Current behavior undefined
889+
properties:
890+
priorityClassName:
891+
description: |-
892+
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
893+
894+
PriorityClassName behavior:
895+
896+
For KubePriorityClass:
897+
- If specified: Uses the named Kubernetes PriorityClass
898+
- If empty: Uses cluster's global default PriorityClass
899+
- If neither exists: Sets priority=0 and preemptionPolicy=Never
900+
901+
For PodPriorityClass:
902+
- Uses PriorityClassName from PodTemplate
903+
- Falls back to global default if not found
904+
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
905+
906+
For FederatedPriorityClass:
907+
- Reserved for future use
908+
- Current behavior undefined
909+
type: string
910+
priorityClassSource:
911+
default: KubePriorityClass
912+
description: |-
913+
PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
914+
Available options:
915+
- KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
916+
- PodPriorityClass: Uses PriorityClassName from PodTemplate (PodSpec.PriorityClassName)
917+
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
918+
enum:
919+
- FederatedPriorityClass
920+
- KubePriorityClass
921+
- PodPriorityClass
922+
type: string
923+
type: object
864924
schedulerName:
865925
default: default-scheduler
866926
description: |-

pkg/apis/policy/v1alpha1/propagation_types.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,33 @@ 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+
// Valid options for PriorityClassSource are:
208+
// - KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
209+
// - PodPriorityClass: Uses PriorityClassName from PodTemplate (PodSpec.PriorityClassName)
210+
// - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
211+
//
212+
// PriorityClassName behavior:
213+
//
214+
// For KubePriorityClass:
215+
// - If specified: Uses the named Kubernetes PriorityClass
216+
// - If empty: Uses cluster's global default PriorityClass
217+
// - If neither exists: Sets priority=0 and preemptionPolicy=Never
218+
//
219+
// For PodPriorityClass:
220+
// - Uses PriorityClassName from PodTemplate
221+
// - Falls back to global default if not found
222+
// - If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
223+
//
224+
// For FederatedPriorityClass:
225+
// - Reserved for future use
226+
// - Current behavior undefined
227+
//
228+
// +optional
229+
SchedulePriority *SchedulePriority `json:"schedulePriority,omitempty"`
203230
}
204231

205232
// ResourceSelector the resources will be selected.
@@ -660,6 +687,59 @@ const (
660687
LazyActivation ActivationPreference = "Lazy"
661688
)
662689

690+
// SchedulePriority defines how Karmada should resolve the priority and preemption policy
691+
// for workload scheduling.
692+
type SchedulePriority struct {
693+
// PriorityClassSource specifies where Karmada should look for the PriorityClass definition.
694+
// Available options:
695+
// - KubePriorityClass (default): Uses Kubernetes PriorityClass (scheduling.k8s.io/v1)
696+
// - PodPriorityClass: Uses PriorityClassName from PodTemplate (PodSpec.PriorityClassName)
697+
// - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
698+
//
699+
// +kubebuilder:default="KubePriorityClass"
700+
// +kubebuilder:validation:Enum=FederatedPriorityClass;KubePriorityClass;PodPriorityClass
701+
// +optional
702+
PriorityClassSource PriorityClassSource `json:"priorityClassSource,omitempty"`
703+
704+
// PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
705+
//
706+
// PriorityClassName behavior:
707+
//
708+
// For KubePriorityClass:
709+
// - If specified: Uses the named Kubernetes PriorityClass
710+
// - If empty: Uses cluster's global default PriorityClass
711+
// - If neither exists: Sets priority=0 and preemptionPolicy=Never
712+
//
713+
// For PodPriorityClass:
714+
// - Uses PriorityClassName from PodTemplate
715+
// - Falls back to global default if not found
716+
// - If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
717+
//
718+
// For FederatedPriorityClass:
719+
// - Reserved for future use
720+
// - Current behavior undefined
721+
//
722+
// +optional
723+
PriorityClassName string `json:"priorityClassName,omitempty"`
724+
}
725+
726+
// PriorityClassSource defines the type for PriorityClassSource field.
727+
type PriorityClassSource string
728+
729+
const (
730+
// FederatedPriorityClass specifies to use Karmada FederatedPriorityClass for priority resolution.
731+
// This feature is planned for future releases and is currently not implemented.
732+
FederatedPriorityClass PriorityClassSource = "FederatedPriorityClass"
733+
734+
// KubePriorityClass specifies to use Kubernetes native PriorityClass (scheduling.k8s.io/v1)
735+
// for priority resolution. This is the default source.
736+
KubePriorityClass PriorityClassSource = "KubePriorityClass"
737+
738+
// PodPriorityClass specifies to use the PriorityClassName defined in the workload's
739+
// PodTemplate for priority resolution.
740+
PodPriorityClass PriorityClassSource = "PodPriorityClass"
741+
)
742+
663743
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
664744

665745
// 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.

pkg/generated/openapi/zz_generated.openapi.go

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)