Merge pull request #497 from qianjun1993/bug-fix

Update ReplicaScheduling type
This commit is contained in:
karmada-bot 2021-07-06 11:02:23 +08:00 committed by GitHub
commit ea47422461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 290 additions and 482 deletions

View File

@ -214,26 +214,29 @@ spec:
that have replicas in spec (e.g. deployments, statefulsets) that have replicas in spec (e.g. deployments, statefulsets)
to member clusters. to member clusters.
properties: properties:
apiVersion: replicaDivisionPreference:
description: 'APIVersion defines the versioned schema of this description: ReplicaDivisionPreference determines how the
representation of an object. Servers should convert recognized replicas is divided when ReplicaSchedulingType is "Divided".
schemas to the latest internal value, and may reject unrecognized Valid options are Aggregated and Weighted. "Aggregated"
values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' divides replicas into clusters as few as possible, while
respecting clusters' resource availabilities during the
division. "Weighted" divides replicas by weight according
to WeightPreference.
type: string type: string
kind: replicaSchedulingType:
description: 'Kind is a string value representing the REST description: ReplicaSchedulingType determines how the replicas
resource this object represents. Servers may infer this is scheduled when karmada propagating a resource. Valid
from the endpoint the client submits requests to. Cannot options are Duplicated and Divided. "Duplicated" duplicates
be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' the same replicas to each candidate member cluster from
resource. "Divided" divides replicas into parts according
to number of valid candidate member clusters, and exact
replicas for each cluster are determined by ReplicaDivisionPreference.
type: string type: string
metadata: weightPreference:
type: object description: WeightPreference describes weight for each cluster
spec: or for each group of cluster If ReplicaDivisionPreference
description: Spec represents the desired behavior of ReplicaSchedulingPolicy. is set to "Weighted", and WeightPreference is not set, scheduler
properties: will weight all clusters the same.
preferences:
description: Preferences describes weight for each cluster
or for each group of cluster.
properties: properties:
staticWeightList: staticWeightList:
description: StaticWeightList defines the static cluster description: StaticWeightList defines the static cluster
@ -247,26 +250,25 @@ spec:
to select clusters. to select clusters.
properties: properties:
clusterNames: clusterNames:
description: ClusterNames is the list of description: ClusterNames is the list of clusters
clusters to be selected. to be selected.
items: items:
type: string type: string
type: array type: array
exclude: exclude:
description: ExcludedClusters is the list description: ExcludedClusters is the list of
of clusters to be ignored. clusters to be ignored.
items: items:
type: string type: string
type: array type: array
fieldSelector: fieldSelector:
description: FieldSelector is a filter to description: FieldSelector is a filter to select
select member clusters by fields. If non-nil member clusters by fields. If non-nil and
and non-empty, only the clusters match non-empty, only the clusters match this filter
this filter will be selected. will be selected.
properties: properties:
matchExpressions: matchExpressions:
description: A list of field selector description: A list of field selector requirements.
requirements.
items: items:
description: A node selector requirement description: A node selector requirement
is a selector that contains values, is a selector that contains values,
@ -274,29 +276,26 @@ spec:
the key and values. the key and values.
properties: properties:
key: key:
description: The label key that description: The label key that the
the selector applies to. selector applies to.
type: string type: string
operator: operator:
description: Represents a key's description: Represents a key's relationship
relationship to a set of values. to a set of values. Valid operators
Valid operators are In, NotIn, are In, NotIn, Exists, DoesNotExist.
Exists, DoesNotExist. Gt, and Gt, and Lt.
Lt.
type: string type: string
values: values:
description: An array of string description: An array of string values.
values. If the operator is In If the operator is In or NotIn,
or NotIn, the values array must the values array must be non-empty.
be non-empty. If the operator If the operator is Exists or DoesNotExist,
is Exists or DoesNotExist, the the values array must be empty.
values array must be empty. If the operator is Gt or Lt, the
If the operator is Gt or Lt, values array must have a single
the values array must have a element, which will be interpreted
single element, which will be as an integer. This array is replaced
interpreted as an integer. This during a strategic merge patch.
array is replaced during a strategic
merge patch.
items: items:
type: string type: string
type: array type: array
@ -307,15 +306,15 @@ spec:
type: array type: array
type: object type: object
labelSelector: labelSelector:
description: LabelSelector is a filter to description: LabelSelector is a filter to select
select member clusters by labels. If non-nil member clusters by labels. If non-nil and
and non-empty, only the clusters match non-empty, only the clusters match this filter
this filter will be selected. will be selected.
properties: properties:
matchExpressions: matchExpressions:
description: matchExpressions is a list description: matchExpressions is a list
of label selector requirements. The of label selector requirements. The requirements
requirements are ANDed. are ANDed.
items: items:
description: A label selector requirement description: A label selector requirement
is a selector that contains values, is a selector that contains values,
@ -323,106 +322,24 @@ spec:
the key and values. the key and values.
properties: properties:
key: key:
description: key is the label description: key is the label key
key that the selector applies that the selector applies to.
to.
type: string type: string
operator: operator:
description: operator represents description: operator represents a
a key's relationship to a set key's relationship to a set of values.
of values. Valid operators are Valid operators are In, NotIn, Exists
In, NotIn, Exists and DoesNotExist. and DoesNotExist.
type: string type: string
values: values:
description: values is an array description: values is an array of
of string values. If the operator string values. If the operator is
is In or NotIn, the values array In or NotIn, the values array must
must be non-empty. If the operator be non-empty. If the operator is
is Exists or DoesNotExist, the Exists or DoesNotExist, the values
values array must be empty. array must be empty. This array
This array is replaced during is replaced during a strategic merge
a strategic merge patch. patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of
{key,value} pairs. A single {key,value}
in the matchLabels map is equivalent
to an element of matchExpressions,
whose key field is "key", the operator
is "In", and the values array contains
only "value". The requirements are
ANDed.
type: object
type: object
type: object
weight:
description: Weight expressing the preference
to the cluster(s) specified by 'TargetCluster'.
format: int64
type: integer
required:
- targetCluster
- weight
type: object
type: array
required:
- staticWeightList
type: object
resourceSelectors:
description: ResourceSelectors used to select resources.
items:
description: ResourceSelector the resources will be
selected.
properties:
apiVersion:
description: APIVersion represents the API version
of the target resources.
type: string
kind:
description: Kind represents the Kind of the target
resources.
type: string
labelSelector:
description: A label query over a set of resources.
If name is not empty, labelSelector will be ignored.
properties:
matchExpressions:
description: matchExpressions is a list of label
selector requirements. The requirements are
ANDed.
items:
description: A label selector requirement
is a selector that contains values, a key,
and an operator that relates the key and
values.
properties:
key:
description: key is the label key that
the selector applies to.
type: string
operator:
description: operator represents a key's
relationship to a set of values. Valid
operators are In, NotIn, Exists and
DoesNotExist.
type: string
values:
description: values is an array of string
values. If the operator is In or NotIn,
the values array must be non-empty.
If the operator is Exists or DoesNotExist,
the values array must be empty. This
array is replaced during a strategic
merge patch.
items: items:
type: string type: string
type: array type: array
@ -437,38 +354,25 @@ spec:
description: matchLabels is a map of {key,value} description: matchLabels is a map of {key,value}
pairs. A single {key,value} in the matchLabels pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, map is equivalent to an element of matchExpressions,
whose key field is "key", the operator is whose key field is "key", the operator
"In", and the values array contains only "value". is "In", and the values array contains
The requirements are ANDed. only "value". The requirements are ANDed.
type: object type: object
type: object type: object
name:
description: Name of the target resource. Default
is empty, which means selecting all resources.
type: string
namespace:
description: Namespace of the target resource. Default
is empty, which means inherit from the parent
object scope.
type: string
required:
- apiVersion
- kind
type: object type: object
type: array weight:
totalReplicas: description: Weight expressing the preference to
description: TotalReplicas represents the total number the cluster(s) specified by 'TargetCluster'.
of replicas across member clusters. The replicas(spec.replicas) format: int64
specified for deployment template will be discarded.
format: int32
type: integer type: integer
required: required:
- preferences - targetCluster
- resourceSelectors - weight
- totalReplicas
type: object type: object
type: array
required: required:
- spec - staticWeightList
type: object
type: object type: object
spreadConstraints: spreadConstraints:
description: SpreadConstraints represents a list of the scheduling description: SpreadConstraints represents a list of the scheduling

