Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dynamic weight by available replicas #841

Merged
merged 2 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ spec:
is set to "Weighted", and WeightPreference is not set, scheduler
will weight all clusters the same.
properties:
dynamicWeight:
description: DynamicWeight specifies the factor to generates
dynamic weight list. If specified, StaticWeightList
will be ignored.
enum:
- AvailableReplicas
type: string
staticWeightList:
description: StaticWeightList defines the static cluster
weight.
Expand Down
7 changes: 7 additions & 0 deletions charts/_crds/bases/policy.karmada.io_propagationpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ spec:
is set to "Weighted", and WeightPreference is not set, scheduler
will weight all clusters the same.
properties:
dynamicWeight:
description: DynamicWeight specifies the factor to generates
dynamic weight list. If specified, StaticWeightList
will be ignored.
enum:
- AvailableReplicas
type: string
staticWeightList:
description: StaticWeightList defines the static cluster
weight.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ spec:
description: Preferences describes weight for each cluster or for
each group of cluster.
properties:
dynamicWeight:
description: DynamicWeight specifies the factor to generates dynamic
weight list. If specified, StaticWeightList will be ignored.
enum:
- AvailableReplicas
type: string
staticWeightList:
description: StaticWeightList defines the static cluster weight.
items:
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/policy/v1alpha1/propagation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ type ClusterAffinity struct {
ExcludeClusters []string `json:"exclude,omitempty"`
}

// ReplicaSchedulingType describes scheduling methods for the "replicas" in a resouce.
// ReplicaSchedulingType describes scheduling methods for the "replicas" in a resource.
RainbowMango marked this conversation as resolved.
Show resolved Hide resolved
type ReplicaSchedulingType string

const (
Expand Down
24 changes: 24 additions & 0 deletions pkg/apis/policy/v1alpha1/replicascheduling_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ type ClusterPreferences struct {
// StaticWeightList defines the static cluster weight.
// +required
StaticWeightList []StaticClusterWeight `json:"staticWeightList"`
// DynamicWeight specifies the factor to generates dynamic weight list.
// If specified, StaticWeightList will be ignored.
// +kubebuilder:validation:Enum=AvailableReplicas
// +optional
DynamicWeight DynamicWeightFactor `json:"dynamicWeight,omitempty"`
}

// StaticClusterWeight defines the static cluster weight.
Expand All @@ -51,6 +56,25 @@ type StaticClusterWeight struct {
Weight int64 `json:"weight"`
}

// DynamicWeightFactor represents the weight factor.
// For now only support 'AvailableReplicas', more factors could be extended if there is a need.
type DynamicWeightFactor string

const (
// DynamicWeightByAvailableReplicas represents the cluster weight list should be generated according to
// available resource (available replicas).
// Example:
// The scheduler selected 3 clusters (A/B/C) and should divide 12 replicas to them.
// Workload:
// Desired replica: 12
// Cluster:
// A: Max available replica: 6
// B: Max available replica: 12
// C: Max available replica: 18
// The weight of cluster A:B:C will be 6:12:18 (equals to 1:2:3). At last, the assignment would be 'A: 2, B: 4, C: 6'.
DynamicWeightByAvailableReplicas DynamicWeightFactor = "AvailableReplicas"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ReplicaSchedulingPolicyList contains a list of ReplicaSchedulingPolicy.
Expand Down

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