Update clusterset api to make ManagedClusterSet exclusive

This commit is contained in:
Yang Le
2020-09-23 16:22:50 +08:00
parent 6c8511ad98
commit 4d7ea36bf4
12 changed files with 49 additions and 289 deletions

2
go.mod
View File

@@ -9,7 +9,7 @@ require (
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/open-cluster-management/api v0.0.0-20200902123524-a932fbe34f12
github.com/open-cluster-management/api v0.0.0-20200923021655-f9a64b7328eb
github.com/openshift/api v0.0.0-20200827090112-c05698d102cf
github.com/openshift/build-machinery-go v0.0.0-20200819073603-48aa266c95f7
github.com/openshift/library-go v0.0.0-20200902171820-35f48b6ef30c

4
go.sum
View File

@@ -331,8 +331,8 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/open-cluster-management/api v0.0.0-20200902123524-a932fbe34f12 h1:yHeMhSm3TNLQBOqoGnqXZyLtdAhEEYSM7B+bOW35/iU=
github.com/open-cluster-management/api v0.0.0-20200902123524-a932fbe34f12/go.mod h1:F1hDJHtWuV7BAUtfL4XRS9GZjUpksleLgEcisNXvQEw=
github.com/open-cluster-management/api v0.0.0-20200923021655-f9a64b7328eb h1:38+wdQOd8ZRzky4LyM+VaQswpKqHWjXsP6MdAdEoBRM=
github.com/open-cluster-management/api v0.0.0-20200923021655-f9a64b7328eb/go.mod h1:F1hDJHtWuV7BAUtfL4XRS9GZjUpksleLgEcisNXvQEw=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v0.0.0-20191031171055-b133feaeeb2e/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=

View File

@@ -1,7 +1,6 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersets.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io
@@ -18,10 +17,15 @@ spec:
openAPIV3Schema:
description: "ManagedClusterSet defines a group of ManagedClusters that user's
workload can run on. A workload can be defined to deployed on a ManagedClusterSet,
which mean: \n 1. The workload can run on any ManagedCluster in the ManagedClusterSet
2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet"
which mean: 1. The workload can run on any ManagedCluster in the ManagedClusterSet
\ 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
\ 3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet \n In order to assign a ManagedCluster to a certian
ManagedClusterSet, add a label with name `cluster.open-cluster-management.io/clusterset`
on the ManagedCluster to refers to the ManagedClusterSet. User is not allow
to add/remove this label on a ManagedCluster unless they have a RBAC rule
to CREATE on a virtual subresource of managedclustersets/join. In order to
update this label, user must have the permission on both the old and new ManagedClusterSet."
type: object
properties:
apiVersion:
@@ -37,72 +41,8 @@ spec:
metadata:
type: object
spec:
description: Spec defines the attributes of the desired ManagedClusters
description: Spec defines the attributes of the ManagedClusterSet
type: object
properties:
clusterSelectors:
description: ClusterSelectors represents a slice of selectors to select
ManagedClusters If empty, the ManagedClusterSet will include no ManagedCluster.
If more than one ClusterSelector are specified in the slice, OR operation
will be used between them.
type: array
items:
description: ClusterSelector represents a selector of ManagedClusters
ClusterNames and LabelSelector are mutually exclusive. They cannot
be set at the same time. If none of them is set, no ManagedCluster
will be selected
type: object
properties:
clusterNames:
description: ClusterNames represents a list of cluster name
type: array
items:
type: string
labelSelector:
description: LabelSelector represents a label selector to select
cluster by label
type: object
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
type: array
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
type: object
required:
- key
- operator
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.
type: array
items:
type: string
matchLabels:
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
additionalProperties:
type: string
status:
description: Status represents the current status of the ManagedClusterSet
type: object

View File

@@ -1,7 +1,6 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersetbindings.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io

View File

@@ -7,6 +7,7 @@ package dependencymagnet
import (
_ "github.com/go-bindata/go-bindata/go-bindata"
_ "github.com/open-cluster-management/api/cluster/v1"
_ "github.com/open-cluster-management/api/cluster/v1alpha1"
_ "github.com/open-cluster-management/api/work/v1"
_ "github.com/openshift/build-machinery-go"
)

View File

@@ -314,7 +314,6 @@ func manifestsClusterManager0000_00_clustersOpenClusterManagementIo_managedclust
var _manifestsClusterManager0000_00_clustersOpenClusterManagementIo_managedclustersetsCrdYaml = []byte(`apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersets.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io
@@ -331,10 +330,15 @@ spec:
openAPIV3Schema:
description: "ManagedClusterSet defines a group of ManagedClusters that user's
workload can run on. A workload can be defined to deployed on a ManagedClusterSet,
which mean: \n 1. The workload can run on any ManagedCluster in the ManagedClusterSet
2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet"
which mean: 1. The workload can run on any ManagedCluster in the ManagedClusterSet
\ 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
\ 3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet \n In order to assign a ManagedCluster to a certian
ManagedClusterSet, add a label with name ` + "`" + `cluster.open-cluster-management.io/clusterset` + "`" + `
on the ManagedCluster to refers to the ManagedClusterSet. User is not allow
to add/remove this label on a ManagedCluster unless they have a RBAC rule
to CREATE on a virtual subresource of managedclustersets/join. In order to
update this label, user must have the permission on both the old and new ManagedClusterSet."
type: object
properties:
apiVersion:
@@ -350,72 +354,8 @@ spec:
metadata:
type: object
spec:
description: Spec defines the attributes of the desired ManagedClusters
description: Spec defines the attributes of the ManagedClusterSet
type: object
properties:
clusterSelectors:
description: ClusterSelectors represents a slice of selectors to select
ManagedClusters If empty, the ManagedClusterSet will include no ManagedCluster.
If more than one ClusterSelector are specified in the slice, OR operation
will be used between them.
type: array
items:
description: ClusterSelector represents a selector of ManagedClusters
ClusterNames and LabelSelector are mutually exclusive. They cannot
be set at the same time. If none of them is set, no ManagedCluster
will be selected
type: object
properties:
clusterNames:
description: ClusterNames represents a list of cluster name
type: array
items:
type: string
labelSelector:
description: LabelSelector represents a label selector to select
cluster by label
type: object
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
type: array
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
type: object
required:
- key
- operator
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.
type: array
items:
type: string
matchLabels:
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
additionalProperties:
type: string
status:
description: Status represents the current status of the ManagedClusterSet
type: object
@@ -815,7 +755,6 @@ func manifestsClusterManager0000_00_workOpenClusterManagementIo_manifestworksCrd
var _manifestsClusterManager0000_01_clustersOpenClusterManagementIo_managedclustersetbindingsCrdYaml = []byte(`apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersetbindings.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io

View File

@@ -1,7 +1,6 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersets.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io
@@ -18,10 +17,15 @@ spec:
openAPIV3Schema:
description: "ManagedClusterSet defines a group of ManagedClusters that user's
workload can run on. A workload can be defined to deployed on a ManagedClusterSet,
which mean: \n 1. The workload can run on any ManagedCluster in the ManagedClusterSet
2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet"
which mean: 1. The workload can run on any ManagedCluster in the ManagedClusterSet
\ 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
\ 3. The service exposed by the workload can be shared in any ManagedCluster
in the ManagedClusterSet \n In order to assign a ManagedCluster to a certian
ManagedClusterSet, add a label with name `cluster.open-cluster-management.io/clusterset`
on the ManagedCluster to refers to the ManagedClusterSet. User is not allow
to add/remove this label on a ManagedCluster unless they have a RBAC rule
to CREATE on a virtual subresource of managedclustersets/join. In order to
update this label, user must have the permission on both the old and new ManagedClusterSet."
type: object
properties:
apiVersion:
@@ -37,72 +41,8 @@ spec:
metadata:
type: object
spec:
description: Spec defines the attributes of the desired ManagedClusters
description: Spec defines the attributes of the ManagedClusterSet
type: object
properties:
clusterSelectors:
description: ClusterSelectors represents a slice of selectors to select
ManagedClusters If empty, the ManagedClusterSet will include no ManagedCluster.
If more than one ClusterSelector are specified in the slice, OR operation
will be used between them.
type: array
items:
description: ClusterSelector represents a selector of ManagedClusters
ClusterNames and LabelSelector are mutually exclusive. They cannot
be set at the same time. If none of them is set, no ManagedCluster
will be selected
type: object
properties:
clusterNames:
description: ClusterNames represents a list of cluster name
type: array
items:
type: string
labelSelector:
description: LabelSelector represents a label selector to select
cluster by label
type: object
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
type: array
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
type: object
required:
- key
- operator
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.
type: array
items:
type: string
matchLabels:
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
additionalProperties:
type: string
status:
description: Status represents the current status of the ManagedClusterSet
type: object

View File

@@ -1,7 +1,6 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: managedclustersetbindings.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io

View File

@@ -12,15 +12,20 @@ import (
// ManagedClusterSet defines a group of ManagedClusters that user's workload can run on.
// A workload can be defined to deployed on a ManagedClusterSet, which mean:
// 1. The workload can run on any ManagedCluster in the ManagedClusterSet
// 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
// 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet
//
// 1. The workload can run on any ManagedCluster in the ManagedClusterSet
// 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet
// 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet
// In order to assign a ManagedCluster to a certian ManagedClusterSet, add a label with name
// `cluster.open-cluster-management.io/clusterset` on the ManagedCluster to refers to the ManagedClusterSet.
// User is not allow to add/remove this label on a ManagedCluster unless they have a RBAC rule to CREATE on
// a virtual subresource of managedclustersets/join. In order to update this label, user must have the permission
// on both the old and new ManagedClusterSet.
type ManagedClusterSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the attributes of the desired ManagedClusters
// Spec defines the attributes of the ManagedClusterSet
Spec ManagedClusterSetSpec `json:"spec"`
// Status represents the current status of the ManagedClusterSet
@@ -28,27 +33,8 @@ type ManagedClusterSet struct {
Status ManagedClusterSetStatus `json:"status,omitempty"`
}
// ManagedClusterSetSpec describes the attributes of the desired ManagedClusters
// ManagedClusterSetSpec describes the attributes of the ManagedClusterSet
type ManagedClusterSetSpec struct {
// ClusterSelectors represents a slice of selectors to select ManagedClusters
// If empty, the ManagedClusterSet will include no ManagedCluster.
// If more than one ClusterSelector are specified in the slice, OR operation
// will be used between them.
// +optional
ClusterSelectors []ClusterSelector `json:"clusterSelectors,omitempty"`
}
// ClusterSelector represents a selector of ManagedClusters
// ClusterNames and LabelSelector are mutually exclusive. They cannot be set at the
// same time. If none of them is set, no ManagedCluster will be selected
type ClusterSelector struct {
// ClusterNames represents a list of cluster name
// +optional
ClusterNames []string `json:"clusterNames,omitempty"`
// LabelSelector represents a label selector to select cluster by label
// +optional
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
}
// ManagedClusterSetStatus represents the current status of the ManagedClusterSet.

View File

@@ -9,38 +9,12 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterSelector) DeepCopyInto(out *ClusterSelector) {
*out = *in
if in.ClusterNames != nil {
in, out := &in.ClusterNames, &out.ClusterNames
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.LabelSelector != nil {
in, out := &in.LabelSelector, &out.LabelSelector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSelector.
func (in *ClusterSelector) DeepCopy() *ClusterSelector {
if in == nil {
return nil
}
out := new(ClusterSelector)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedClusterSet) DeepCopyInto(out *ManagedClusterSet) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Spec = in.Spec
in.Status.DeepCopyInto(&out.Status)
return
}
@@ -175,13 +149,6 @@ func (in *ManagedClusterSetList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ManagedClusterSetSpec) DeepCopyInto(out *ManagedClusterSetSpec) {
*out = *in
if in.ClusterSelectors != nil {
in, out := &in.ClusterSelectors, &out.ClusterSelectors
*out = make([]ClusterSelector, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}

View File

@@ -11,19 +11,9 @@ package v1alpha1
// Those methods can be generated by using hack/update-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE
var map_ClusterSelector = map[string]string{
"": "ClusterSelector represents a selector of ManagedClusters ClusterNames and LabelSelector are mutually exclusive. They cannot be set at the same time. If none of them is set, no ManagedCluster will be selected",
"clusterNames": "ClusterNames represents a list of cluster name",
"labelSelector": "LabelSelector represents a label selector to select cluster by label",
}
func (ClusterSelector) SwaggerDoc() map[string]string {
return map_ClusterSelector
}
var map_ManagedClusterSet = map[string]string{
"": "ManagedClusterSet defines a group of ManagedClusters that user's workload can run on. A workload can be defined to deployed on a ManagedClusterSet, which mean:\n\n1. The workload can run on any ManagedCluster in the ManagedClusterSet 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet",
"spec": "Spec defines the attributes of the desired ManagedClusters",
"": "ManagedClusterSet defines a group of ManagedClusters that user's workload can run on. A workload can be defined to deployed on a ManagedClusterSet, which mean:\n 1. The workload can run on any ManagedCluster in the ManagedClusterSet\n 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet\n 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet\n\nIn order to assign a ManagedCluster to a certian ManagedClusterSet, add a label with name `cluster.open-cluster-management.io/clusterset` on the ManagedCluster to refers to the ManagedClusterSet. User is not allow to add/remove this label on a ManagedCluster unless they have a RBAC rule to CREATE on a virtual subresource of managedclustersets/join. In order to update this label, user must have the permission on both the old and new ManagedClusterSet.",
"spec": "Spec defines the attributes of the ManagedClusterSet",
"status": "Status represents the current status of the ManagedClusterSet",
}
@@ -70,8 +60,7 @@ func (ManagedClusterSetList) SwaggerDoc() map[string]string {
}
var map_ManagedClusterSetSpec = map[string]string{
"": "ManagedClusterSetSpec describes the attributes of the desired ManagedClusters",
"clusterSelectors": "ClusterSelectors represents a slice of selectors to select ManagedClusters If empty, the ManagedClusterSet will include no ManagedCluster. If more than one ClusterSelector are specified in the slice, OR operation will be used between them.",
"": "ManagedClusterSetSpec describes the attributes of the ManagedClusterSet",
}
func (ManagedClusterSetSpec) SwaggerDoc() map[string]string {

2
vendor/modules.txt vendored
View File

@@ -144,7 +144,7 @@ github.com/onsi/gomega/matchers/support/goraph/edge
github.com/onsi/gomega/matchers/support/goraph/node
github.com/onsi/gomega/matchers/support/goraph/util
github.com/onsi/gomega/types
# github.com/open-cluster-management/api v0.0.0-20200902123524-a932fbe34f12
# github.com/open-cluster-management/api v0.0.0-20200923021655-f9a64b7328eb
## explicit
github.com/open-cluster-management/api/client/cluster/clientset/versioned
github.com/open-cluster-management/api/client/cluster/clientset/versioned/scheme