add dispersal replica division preference

Signed-off-by: Garrybest <garrybest@foxmail.com>
This commit is contained in:
Garrybest 2021-10-20 20:31:39 +08:00
parent dfe22abff3
commit 079778ed87
6 changed files with 54 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,30 @@ 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). e.g.
// The scheduler has 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 {