From 6aa3ffd6cf1c6a2c6beb71bdb74e41ff8a834b9c Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Fri, 17 Feb 2023 16:37:28 +0800 Subject: [PATCH] Simply OrderedClusterAffinities API names Signed-off-by: RainbowMango --- api/openapi-spec/swagger.json | 89 +++++------ ...karmada.io_clusterpropagationpolicies.yaml | 41 +++-- ...policy.karmada.io_propagationpolicies.yaml | 41 +++-- ...rk.karmada.io_clusterresourcebindings.yaml | 41 +++-- .../work.karmada.io_resourcebindings.yaml | 41 +++-- pkg/apis/policy/v1alpha1/propagation_types.go | 35 ++-- .../policy/v1alpha1/zz_generated.deepcopy.go | 40 ++--- pkg/generated/openapi/zz_generated.openapi.go | 150 +++++++++--------- 8 files changed, 222 insertions(+), 256 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 2cbc0eff3..8495bd09a 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -15061,6 +15061,44 @@ } } }, + "com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ClusterAffinityTerm": { + "description": "ClusterAffinityTerm selects a set of cluster.", + "type": "object", + "required": [ + "affinityName" + ], + "properties": { + "affinityName": { + "description": "AffinityName is the name of the cluster group.", + "type": "string", + "default": "" + }, + "clusterNames": { + "description": "ClusterNames is the list of clusters to be selected.", + "type": "array", + "items": { + "type": "string", + "default": "" + } + }, + "exclude": { + "description": "ExcludedClusters is the list of clusters to be ignored.", + "type": "array", + "items": { + "type": "string", + "default": "" + } + }, + "fieldSelector": { + "description": "FieldSelector is a filter to select member clusters by fields. If non-nil and non-empty, only the clusters match this filter will be selected.", + "$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.FieldSelector" + }, + "labelSelector": { + "description": "LabelSelector is a filter to select member clusters by labels. If non-nil and non-empty, only the clusters match this filter will be selected.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + } + } + }, "com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ClusterOverridePolicy": { "description": "ClusterOverridePolicy represents the cluster-wide policy that overrides a group of resources to one or more clusters.", "type": "object", @@ -15480,51 +15518,6 @@ } } }, - "com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.OrderedClusterAffinityTerm": { - "description": "OrderedClusterAffinityTerm selects a set of cluster and indicates the order that Karmada scheduler should inspect with.", - "type": "object", - "required": [ - "affinityName", - "order" - ], - "properties": { - "affinityName": { - "description": "AffinityName is the name of the cluster group.", - "type": "string", - "default": "" - }, - "clusterNames": { - "description": "ClusterNames is the list of clusters to be selected.", - "type": "array", - "items": { - "type": "string", - "default": "" - } - }, - "exclude": { - "description": "ExcludedClusters is the list of clusters to be ignored.", - "type": "array", - "items": { - "type": "string", - "default": "" - } - }, - "fieldSelector": { - "description": "FieldSelector is a filter to select member clusters by fields. If non-nil and non-empty, only the clusters match this filter will be selected.", - "$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.FieldSelector" - }, - "labelSelector": { - "description": "LabelSelector is a filter to select member clusters by labels. If non-nil and non-empty, only the clusters match this filter will be selected.", - "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" - }, - "order": { - "description": "Order of the cluster group that Karmada scheduler should inspect with, in the range 1-100.", - "type": "integer", - "format": "int32", - "default": 0 - } - } - }, "com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.OverridePolicy": { "description": "OverridePolicy represents the policy that overrides a group of resources to one or more clusters.", "type": "object", @@ -15684,7 +15677,7 @@ "type": "object", "properties": { "clusterAffinity": { - "description": "ClusterAffinity represents scheduling restrictions to a certain set of clusters. If not set, any cluster can be scheduling candidate.", + "description": "ClusterAffinity represents scheduling restrictions to a certain set of clusters. Note:\n 1. ClusterAffinity can not co-exist with ClusterAffinities.\n 2. If both ClusterAffinity and ClusterAffinities are not set, any cluster\n can be scheduling candidates.", "$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ClusterAffinity" }, "clusterTolerations": { @@ -15696,11 +15689,11 @@ } }, "orderedClusterAffinities": { - "description": "OrderedClusterAffinities represents the scheduling order among multiple set of clusters that indicated by OrderedClusterAffinityTerm. Each term should have a unique order among all terms.\n\nThe scheduler will evaluate these groups one by one in strict order, the group that does not satisfy scheduling restrictions will be ignored that means all clusters in this group will not be selected unless it also belongs to the next group(a cluster could belong to multiple groups).\n\nIf none of the groups satisfy the scheduling restrictions, then scheduling fails, which means no cluster will be selected.\n\nNote: OrderedClusterAffinities can not co-exist with ClusterAffinity.\n\nPotential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler would prefer to schedule workloads to the main group and the second group will only be considered in case of the main group does not satisfy restrictions(like, lack of resources).\n\nPotential use case 2: For the disaster recovery scenario, the clusters could be organized to primary and backup groups, the workloads would be scheduled to primary clusters firstly, and when primary cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters.", + "description": "ClusterAffinities represents scheduling restrictions to multiple cluster groups that indicated by ClusterAffinityTerm.\n\nThe scheduler will evaluate these groups one by one in the order they appear in the spec, the group that does not satisfy scheduling restrictions will be ignored which means all clusters in this group will not be selected unless it also belongs to the next group(a cluster could belong to multiple groups).\n\nIf none of the groups satisfy the scheduling restrictions, then scheduling fails, which means no cluster will be selected.\n\nNote:\n 1. ClusterAffinities can not co-exist with ClusterAffinity.\n 2. If both ClusterAffinity and ClusterAffinities are not set, any cluster\n can be scheduling candidates.\n\nPotential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler would prefer to schedule workloads to the main group and the second group will only be considered in case of the main group does not satisfy restrictions(like, lack of resources).\n\nPotential use case 2: For the disaster recovery scenario, the clusters could be organized to primary and backup groups, the workloads would be scheduled to primary clusters firstly, and when primary cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters.", "type": "array", "items": { "default": {}, - "$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.OrderedClusterAffinityTerm" + "$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ClusterAffinityTerm" } }, "replicaScheduling": { diff --git a/charts/karmada/_crds/bases/policy.karmada.io_clusterpropagationpolicies.yaml b/charts/karmada/_crds/bases/policy.karmada.io_clusterpropagationpolicies.yaml index 9c731de2a..0e6c4ba30 100644 --- a/charts/karmada/_crds/bases/policy.karmada.io_clusterpropagationpolicies.yaml +++ b/charts/karmada/_crds/bases/policy.karmada.io_clusterpropagationpolicies.yaml @@ -66,9 +66,11 @@ spec: propagate resources. properties: clusterAffinity: - description: ClusterAffinity represents scheduling restrictions - to a certain set of clusters. If not set, any cluster can be - scheduling candidate. + description: 'ClusterAffinity represents scheduling restrictions + to a certain set of clusters. Note: 1. ClusterAffinity can not + co-exist with ClusterAffinities. 2. If both ClusterAffinity + and ClusterAffinities are not set, any cluster can be scheduling + candidates.' properties: clusterNames: description: ClusterNames is the list of clusters to be selected. @@ -210,17 +212,18 @@ spec: type: object type: array orderedClusterAffinities: - description: "OrderedClusterAffinities represents the scheduling - order among multiple set of clusters that indicated by OrderedClusterAffinityTerm. - Each term should have a unique order among all terms. \n The - scheduler will evaluate these groups one by one in strict order, - the group that does not satisfy scheduling restrictions will - be ignored that means all clusters in this group will not be - selected unless it also belongs to the next group(a cluster - could belong to multiple groups). \n If none of the groups satisfy - the scheduling restrictions, then scheduling fails, which means - no cluster will be selected. \n Note: OrderedClusterAffinities - can not co-exist with ClusterAffinity. \n Potential use case + description: "ClusterAffinities represents scheduling restrictions + to multiple cluster groups that indicated by ClusterAffinityTerm. + \n The scheduler will evaluate these groups one by one in the + order they appear in the spec, the group that does not satisfy + scheduling restrictions will be ignored which means all clusters + in this group will not be selected unless it also belongs to + the next group(a cluster could belong to multiple groups). \n + If none of the groups satisfy the scheduling restrictions, then + scheduling fails, which means no cluster will be selected. \n + Note: 1. ClusterAffinities can not co-exist with ClusterAffinity. + 2. If both ClusterAffinity and ClusterAffinities are not set, + any cluster can be scheduling candidates. \n Potential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler @@ -233,9 +236,7 @@ spec: cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters." items: - description: OrderedClusterAffinityTerm selects a set of cluster - and indicates the order that Karmada scheduler should inspect - with. + description: ClusterAffinityTerm selects a set of cluster. properties: affinityName: description: AffinityName is the name of the cluster group. @@ -338,14 +339,8 @@ spec: contains only "value". The requirements are ANDed. type: object type: object - order: - description: Order of the cluster group that Karmada scheduler - should inspect with, in the range 1-100. - format: int32 - type: integer required: - affinityName - - order type: object type: array replicaScheduling: diff --git a/charts/karmada/_crds/bases/policy.karmada.io_propagationpolicies.yaml b/charts/karmada/_crds/bases/policy.karmada.io_propagationpolicies.yaml index ef3a764f0..cd6b22efe 100644 --- a/charts/karmada/_crds/bases/policy.karmada.io_propagationpolicies.yaml +++ b/charts/karmada/_crds/bases/policy.karmada.io_propagationpolicies.yaml @@ -62,9 +62,11 @@ spec: propagate resources. properties: clusterAffinity: - description: ClusterAffinity represents scheduling restrictions - to a certain set of clusters. If not set, any cluster can be - scheduling candidate. + description: 'ClusterAffinity represents scheduling restrictions + to a certain set of clusters. Note: 1. ClusterAffinity can not + co-exist with ClusterAffinities. 2. If both ClusterAffinity + and ClusterAffinities are not set, any cluster can be scheduling + candidates.' properties: clusterNames: description: ClusterNames is the list of clusters to be selected. @@ -206,17 +208,18 @@ spec: type: object type: array orderedClusterAffinities: - description: "OrderedClusterAffinities represents the scheduling - order among multiple set of clusters that indicated by OrderedClusterAffinityTerm. - Each term should have a unique order among all terms. \n The - scheduler will evaluate these groups one by one in strict order, - the group that does not satisfy scheduling restrictions will - be ignored that means all clusters in this group will not be - selected unless it also belongs to the next group(a cluster - could belong to multiple groups). \n If none of the groups satisfy - the scheduling restrictions, then scheduling fails, which means - no cluster will be selected. \n Note: OrderedClusterAffinities - can not co-exist with ClusterAffinity. \n Potential use case + description: "ClusterAffinities represents scheduling restrictions + to multiple cluster groups that indicated by ClusterAffinityTerm. + \n The scheduler will evaluate these groups one by one in the + order they appear in the spec, the group that does not satisfy + scheduling restrictions will be ignored which means all clusters + in this group will not be selected unless it also belongs to + the next group(a cluster could belong to multiple groups). \n + If none of the groups satisfy the scheduling restrictions, then + scheduling fails, which means no cluster will be selected. \n + Note: 1. ClusterAffinities can not co-exist with ClusterAffinity. + 2. If both ClusterAffinity and ClusterAffinities are not set, + any cluster can be scheduling candidates. \n Potential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler @@ -229,9 +232,7 @@ spec: cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters." items: - description: OrderedClusterAffinityTerm selects a set of cluster - and indicates the order that Karmada scheduler should inspect - with. + description: ClusterAffinityTerm selects a set of cluster. properties: affinityName: description: AffinityName is the name of the cluster group. @@ -334,14 +335,8 @@ spec: contains only "value". The requirements are ANDed. type: object type: object - order: - description: Order of the cluster group that Karmada scheduler - should inspect with, in the range 1-100. - format: int32 - type: integer required: - affinityName - - order type: object type: array replicaScheduling: diff --git a/charts/karmada/_crds/bases/work.karmada.io_clusterresourcebindings.yaml b/charts/karmada/_crds/bases/work.karmada.io_clusterresourcebindings.yaml index e5cb5cbe2..f932b049c 100644 --- a/charts/karmada/_crds/bases/work.karmada.io_clusterresourcebindings.yaml +++ b/charts/karmada/_crds/bases/work.karmada.io_clusterresourcebindings.yaml @@ -329,9 +329,11 @@ spec: propagate resources. properties: clusterAffinity: - description: ClusterAffinity represents scheduling restrictions - to a certain set of clusters. If not set, any cluster can be - scheduling candidate. + description: 'ClusterAffinity represents scheduling restrictions + to a certain set of clusters. Note: 1. ClusterAffinity can not + co-exist with ClusterAffinities. 2. If both ClusterAffinity + and ClusterAffinities are not set, any cluster can be scheduling + candidates.' properties: clusterNames: description: ClusterNames is the list of clusters to be selected. @@ -473,17 +475,18 @@ spec: type: object type: array orderedClusterAffinities: - description: "OrderedClusterAffinities represents the scheduling - order among multiple set of clusters that indicated by OrderedClusterAffinityTerm. - Each term should have a unique order among all terms. \n The - scheduler will evaluate these groups one by one in strict order, - the group that does not satisfy scheduling restrictions will - be ignored that means all clusters in this group will not be - selected unless it also belongs to the next group(a cluster - could belong to multiple groups). \n If none of the groups satisfy - the scheduling restrictions, then scheduling fails, which means - no cluster will be selected. \n Note: OrderedClusterAffinities - can not co-exist with ClusterAffinity. \n Potential use case + description: "ClusterAffinities represents scheduling restrictions + to multiple cluster groups that indicated by ClusterAffinityTerm. + \n The scheduler will evaluate these groups one by one in the + order they appear in the spec, the group that does not satisfy + scheduling restrictions will be ignored which means all clusters + in this group will not be selected unless it also belongs to + the next group(a cluster could belong to multiple groups). \n + If none of the groups satisfy the scheduling restrictions, then + scheduling fails, which means no cluster will be selected. \n + Note: 1. ClusterAffinities can not co-exist with ClusterAffinity. + 2. If both ClusterAffinity and ClusterAffinities are not set, + any cluster can be scheduling candidates. \n Potential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler @@ -496,9 +499,7 @@ spec: cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters." items: - description: OrderedClusterAffinityTerm selects a set of cluster - and indicates the order that Karmada scheduler should inspect - with. + description: ClusterAffinityTerm selects a set of cluster. properties: affinityName: description: AffinityName is the name of the cluster group. @@ -601,14 +602,8 @@ spec: contains only "value". The requirements are ANDed. type: object type: object - order: - description: Order of the cluster group that Karmada scheduler - should inspect with, in the range 1-100. - format: int32 - type: integer required: - affinityName - - order type: object type: array replicaScheduling: diff --git a/charts/karmada/_crds/bases/work.karmada.io_resourcebindings.yaml b/charts/karmada/_crds/bases/work.karmada.io_resourcebindings.yaml index 4e2574acf..74eab935f 100644 --- a/charts/karmada/_crds/bases/work.karmada.io_resourcebindings.yaml +++ b/charts/karmada/_crds/bases/work.karmada.io_resourcebindings.yaml @@ -329,9 +329,11 @@ spec: propagate resources. properties: clusterAffinity: - description: ClusterAffinity represents scheduling restrictions - to a certain set of clusters. If not set, any cluster can be - scheduling candidate. + description: 'ClusterAffinity represents scheduling restrictions + to a certain set of clusters. Note: 1. ClusterAffinity can not + co-exist with ClusterAffinities. 2. If both ClusterAffinity + and ClusterAffinities are not set, any cluster can be scheduling + candidates.' properties: clusterNames: description: ClusterNames is the list of clusters to be selected. @@ -473,17 +475,18 @@ spec: type: object type: array orderedClusterAffinities: - description: "OrderedClusterAffinities represents the scheduling - order among multiple set of clusters that indicated by OrderedClusterAffinityTerm. - Each term should have a unique order among all terms. \n The - scheduler will evaluate these groups one by one in strict order, - the group that does not satisfy scheduling restrictions will - be ignored that means all clusters in this group will not be - selected unless it also belongs to the next group(a cluster - could belong to multiple groups). \n If none of the groups satisfy - the scheduling restrictions, then scheduling fails, which means - no cluster will be selected. \n Note: OrderedClusterAffinities - can not co-exist with ClusterAffinity. \n Potential use case + description: "ClusterAffinities represents scheduling restrictions + to multiple cluster groups that indicated by ClusterAffinityTerm. + \n The scheduler will evaluate these groups one by one in the + order they appear in the spec, the group that does not satisfy + scheduling restrictions will be ignored which means all clusters + in this group will not be selected unless it also belongs to + the next group(a cluster could belong to multiple groups). \n + If none of the groups satisfy the scheduling restrictions, then + scheduling fails, which means no cluster will be selected. \n + Note: 1. ClusterAffinities can not co-exist with ClusterAffinity. + 2. If both ClusterAffinity and ClusterAffinities are not set, + any cluster can be scheduling candidates. \n Potential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler @@ -496,9 +499,7 @@ spec: cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters." items: - description: OrderedClusterAffinityTerm selects a set of cluster - and indicates the order that Karmada scheduler should inspect - with. + description: ClusterAffinityTerm selects a set of cluster. properties: affinityName: description: AffinityName is the name of the cluster group. @@ -601,14 +602,8 @@ spec: contains only "value". The requirements are ANDed. type: object type: object - order: - description: Order of the cluster group that Karmada scheduler - should inspect with, in the range 1-100. - format: int32 - type: integer required: - affinityName - - order type: object type: array replicaScheduling: diff --git a/pkg/apis/policy/v1alpha1/propagation_types.go b/pkg/apis/policy/v1alpha1/propagation_types.go index 467106aba..4c1cb12b4 100644 --- a/pkg/apis/policy/v1alpha1/propagation_types.go +++ b/pkg/apis/policy/v1alpha1/propagation_types.go @@ -146,23 +146,29 @@ type FieldSelector struct { // Placement represents the rule for select clusters. type Placement struct { // ClusterAffinity represents scheduling restrictions to a certain set of clusters. - // If not set, any cluster can be scheduling candidate. + // Note: + // 1. ClusterAffinity can not co-exist with ClusterAffinities. + // 2. If both ClusterAffinity and ClusterAffinities are not set, any cluster + // can be scheduling candidates. // +optional ClusterAffinity *ClusterAffinity `json:"clusterAffinity,omitempty"` - // OrderedClusterAffinities represents the scheduling order among multiple - // set of clusters that indicated by OrderedClusterAffinityTerm. - // Each term should have a unique order among all terms. + // ClusterAffinities represents scheduling restrictions to multiple cluster + // groups that indicated by ClusterAffinityTerm. // - // The scheduler will evaluate these groups one by one in strict order, the - // group that does not satisfy scheduling restrictions will be ignored that - // means all clusters in this group will not be selected unless it also - // belongs to the next group(a cluster could belong to multiple groups). + // The scheduler will evaluate these groups one by one in the order they + // appear in the spec, the group that does not satisfy scheduling restrictions + // will be ignored which means all clusters in this group will not be selected + // unless it also belongs to the next group(a cluster could belong to multiple + // groups). // // If none of the groups satisfy the scheduling restrictions, then scheduling // fails, which means no cluster will be selected. // - // Note: OrderedClusterAffinities can not co-exist with ClusterAffinity. + // Note: + // 1. ClusterAffinities can not co-exist with ClusterAffinity. + // 2. If both ClusterAffinity and ClusterAffinities are not set, any cluster + // can be scheduling candidates. // // Potential use case 1: // The private clusters in the local data center could be the main group, and @@ -178,7 +184,7 @@ type Placement struct { // Karmada scheduler could migrate workloads to the backup clusters. // // +optional - OrderedClusterAffinities []OrderedClusterAffinityTerm `json:"orderedClusterAffinities,omitempty"` + ClusterAffinities []ClusterAffinityTerm `json:"orderedClusterAffinities,omitempty"` // ClusterTolerations represents the tolerations. // +optional @@ -255,17 +261,12 @@ type ClusterAffinity struct { ExcludeClusters []string `json:"exclude,omitempty"` } -// OrderedClusterAffinityTerm selects a set of cluster and indicates the order -// that Karmada scheduler should inspect with. -type OrderedClusterAffinityTerm struct { +// ClusterAffinityTerm selects a set of cluster. +type ClusterAffinityTerm struct { // AffinityName is the name of the cluster group. // +required AffinityName string `json:"affinityName"` - // Order of the cluster group that Karmada scheduler should inspect with, in the range 1-100. - // +required - Order int32 `json:"order"` - ClusterAffinity `json:",inline"` } diff --git a/pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go index 1e5c53856..533f13469 100644 --- a/pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go @@ -47,6 +47,23 @@ func (in *ClusterAffinity) DeepCopy() *ClusterAffinity { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterAffinityTerm) DeepCopyInto(out *ClusterAffinityTerm) { + *out = *in + in.ClusterAffinity.DeepCopyInto(&out.ClusterAffinity) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterAffinityTerm. +func (in *ClusterAffinityTerm) DeepCopy() *ClusterAffinityTerm { + if in == nil { + return nil + } + out := new(ClusterAffinityTerm) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterOverridePolicy) DeepCopyInto(out *ClusterOverridePolicy) { *out = *in @@ -439,23 +456,6 @@ func (in *LabelAnnotationOverrider) DeepCopy() *LabelAnnotationOverrider { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OrderedClusterAffinityTerm) DeepCopyInto(out *OrderedClusterAffinityTerm) { - *out = *in - in.ClusterAffinity.DeepCopyInto(&out.ClusterAffinity) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OrderedClusterAffinityTerm. -func (in *OrderedClusterAffinityTerm) DeepCopy() *OrderedClusterAffinityTerm { - if in == nil { - return nil - } - out := new(OrderedClusterAffinityTerm) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OverridePolicy) DeepCopyInto(out *OverridePolicy) { *out = *in @@ -618,9 +618,9 @@ func (in *Placement) DeepCopyInto(out *Placement) { *out = new(ClusterAffinity) (*in).DeepCopyInto(*out) } - if in.OrderedClusterAffinities != nil { - in, out := &in.OrderedClusterAffinities, &out.OrderedClusterAffinities - *out = make([]OrderedClusterAffinityTerm, len(*in)) + if in.ClusterAffinities != nil { + in, out := &in.ClusterAffinities, &out.ClusterAffinities + *out = make([]ClusterAffinityTerm, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 9cf6a2dda..73423fc74 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -55,6 +55,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1.MultiClusterIngress": schema_pkg_apis_networking_v1alpha1_MultiClusterIngress(ref), "github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1.MultiClusterIngressList": schema_pkg_apis_networking_v1alpha1_MultiClusterIngressList(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinity": schema_pkg_apis_policy_v1alpha1_ClusterAffinity(ref), + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinityTerm": schema_pkg_apis_policy_v1alpha1_ClusterAffinityTerm(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterOverridePolicy": schema_pkg_apis_policy_v1alpha1_ClusterOverridePolicy(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterOverridePolicyList": schema_pkg_apis_policy_v1alpha1_ClusterOverridePolicyList(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterPreferences": schema_pkg_apis_policy_v1alpha1_ClusterPreferences(ref), @@ -70,7 +71,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ImageOverrider": schema_pkg_apis_policy_v1alpha1_ImageOverrider(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ImagePredicate": schema_pkg_apis_policy_v1alpha1_ImagePredicate(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.LabelAnnotationOverrider": schema_pkg_apis_policy_v1alpha1_LabelAnnotationOverrider(ref), - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.OrderedClusterAffinityTerm": schema_pkg_apis_policy_v1alpha1_OrderedClusterAffinityTerm(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.OverridePolicy": schema_pkg_apis_policy_v1alpha1_OverridePolicy(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.OverridePolicyList": schema_pkg_apis_policy_v1alpha1_OverridePolicyList(ref), "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.OverrideSpec": schema_pkg_apis_policy_v1alpha1_OverrideSpec(ref), @@ -2202,6 +2202,72 @@ func schema_pkg_apis_policy_v1alpha1_ClusterAffinity(ref common.ReferenceCallbac } } +func schema_pkg_apis_policy_v1alpha1_ClusterAffinityTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClusterAffinityTerm selects a set of cluster.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "affinityName": { + SchemaProps: spec.SchemaProps{ + Description: "AffinityName is the name of the cluster group.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "labelSelector": { + SchemaProps: spec.SchemaProps{ + Description: "LabelSelector is a filter to select member clusters by labels. If non-nil and non-empty, only the clusters match this filter will be selected.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + "fieldSelector": { + SchemaProps: spec.SchemaProps{ + Description: "FieldSelector is a filter to select member clusters by fields. If non-nil and non-empty, only the clusters match this filter will be selected.", + Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FieldSelector"), + }, + }, + "clusterNames": { + SchemaProps: spec.SchemaProps{ + Description: "ClusterNames is the list of clusters to be selected.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "exclude": { + SchemaProps: spec.SchemaProps{ + Description: "ExcludedClusters is the list of clusters to be ignored.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"affinityName"}, + }, + }, + Dependencies: []string{ + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FieldSelector", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + func schema_pkg_apis_policy_v1alpha1_ClusterOverridePolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2859,80 +2925,6 @@ func schema_pkg_apis_policy_v1alpha1_LabelAnnotationOverrider(ref common.Referen } } -func schema_pkg_apis_policy_v1alpha1_OrderedClusterAffinityTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "OrderedClusterAffinityTerm selects a set of cluster and indicates the order that Karmada scheduler should inspect with.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "affinityName": { - SchemaProps: spec.SchemaProps{ - Description: "AffinityName is the name of the cluster group.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "order": { - SchemaProps: spec.SchemaProps{ - Description: "Order of the cluster group that Karmada scheduler should inspect with, in the range 1-100.", - Default: 0, - Type: []string{"integer"}, - Format: "int32", - }, - }, - "labelSelector": { - SchemaProps: spec.SchemaProps{ - Description: "LabelSelector is a filter to select member clusters by labels. If non-nil and non-empty, only the clusters match this filter will be selected.", - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), - }, - }, - "fieldSelector": { - SchemaProps: spec.SchemaProps{ - Description: "FieldSelector is a filter to select member clusters by fields. If non-nil and non-empty, only the clusters match this filter will be selected.", - Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FieldSelector"), - }, - }, - "clusterNames": { - SchemaProps: spec.SchemaProps{ - Description: "ClusterNames is the list of clusters to be selected.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - "exclude": { - SchemaProps: spec.SchemaProps{ - Description: "ExcludedClusters is the list of clusters to be ignored.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - }, - Required: []string{"affinityName", "order"}, - }, - }, - Dependencies: []string{ - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FieldSelector", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, - } -} - func schema_pkg_apis_policy_v1alpha1_OverridePolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -3190,19 +3182,19 @@ func schema_pkg_apis_policy_v1alpha1_Placement(ref common.ReferenceCallback) com Properties: map[string]spec.Schema{ "clusterAffinity": { SchemaProps: spec.SchemaProps{ - Description: "ClusterAffinity represents scheduling restrictions to a certain set of clusters. If not set, any cluster can be scheduling candidate.", + Description: "ClusterAffinity represents scheduling restrictions to a certain set of clusters. Note:\n 1. ClusterAffinity can not co-exist with ClusterAffinities.\n 2. If both ClusterAffinity and ClusterAffinities are not set, any cluster\n can be scheduling candidates.", Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinity"), }, }, "orderedClusterAffinities": { SchemaProps: spec.SchemaProps{ - Description: "OrderedClusterAffinities represents the scheduling order among multiple set of clusters that indicated by OrderedClusterAffinityTerm. Each term should have a unique order among all terms.\n\nThe scheduler will evaluate these groups one by one in strict order, the group that does not satisfy scheduling restrictions will be ignored that means all clusters in this group will not be selected unless it also belongs to the next group(a cluster could belong to multiple groups).\n\nIf none of the groups satisfy the scheduling restrictions, then scheduling fails, which means no cluster will be selected.\n\nNote: OrderedClusterAffinities can not co-exist with ClusterAffinity.\n\nPotential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler would prefer to schedule workloads to the main group and the second group will only be considered in case of the main group does not satisfy restrictions(like, lack of resources).\n\nPotential use case 2: For the disaster recovery scenario, the clusters could be organized to primary and backup groups, the workloads would be scheduled to primary clusters firstly, and when primary cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters.", + Description: "ClusterAffinities represents scheduling restrictions to multiple cluster groups that indicated by ClusterAffinityTerm.\n\nThe scheduler will evaluate these groups one by one in the order they appear in the spec, the group that does not satisfy scheduling restrictions will be ignored which means all clusters in this group will not be selected unless it also belongs to the next group(a cluster could belong to multiple groups).\n\nIf none of the groups satisfy the scheduling restrictions, then scheduling fails, which means no cluster will be selected.\n\nNote:\n 1. ClusterAffinities can not co-exist with ClusterAffinity.\n 2. If both ClusterAffinity and ClusterAffinities are not set, any cluster\n can be scheduling candidates.\n\nPotential use case 1: The private clusters in the local data center could be the main group, and the managed clusters provided by cluster providers could be the secondary group. So that the Karmada scheduler would prefer to schedule workloads to the main group and the second group will only be considered in case of the main group does not satisfy restrictions(like, lack of resources).\n\nPotential use case 2: For the disaster recovery scenario, the clusters could be organized to primary and backup groups, the workloads would be scheduled to primary clusters firstly, and when primary cluster fails(like data center power off), Karmada scheduler could migrate workloads to the backup clusters.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.OrderedClusterAffinityTerm"), + Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinityTerm"), }, }, }, @@ -3246,7 +3238,7 @@ func schema_pkg_apis_policy_v1alpha1_Placement(ref common.ReferenceCallback) com }, }, Dependencies: []string{ - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinity", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.OrderedClusterAffinityTerm", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ReplicaSchedulingStrategy", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SpreadConstraint", "k8s.io/api/core/v1.Toleration"}, + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinity", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ClusterAffinityTerm", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.ReplicaSchedulingStrategy", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.SpreadConstraint", "k8s.io/api/core/v1.Toleration"}, } }