View File

@ -210,26 +210,29 @@ spec:
that have replicas in spec (e.g. deployments, statefulsets) that have replicas in spec (e.g. deployments, statefulsets)
to member clusters. to member clusters.
properties: properties:
apiVersion: replicaDivisionPreference:
description: 'APIVersion defines the versioned schema of this description: ReplicaDivisionPreference determines how the
representation of an object. Servers should convert recognized replicas is divided when ReplicaSchedulingType is "Divided".
schemas to the latest internal value, and may reject unrecognized Valid options are Aggregated and Weighted. "Aggregated"
values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' divides replicas into clusters as few as possible, while
respecting clusters' resource availabilities during the
division. "Weighted" divides replicas by weight according
to WeightPreference.
type: string type: string
kind: replicaSchedulingType:
description: 'Kind is a string value representing the REST description: ReplicaSchedulingType determines how the replicas
resource this object represents. Servers may infer this is scheduled when karmada propagating a resource. Valid
from the endpoint the client submits requests to. Cannot options are Duplicated and Divided. "Duplicated" duplicates
be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' the same replicas to each candidate member cluster from
resource. "Divided" divides replicas into parts according
to number of valid candidate member clusters, and exact
replicas for each cluster are determined by ReplicaDivisionPreference.
type: string type: string
metadata: weightPreference:
type: object description: WeightPreference describes weight for each cluster
spec: or for each group of cluster If ReplicaDivisionPreference
description: Spec represents the desired behavior of ReplicaSchedulingPolicy. is set to "Weighted", and WeightPreference is not set, scheduler
properties: will weight all clusters the same.
preferences:
description: Preferences describes weight for each cluster
or for each group of cluster.
properties: properties:
staticWeightList: staticWeightList:
description: StaticWeightList defines the static cluster description: StaticWeightList defines the static cluster
@ -243,26 +246,25 @@ spec:
to select clusters. to select clusters.
properties: properties:
clusterNames: clusterNames:
description: ClusterNames is the list of description: ClusterNames is the list of clusters
clusters to be selected. to be selected.
items: items:
type: string type: string
type: array type: array
exclude: exclude:
description: ExcludedClusters is the list description: ExcludedClusters is the list of
of clusters to be ignored. clusters to be ignored.
items: items:
type: string type: string
type: array type: array
fieldSelector: fieldSelector:
description: FieldSelector is a filter to description: FieldSelector is a filter to select
select member clusters by fields. If non-nil member clusters by fields. If non-nil and
and non-empty, only the clusters match non-empty, only the clusters match this filter
this filter will be selected. will be selected.
properties: properties:
matchExpressions: matchExpressions:
description: A list of field selector description: A list of field selector requirements.
requirements.
items: items:
description: A node selector requirement description: A node selector requirement
is a selector that contains values, is a selector that contains values,
@ -270,29 +272,26 @@ spec:
the key and values. the key and values.
properties: properties:
key: key:
description: The label key that description: The label key that the
the selector applies to. selector applies to.
type: string type: string
operator: operator:
description: Represents a key's description: Represents a key's relationship
relationship to a set of values. to a set of values. Valid operators
Valid operators are In, NotIn, are In, NotIn, Exists, DoesNotExist.
Exists, DoesNotExist. Gt, and Gt, and Lt.
Lt.
type: string type: string
values: values:
description: An array of string description: An array of string values.
values. If the operator is In If the operator is In or NotIn,
or NotIn, the values array must the values array must be non-empty.
be non-empty. If the operator If the operator is Exists or DoesNotExist,
is Exists or DoesNotExist, the the values array must be empty.
values array must be empty. If the operator is Gt or Lt, the
If the operator is Gt or Lt, values array must have a single
the values array must have a element, which will be interpreted
single element, which will be as an integer. This array is replaced
interpreted as an integer. This during a strategic merge patch.
array is replaced during a strategic
merge patch.
items: items:
type: string type: string
type: array type: array
@ -303,15 +302,15 @@ spec:
type: array type: array
type: object type: object
labelSelector: labelSelector:
description: LabelSelector is a filter to description: LabelSelector is a filter to select
select member clusters by labels. If non-nil member clusters by labels. If non-nil and
and non-empty, only the clusters match non-empty, only the clusters match this filter
this filter will be selected. will be selected.
properties: properties:
matchExpressions: matchExpressions:
description: matchExpressions is a list description: matchExpressions is a list
of label selector requirements. The of label selector requirements. The requirements
requirements are ANDed. are ANDed.
items: items:
description: A label selector requirement description: A label selector requirement
is a selector that contains values, is a selector that contains values,
@ -319,106 +318,24 @@ spec:
the key and values. the key and values.
properties: properties:
key: key:
description: key is the label description: key is the label key
key that the selector applies that the selector applies to.
to.
type: string type: string
operator: operator:
description: operator represents description: operator represents a
a key's relationship to a set key's relationship to a set of values.
of values. Valid operators are Valid operators are In, NotIn, Exists
In, NotIn, Exists and DoesNotExist. and DoesNotExist.
type: string type: string
values: values:
description: values is an array description: values is an array of
of string values. If the operator string values. If the operator is
is In or NotIn, the values array In or NotIn, the values array must
must be non-empty. If the operator be non-empty. If the operator is
is Exists or DoesNotExist, the Exists or DoesNotExist, the values
values array must be empty. array must be empty. This array
This array is replaced during is replaced during a strategic merge
a strategic merge patch. patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of
{key,value} pairs. A single {key,value}
in the matchLabels map is equivalent
to an element of matchExpressions,
whose key field is "key", the operator
is "In", and the values array contains
only "value". The requirements are
ANDed.
type: object
type: object
type: object
weight:
description: Weight expressing the preference
to the cluster(s) specified by 'TargetCluster'.
format: int64
type: integer
required:
- targetCluster
- weight
type: object
type: array
required:
- staticWeightList
type: object
resourceSelectors:
description: ResourceSelectors used to select resources.
items:
description: ResourceSelector the resources will be
selected.
properties:
apiVersion:
description: APIVersion represents the API version
of the target resources.
type: string
kind:
description: Kind represents the Kind of the target
resources.
type: string
labelSelector:
description: A label query over a set of resources.
If name is not empty, labelSelector will be ignored.
properties:
matchExpressions:
description: matchExpressions is a list of label
selector requirements. The requirements are
ANDed.
items:
description: A label selector requirement
is a selector that contains values, a key,
and an operator that relates the key and
values.
properties:
key:
description: key is the label key that
the selector applies to.
type: string
operator:
description: operator represents a key's
relationship to a set of values. Valid
operators are In, NotIn, Exists and
DoesNotExist.
type: string
values:
description: values is an array of string
values. If the operator is In or NotIn,
the values array must be non-empty.
If the operator is Exists or DoesNotExist,
the values array must be empty. This
array is replaced during a strategic
merge patch.
items: items:
type: string type: string
type: array type: array
@ -433,38 +350,25 @@ spec:
description: matchLabels is a map of {key,value} description: matchLabels is a map of {key,value}
pairs. A single {key,value} in the matchLabels pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, map is equivalent to an element of matchExpressions,
whose key field is "key", the operator is whose key field is "key", the operator
"In", and the values array contains only "value". is "In", and the values array contains
The requirements are ANDed. only "value". The requirements are ANDed.
type: object type: object
type: object type: object
name:
description: Name of the target resource. Default
is empty, which means selecting all resources.
type: string
namespace:
description: Namespace of the target resource. Default
is empty, which means inherit from the parent
object scope.
type: string
required:
- apiVersion
- kind
type: object type: object
type: array weight:
totalReplicas: description: Weight expressing the preference to
description: TotalReplicas represents the total number the cluster(s) specified by 'TargetCluster'.
of replicas across member clusters. The replicas(spec.replicas) format: int64
specified for deployment template will be discarded.
format: int32
type: integer type: integer
required: required:
- preferences - targetCluster
- resourceSelectors - weight
- totalReplicas
type: object type: object
type: array
required: required:
- spec - staticWeightList
type: object
type: object type: object
spreadConstraints: spreadConstraints:
description: SpreadConstraints represents a list of the scheduling description: SpreadConstraints represents a list of the scheduling

