Merge pull request #841 from Garrybest/pr_dispersal

add dispersal replica division preference
This commit is contained in:
karmada-bot 2021-10-29 13:16:09 +08:00 committed by GitHub
commit 085fdd23c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 2 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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:

View File

@ -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.
type ReplicaSchedulingType string
const (

View File

@ -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.
@ -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.

View File

@ -64,7 +64,10 @@ func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
var _ clientset.Interface = &Clientset{}
var (
_ clientset.Interface = &Clientset{}
_ testing.FakeClient = &Clientset{}
)
// ClusterV1alpha1 retrieves the ClusterV1alpha1Client
func (c *Clientset) ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface {