Skip to content

Commit

Permalink
Add priorityClassName in PropagationPolicy & ClusterPropagationPolicy
Browse files Browse the repository at this point in the history
Signed-off-by: wei-chenglai <[email protected]>
  • Loading branch information
seanlaii committed Jan 19, 2025
1 parent 5bfdf61 commit 25e0f40
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 1 deletion.
18 changes: 18 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\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",
"$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"
Expand Down Expand Up @@ -19289,6 +19293,20 @@
}
}
},
"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",
"properties": {
"priorityClassName": {
"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",
"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) - 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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,66 @@ spec:
type: object
minItems: 1
type: array
schedulePriority:
description: |-
SchedulePriority defines how Karmada should resolve the priority and preemption policy
for workload scheduling.
Valid 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)
PriorityClassName behavior:
For 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
For PodPriorityClass:
- Uses PriorityClassName from PodTemplate
- Falls back to global default if not found
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
For FederatedPriorityClass:
- Reserved for future use
- Current behavior undefined
properties:
priorityClassName:
description: |-
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
PriorityClassName behavior:
For 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
For PodPriorityClass:
- Uses PriorityClassName from PodTemplate
- Falls back to global default if not found
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
For FederatedPriorityClass:
- Reserved for future use
- Current behavior undefined
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)
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
enum:
- FederatedPriorityClass
- KubePriorityClass
- PodPriorityClass
type: string
type: object
schedulerName:
default: default-scheduler
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,66 @@ spec:
type: object
minItems: 1
type: array
schedulePriority:
description: |-
SchedulePriority defines how Karmada should resolve the priority and preemption policy
for workload scheduling.
Valid 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)
PriorityClassName behavior:
For 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
For PodPriorityClass:
- Uses PriorityClassName from PodTemplate
- Falls back to global default if not found
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
For FederatedPriorityClass:
- Reserved for future use
- Current behavior undefined
properties:
priorityClassName:
description: |-
PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
PriorityClassName behavior:
For 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
For PodPriorityClass:
- Uses PriorityClassName from PodTemplate
- Falls back to global default if not found
- If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
For FederatedPriorityClass:
- Reserved for future use
- Current behavior undefined
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)
- FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
enum:
- FederatedPriorityClass
- KubePriorityClass
- PodPriorityClass
type: string
type: object
schedulerName:
default: default-scheduler
description: |-
Expand Down
80 changes: 80 additions & 0 deletions pkg/apis/policy/v1alpha1/propagation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,33 @@ type PropagationSpec struct {
//
// +optional
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`

// SchedulePriority defines how Karmada should resolve the priority and preemption policy
// for workload scheduling.
//
// Valid 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)
//
// PriorityClassName behavior:
//
// For 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
//
// For PodPriorityClass:
// - Uses PriorityClassName from PodTemplate
// - Falls back to global default if not found
// - If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
//
// For FederatedPriorityClass:
// - Reserved for future use
// - Current behavior undefined
//
// +optional
SchedulePriority *SchedulePriority `json:"schedulePriority,omitempty"`
}

// ResourceSelector the resources will be selected.
Expand Down Expand Up @@ -660,6 +687,59 @@ 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)
// - FederatedPriorityClass: Uses Karmada FederatedPriorityClass (not yet implemented)
//
// +kubebuilder:default="KubePriorityClass"
// +kubebuilder:validation:Enum=FederatedPriorityClass;KubePriorityClass;PodPriorityClass
// +optional
PriorityClassSource PriorityClassSource `json:"priorityClassSource,omitempty"`

// PriorityClassName specifies which PriorityClass to use. Its behavior depends on PriorityClassSource:
//
// PriorityClassName behavior:
//
// For 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
//
// For PodPriorityClass:
// - Uses PriorityClassName from PodTemplate
// - Falls back to global default if not found
// - If no valid PriorityClass found: Sets priority=0 and preemptionPolicy=Never
//
// For FederatedPriorityClass:
// - Reserved for future use
// - Current behavior undefined
//
// +optional
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.
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 35 additions & 1 deletion pkg/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25e0f40

Please sign in to comment.