View File

@ -104,7 +104,7 @@ type Placement struct {
// ReplicaScheduling represents the scheduling policy on dealing with the number of replicas // ReplicaScheduling represents the scheduling policy on dealing with the number of replicas
// when propagating resources that have replicas in spec (e.g. deployments, statefulsets) to member clusters. // when propagating resources that have replicas in spec (e.g. deployments, statefulsets) to member clusters.
// +optional // +optional
ReplicaScheduling *ReplicaSchedulingPolicy `json:"replicaScheduling,omitempty"` ReplicaScheduling *ReplicaSchedulingStrategy `json:"replicaScheduling,omitempty"`
} }
// SpreadFieldValue is the type to define valid values for SpreadConstraint.SpreadByField // SpreadFieldValue is the type to define valid values for SpreadConstraint.SpreadByField

View File

@ -390,7 +390,7 @@ func (in *Placement) DeepCopyInto(out *Placement) {
} }
if in.ReplicaScheduling != nil { if in.ReplicaScheduling != nil {
in, out := &in.ReplicaScheduling, &out.ReplicaScheduling in, out := &in.ReplicaScheduling, &out.ReplicaScheduling
*out = new(ReplicaSchedulingPolicy) *out = new(ReplicaSchedulingStrategy)
(*in).DeepCopyInto(*out) (*in).DeepCopyInto(*out)
} }
return return