diff --git a/docs/multicluster/api.md b/docs/multicluster/api.md index 6ff2cdb3ef4..80bbad26829 100644 --- a/docs/multicluster/api.md +++ b/docs/multicluster/api.md @@ -7,11 +7,13 @@ used by Antrea Multi-cluster are in the API group `multicluster.crd.antrea.io`, two CRDs from [mcs-api](https://github.com/kubernetes-sigs/mcs-api) are in group `multicluster.x-k8s.io` which is defined by Kubernetes upstream [KEP-1645](https://github.com/kubernetes/enhancements/tree/master/keps/sig-multicluster/1645-multi-cluster-services-api). -## CRDs in `multicluster.crd.antrea.io` +## Currently-supported + +### CRDs in `multicluster.crd.antrea.io` | CRD | CRD version | Introduced in | Deprecated in / Planned Deprecation | Planned Removal | | ------------------------ | ----------- | ------------- | ----------------------------------- | --------------- | -| `ClusterClaims` | v1alpha1 | v1.5.0 | N/A | N/A | +| `ClusterClaims` | v1alpha2 | v1.8.0 | N/A | N/A | | `ClusterSets` | v1alpha1 | v1.5.0 | N/A | N/A | | `MemberClusterAnnounces` | v1alpha1 | v1.5.0 | N/A | N/A | | `ResourceExports` | v1alpha1 | v1.5.0 | N/A | N/A | @@ -19,9 +21,15 @@ which is defined by Kubernetes upstream [KEP-1645](https://github.com/kubernetes | `Gateway` | v1alpha1 | v1.7.0 | N/A | N/A | | `ClusterInfoImport` | v1alpha1 | v1.7.0 | N/A | N/A | -## CRDs in `multicluster.x-k8s.io` +### CRDs in `multicluster.x-k8s.io` | CRD | CRD version | Introduced in | Deprecated in / Planned Deprecation | Planned Removal | | ---------------- | ----------- | ------------- | ----------------------------------- | --------------- | | `ServiceExports` | v1alpha1 | v1.5.0 | N/A | N/A | | `ServiceImports` | v1alpha1 | v1.5.0 | N/A | N/A | + +## Previously-supported CRDs + +| CRD | API group | CRD version | Introduced in | Deprecated in | Removed in | +| ------------------------ | ---------------------------- | ----------- | ------------- | ------------- | ---------- | +| `ClusterClaims` | `multicluster.crd.antrea.io` | v1alpha1 | v1.5.0 | v1.8.0 | v1.8.0 | \ No newline at end of file diff --git a/docs/multicluster/user-guide.md b/docs/multicluster/user-guide.md old mode 100644 new mode 100755 index ca6c8b90ab2..893b49868a8 --- a/docs/multicluster/user-guide.md +++ b/docs/multicluster/user-guide.md @@ -182,20 +182,18 @@ with the following YAML manifest (you can also refer to [multicluster_membercluster_template.yaml](../../multicluster/config/samples/clusterset_init/multicluster_membercluster_template.yaml)): ```yaml -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: name: id.k8s.io namespace: kube-system -name: id.k8s.io value: test-cluster-east --- -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: name: clusterset.k8s.io namespace: kube-system -name: clusterset.k8s.io value: test-clusterset --- apiVersion: multicluster.crd.antrea.io/v1alpha1 @@ -224,15 +222,13 @@ kind: ClusterClaim metadata: name: id.k8s.io namespace: kube-system -name: id.k8s.io value: test-cluster-west --- -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: name: clusterset.k8s.io namespace: kube-system -name: clusterset.k8s.io value: test-clusterset --- apiVersion: multicluster.crd.antrea.io/v1alpha1 @@ -255,20 +251,18 @@ spec: [multicluster_clusterset_template.yaml](../../multicluster/config/samples/clusterset_init/multicluster_clusterset_template.yaml)): ```yaml -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: name: id.k8s.io namespace: antrea-multicluster -name: id.k8s.io value: test-cluster-north --- -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: name: clusterset.k8s.io namespace: antrea-multicluster -name: clusterset.k8s.io value: test-clusterset --- apiVersion: multicluster.crd.antrea.io/v1alpha1 @@ -303,20 +297,18 @@ Then create the `ClusterClaim` and `ClusterSet` CRs in cluster Multi-cluster Controller runs): ```yaml -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: name: id.k8s.io namespace: kube-system -name: id.k8s.io value: test-cluster-north --- -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: name: clusterset.k8s.io namespace: kube-system -name: clusterset.k8s.io value: test-clusterset --- apiVersion: multicluster.crd.antrea.io/v1alpha1 diff --git a/multicluster/PROJECT b/multicluster/PROJECT index de1384624fe..1625e1d6f51 100644 --- a/multicluster/PROJECT +++ b/multicluster/PROJECT @@ -5,19 +5,6 @@ multigroup: true projectName: multicluster repo: antrea.io/antrea/multicluster resources: -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: crd.antrea.io - group: multicluster - kind: ClusterClaim - path: antrea.io/antrea/multicluster/apis/multicluster/v1alpha1 - version: v1alpha1 - webhooks: - defaulting: true - validation: true - webhookVersion: v1 - api: crdVersion: v1 namespaced: true @@ -96,4 +83,13 @@ resources: kind: Gateway path: antrea.io/antrea/multicluster/apis/multicluster/v1alpha1 version: v1alpha1 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: crd.antrea.io + group: multicluster + kind: ClusterClaim + path: antrea.io/antrea/multicluster/apis/multicluster/v1alpha2 + version: v1alpha2 version: "3" diff --git a/multicluster/apis/multicluster/v1alpha1/webhook_suite_test.go b/multicluster/apis/multicluster/v1alpha1/webhook_suite_test.go deleted file mode 100644 index 03439d3bb61..00000000000 --- a/multicluster/apis/multicluster/v1alpha1/webhook_suite_test.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2021 Antrea Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "context" - "crypto/tls" - "fmt" - "net" - "path/filepath" - "testing" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - admissionv1beta1 "k8s.io/api/admission/v1beta1" - //+kubebuilder:scaffold:imports - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - "sigs.k8s.io/controller-runtime/pkg/envtest/printer" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecsWithDefaultAndCustomReporters(t, - "Webhook Suite", - []Reporter{printer.NewlineReporter{}}) -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: false, - WebhookInstallOptions: envtest.WebhookInstallOptions{ - Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, - }, - } - - var err error - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - scheme := runtime.NewScheme() - err = AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - err = admissionv1beta1.AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - // start webhook server using Manager - webhookInstallOptions := &testEnv.WebhookInstallOptions - mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - LeaderElection: false, - MetricsBindAddress: "0", - }) - Expect(err).NotTo(HaveOccurred()) - - err = (&ClusterClaim{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&ClusterSet{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&ResourceImport{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&ResourceExport{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:webhook - - go func() { - err = mgr.Start(ctx) - if err != nil { - Expect(err).NotTo(HaveOccurred()) - } - }() - - // wait for the webhook server to get ready - dialer := &net.Dialer{Timeout: time.Second} - addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) - Eventually(func() error { - // #nosec G402: for test - conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) - if err != nil { - return err - } - conn.Close() - return nil - }).Should(Succeed()) - -}, 60) - -var _ = AfterSuite(func() { - cancel() - By("tearing down the test environment") - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/multicluster/apis/multicluster/v1alpha1/zz_generated.deepcopy.go b/multicluster/apis/multicluster/v1alpha1/zz_generated.deepcopy.go index 7809291302a..2df3d1d7139 100644 --- a/multicluster/apis/multicluster/v1alpha1/zz_generated.deepcopy.go +++ b/multicluster/apis/multicluster/v1alpha1/zz_generated.deepcopy.go @@ -29,63 +29,6 @@ import ( apisv1alpha1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterClaim) DeepCopyInto(out *ClusterClaim) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaim. -func (in *ClusterClaim) DeepCopy() *ClusterClaim { - if in == nil { - return nil - } - out := new(ClusterClaim) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterClaim) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterClaimList) DeepCopyInto(out *ClusterClaimList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ClusterClaim, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaimList. -func (in *ClusterClaimList) DeepCopy() *ClusterClaimList { - if in == nil { - return nil - } - out := new(ClusterClaimList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterClaimList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterCondition) DeepCopyInto(out *ClusterCondition) { *out = *in diff --git a/multicluster/apis/multicluster/v1alpha1/clusterclaim_types.go b/multicluster/apis/multicluster/v1alpha2/clusterclaim_types.go similarity index 88% rename from multicluster/apis/multicluster/v1alpha1/clusterclaim_types.go rename to multicluster/apis/multicluster/v1alpha2/clusterclaim_types.go index 5699b8e4cb1..3bae18c60a3 100644 --- a/multicluster/apis/multicluster/v1alpha1/clusterclaim_types.go +++ b/multicluster/apis/multicluster/v1alpha2/clusterclaim_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1alpha2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -29,13 +29,13 @@ const ( // +genclient //+kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion // ClusterClaim is the Schema for the clusterclaims API type ClusterClaim struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // Name of the ClusterClaim. - Name string `json:"name,omitempty"` // TODO: Remove the name as it is already part of ObjectMeta and its confusing to have two names // Value of the ClusterClaim. Value string `json:"value,omitempty"` } diff --git a/multicluster/apis/multicluster/v1alpha1/clusterclaim_webhook.go b/multicluster/apis/multicluster/v1alpha2/clusterclaim_webhook.go similarity index 83% rename from multicluster/apis/multicluster/v1alpha1/clusterclaim_webhook.go rename to multicluster/apis/multicluster/v1alpha2/clusterclaim_webhook.go index 69487ea244c..fef4f3ce116 100644 --- a/multicluster/apis/multicluster/v1alpha1/clusterclaim_webhook.go +++ b/multicluster/apis/multicluster/v1alpha2/clusterclaim_webhook.go @@ -14,9 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1alpha2 import ( + "fmt" + "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/log" @@ -32,7 +34,7 @@ func (r *ClusterClaim) SetupWebhookWithManager(mgr ctrl.Manager) error { Complete() } -//+kubebuilder:webhook:path=/mutate-multicluster-crd-antrea-io-v1alpha1-clusterclaim,mutating=true,failurePolicy=fail,sideEffects=None,groups=multicluster.crd.antrea.io,resources=clusterclaims,verbs=create;update,versions=v1alpha1,name=mclusterclaim.kb.io,admissionReviewVersions={v1,v1beta1} +//+kubebuilder:webhook:path=/mutate-multicluster-crd-antrea-io-v1alpha2-clusterclaim,mutating=true,failurePolicy=fail,sideEffects=None,groups=multicluster.crd.antrea.io,resources=clusterclaims,verbs=create;update,versions=v1alpha2,name=mclusterclaim.kb.io,admissionReviewVersions={v1,v1beta1} var _ webhook.Defaulter = &ClusterClaim{} @@ -44,15 +46,18 @@ func (r *ClusterClaim) Default() { } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-multicluster-crd-antrea-io-v1alpha1-clusterclaim,mutating=false,failurePolicy=fail,sideEffects=None,groups=multicluster.crd.antrea.io,resources=clusterclaims,verbs=create;update,versions=v1alpha1,name=vclusterclaim.kb.io,admissionReviewVersions={v1,v1beta1} +//+kubebuilder:webhook:path=/validate-multicluster-crd-antrea-io-v1alpha2-clusterclaim,mutating=false,failurePolicy=fail,sideEffects=None,groups=multicluster.crd.antrea.io,resources=clusterclaims,verbs=create;update,versions=v1alpha2,name=vclusterclaim.kb.io,admissionReviewVersions={v1,v1beta1} var _ webhook.Validator = &ClusterClaim{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *ClusterClaim) ValidateCreate() error { clusterclaimlog.Info("validate create", "name", r.Name) + if r.Name != WellKnownClusterClaimClusterSet && r.Name != WellKnownClusterClaimID { + err := fmt.Errorf("The name %s is not valid, only 'id.k8s.io' and 'clusterset.k8s.io' are valid name for ClusterClaim", r.Name) + return err + } - // TODO(user): fill in your validation logic upon object creation. return nil } diff --git a/multicluster/apis/multicluster/v1alpha2/doc.go b/multicluster/apis/multicluster/v1alpha2/doc.go new file mode 100644 index 00000000000..5a4d8db30eb --- /dev/null +++ b/multicluster/apis/multicluster/v1alpha2/doc.go @@ -0,0 +1,17 @@ +// Copyright 2022 Antrea Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package v1alpha2 is the v1alpha2 version of the API. +// +groupName=multicluster.crd.antrea.io +package v1alpha2 diff --git a/multicluster/apis/multicluster/v1alpha2/groupversion_info.go b/multicluster/apis/multicluster/v1alpha2/groupversion_info.go new file mode 100644 index 00000000000..e6ad5cb7515 --- /dev/null +++ b/multicluster/apis/multicluster/v1alpha2/groupversion_info.go @@ -0,0 +1,36 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha2 contains API Schema definitions for the multicluster v1alpha2 API group +//+kubebuilder:object:generate=true +//+groupName=multicluster.crd.antrea.io +package v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "multicluster.crd.antrea.io", Version: "v1alpha2"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/multicluster/apis/multicluster/v1alpha2/register.go b/multicluster/apis/multicluster/v1alpha2/register.go new file mode 100644 index 00000000000..b2f2b257ca7 --- /dev/null +++ b/multicluster/apis/multicluster/v1alpha2/register.go @@ -0,0 +1,27 @@ +// Copyright 2022 Antrea Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects. +var SchemeGroupVersion = GroupVersion + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} diff --git a/multicluster/apis/multicluster/v1alpha2/zz_generated.deepcopy.go b/multicluster/apis/multicluster/v1alpha2/zz_generated.deepcopy.go new file mode 100644 index 00000000000..fbca39f92da --- /dev/null +++ b/multicluster/apis/multicluster/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,83 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterClaim) DeepCopyInto(out *ClusterClaim) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaim. +func (in *ClusterClaim) DeepCopy() *ClusterClaim { + if in == nil { + return nil + } + out := new(ClusterClaim) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterClaim) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterClaimList) DeepCopyInto(out *ClusterClaimList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterClaim, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaimList. +func (in *ClusterClaimList) DeepCopy() *ClusterClaimList { + if in == nil { + return nil + } + out := new(ClusterClaimList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterClaimList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} diff --git a/multicluster/build/yamls/antrea-multicluster-leader-global.yml b/multicluster/build/yamls/antrea-multicluster-leader-global.yml index 7781be9b2a6..c86d63a55ca 100644 --- a/multicluster/build/yamls/antrea-multicluster-leader-global.yml +++ b/multicluster/build/yamls/antrea-multicluster-leader-global.yml @@ -16,7 +16,7 @@ spec: singular: clusterclaim scope: Namespaced versions: - - name: v1alpha1 + - name: v1alpha2 schema: openAPIV3Schema: description: ClusterClaim is the Schema for the clusterclaims API @@ -33,15 +33,14 @@ spec: type: string metadata: type: object - name: - description: Name of the ClusterClaim. - type: string value: description: Value of the ClusterClaim. type: string type: object served: true storage: true + subresources: + status: {} status: acceptedNames: kind: "" diff --git a/multicluster/build/yamls/antrea-multicluster-leader-namespaced.yml b/multicluster/build/yamls/antrea-multicluster-leader-namespaced.yml index f10897c0ef1..2d87fcf65fb 100644 --- a/multicluster/build/yamls/antrea-multicluster-leader-namespaced.yml +++ b/multicluster/build/yamls/antrea-multicluster-leader-namespaced.yml @@ -423,9 +423,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /mutate-multicluster-crd-antrea-io-v1alpha1-clusterclaim + path: /mutate-multicluster-crd-antrea-io-v1alpha1-clusterset failurePolicy: Fail - name: mclusterclaim.kb.io + name: mclusterset.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -438,7 +438,7 @@ webhooks: - CREATE - UPDATE resources: - - clusterclaims + - clustersets sideEffects: None - admissionReviewVersions: - v1 @@ -447,9 +447,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /mutate-multicluster-crd-antrea-io-v1alpha1-clusterset + path: /mutate-multicluster-crd-antrea-io-v1alpha1-resourceexport failurePolicy: Fail - name: mclusterset.kb.io + name: mresourceexport.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -462,7 +462,7 @@ webhooks: - CREATE - UPDATE resources: - - clustersets + - resourceexports sideEffects: None - admissionReviewVersions: - v1 @@ -471,9 +471,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /mutate-multicluster-crd-antrea-io-v1alpha1-resourceexport + path: /mutate-multicluster-crd-antrea-io-v1alpha1-resourceimport failurePolicy: Fail - name: mresourceexport.kb.io + name: mresourceimport.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -486,7 +486,7 @@ webhooks: - CREATE - UPDATE resources: - - resourceexports + - resourceimports sideEffects: None - admissionReviewVersions: - v1 @@ -495,9 +495,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /mutate-multicluster-crd-antrea-io-v1alpha1-resourceimport + path: /mutate-multicluster-crd-antrea-io-v1alpha2-clusterclaim failurePolicy: Fail - name: mresourceimport.kb.io + name: mclusterclaim.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -505,12 +505,12 @@ webhooks: - apiGroups: - multicluster.crd.antrea.io apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE resources: - - resourceimports + - clusterclaims sideEffects: None --- apiVersion: admissionregistration.k8s.io/v1 @@ -528,9 +528,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /validate-multicluster-crd-antrea-io-v1alpha1-clusterclaim + path: /validate-multicluster-crd-antrea-io-v1alpha1-clusterset failurePolicy: Fail - name: vclusterclaim.kb.io + name: vclusterset.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -543,7 +543,7 @@ webhooks: - CREATE - UPDATE resources: - - clusterclaims + - clustersets sideEffects: None - admissionReviewVersions: - v1 @@ -552,9 +552,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /validate-multicluster-crd-antrea-io-v1alpha1-clusterset + path: /validate-multicluster-crd-antrea-io-v1alpha1-resourceexport failurePolicy: Fail - name: vclusterset.kb.io + name: vresourceexport.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -567,7 +567,7 @@ webhooks: - CREATE - UPDATE resources: - - clustersets + - resourceexports sideEffects: None - admissionReviewVersions: - v1 @@ -576,9 +576,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /validate-multicluster-crd-antrea-io-v1alpha1-resourceexport + path: /validate-multicluster-crd-antrea-io-v1alpha1-resourceimport failurePolicy: Fail - name: vresourceexport.kb.io + name: vresourceimport.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -591,7 +591,7 @@ webhooks: - CREATE - UPDATE resources: - - resourceexports + - resourceimports sideEffects: None - admissionReviewVersions: - v1 @@ -600,9 +600,9 @@ webhooks: service: name: antrea-mc-webhook-service namespace: antrea-multicluster - path: /validate-multicluster-crd-antrea-io-v1alpha1-resourceimport + path: /validate-multicluster-crd-antrea-io-v1alpha2-clusterclaim failurePolicy: Fail - name: vresourceimport.kb.io + name: vclusterclaim.kb.io namespaceSelector: matchLabels: kubernetes.io/metadata.name: antrea-multicluster @@ -610,12 +610,12 @@ webhooks: - apiGroups: - multicluster.crd.antrea.io apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE resources: - - resourceimports + - clusterclaims sideEffects: None - admissionReviewVersions: - v1 diff --git a/multicluster/build/yamls/antrea-multicluster-member.yml b/multicluster/build/yamls/antrea-multicluster-member.yml index 91b124fb4bc..84342a01cb6 100644 --- a/multicluster/build/yamls/antrea-multicluster-member.yml +++ b/multicluster/build/yamls/antrea-multicluster-member.yml @@ -16,7 +16,7 @@ spec: singular: clusterclaim scope: Namespaced versions: - - name: v1alpha1 + - name: v1alpha2 schema: openAPIV3Schema: description: ClusterClaim is the Schema for the clusterclaims API @@ -33,15 +33,14 @@ spec: type: string metadata: type: object - name: - description: Name of the ClusterClaim. - type: string value: description: Value of the ClusterClaim. type: string type: object served: true storage: true + subresources: + status: {} status: acceptedNames: kind: "" @@ -1025,7 +1024,7 @@ webhooks: service: name: antrea-mc-webhook-service namespace: kube-system - path: /mutate-multicluster-crd-antrea-io-v1alpha1-clusterclaim + path: /mutate-multicluster-crd-antrea-io-v1alpha2-clusterclaim failurePolicy: Fail name: mclusterclaim.kb.io namespaceSelector: @@ -1035,7 +1034,7 @@ webhooks: - apiGroups: - multicluster.crd.antrea.io apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE @@ -1081,7 +1080,7 @@ webhooks: service: name: antrea-mc-webhook-service namespace: kube-system - path: /validate-multicluster-crd-antrea-io-v1alpha1-clusterclaim + path: /validate-multicluster-crd-antrea-io-v1alpha2-clusterclaim failurePolicy: Fail name: vclusterclaim.kb.io namespaceSelector: @@ -1091,7 +1090,7 @@ webhooks: - apiGroups: - multicluster.crd.antrea.io apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE diff --git a/multicluster/cmd/multicluster-controller/controller.go b/multicluster/cmd/multicluster-controller/controller.go index c3dbaab2ab8..04805fafc6d 100644 --- a/multicluster/cmd/multicluster-controller/controller.go +++ b/multicluster/cmd/multicluster-controller/controller.go @@ -39,6 +39,7 @@ import ( k8smcsv1alpha1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" multiclustercontrollers "antrea.io/antrea/multicluster/controllers/multicluster" antreacrd "antrea.io/antrea/pkg/apis/crd/v1alpha1" "antrea.io/antrea/pkg/apiserver/certificate" @@ -61,6 +62,7 @@ func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(k8smcsv1alpha1.AddToScheme(scheme)) utilruntime.Must(multiclusterv1alpha1.AddToScheme(scheme)) + utilruntime.Must(multiclusterv1alpha2.AddToScheme(scheme)) utilruntime.Must(antreacrd.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -155,7 +157,7 @@ func setupManagerAndCertController(o *Options) (manager.Manager, error) { }).SetupWithManager(mgr); err != nil { return nil, fmt.Errorf("error creating ClusterClaim controller: %v", err) } - if err = (&multiclusterv1alpha1.ClusterClaim{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&multiclusterv1alpha2.ClusterClaim{}).SetupWebhookWithManager(mgr); err != nil { return nil, fmt.Errorf("error create ClusterClaim webhook: %v", err) } diff --git a/multicluster/config/crd/bases/multicluster.crd.antrea.io_clusterclaims.yaml b/multicluster/config/crd/bases/multicluster.crd.antrea.io_clusterclaims.yaml index 2002afad021..ad8fd3c995e 100644 --- a/multicluster/config/crd/bases/multicluster.crd.antrea.io_clusterclaims.yaml +++ b/multicluster/config/crd/bases/multicluster.crd.antrea.io_clusterclaims.yaml @@ -16,7 +16,7 @@ spec: singular: clusterclaim scope: Namespaced versions: - - name: v1alpha1 + - name: v1alpha2 schema: openAPIV3Schema: description: ClusterClaim is the Schema for the clusterclaims API @@ -33,15 +33,14 @@ spec: type: string metadata: type: object - name: - description: Name of the ClusterClaim. - type: string value: description: Value of the ClusterClaim. type: string type: object served: true storage: true + subresources: + status: {} status: acceptedNames: kind: "" diff --git a/multicluster/config/crd/patches/cainjection_in_clusterclaims.yaml b/multicluster/config/crd/patches/cainjection_in_clusterclaims.yaml new file mode 100644 index 00000000000..1620b8dad8c --- /dev/null +++ b/multicluster/config/crd/patches/cainjection_in_clusterclaims.yaml @@ -0,0 +1,7 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: clusterclaims.multicluster.crd.antrea.io diff --git a/multicluster/config/samples/multicluster_v1alpha1_clusterclaim.yaml b/multicluster/config/samples/multicluster_v1alpha1_clusterclaim.yaml deleted file mode 100644 index 238a0fd3395..00000000000 --- a/multicluster/config/samples/multicluster_v1alpha1_clusterclaim.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: multicluster.crd.antrea.io/v1alpha1 -kind: ClusterClaim -metadata: - name: west-membercluster-id - namespace: default -name: id.k8s.io -value: test-cluster-west ---- -apiVersion: multicluster.crd.antrea.io/v1alpha1 -kind: ClusterClaim -metadata: - name: clusterset-id - namespace: default -name: clusterset.k8s.io -value: test-clusterset diff --git a/multicluster/config/samples/multicluster_v1alpha2_clusterclaim.yaml b/multicluster/config/samples/multicluster_v1alpha2_clusterclaim.yaml new file mode 100644 index 00000000000..9af84342f61 --- /dev/null +++ b/multicluster/config/samples/multicluster_v1alpha2_clusterclaim.yaml @@ -0,0 +1,13 @@ +apiVersion: multicluster.crd.antrea.io/v1alpha2 +kind: ClusterClaim +metadata: + name: id.k8s.io + namespace: default +value: test-cluster-west +--- +apiVersion: multicluster.crd.antrea.io/v1alpha2 +kind: ClusterClaim +metadata: + name: clusterset.k8s.io + namespace: default +value: test-clusterset diff --git a/multicluster/config/webhook/manifests.yaml b/multicluster/config/webhook/manifests.yaml index c6cd4bbb108..618fa9ccf53 100644 --- a/multicluster/config/webhook/manifests.yaml +++ b/multicluster/config/webhook/manifests.yaml @@ -13,14 +13,14 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-multicluster-crd-antrea-io-v1alpha1-clusterclaim + path: /mutate-multicluster-crd-antrea-io-v1alpha2-clusterclaim failurePolicy: Fail name: mclusterclaim.kb.io rules: - apiGroups: - multicluster.crd.antrea.io apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE @@ -105,14 +105,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-multicluster-crd-antrea-io-v1alpha1-clusterclaim + path: /validate-multicluster-crd-antrea-io-v1alpha2-clusterclaim failurePolicy: Fail name: vclusterclaim.kb.io rules: - apiGroups: - multicluster.crd.antrea.io apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE diff --git a/multicluster/controllers/multicluster/clusterclaim_controller.go b/multicluster/controllers/multicluster/clusterclaim_controller.go index f00238405fd..f7945708573 100644 --- a/multicluster/controllers/multicluster/clusterclaim_controller.go +++ b/multicluster/controllers/multicluster/clusterclaim_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" ) // ClusterClaimReconciler reconciles a ClusterClaim object @@ -45,11 +45,11 @@ type ClusterClaimReconciler struct { // the user. // // For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.8.3/pkg/reconcile +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.0/pkg/reconcile func (r *ClusterClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { _ = log.FromContext(ctx) - // your logic here + // TODO(user): your logic here return ctrl.Result{}, nil } @@ -57,6 +57,6 @@ func (r *ClusterClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request // SetupWithManager sets up the controller with the Manager. func (r *ClusterClaimReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&multiclusterv1alpha1.ClusterClaim{}). + For(&multiclusterv1alpha2.ClusterClaim{}). Complete(r) } diff --git a/multicluster/controllers/multicluster/controller_utils.go b/multicluster/controllers/multicluster/controller_utils.go old mode 100644 new mode 100755 index e421da37d53..b15f8af3567 --- a/multicluster/controllers/multicluster/controller_utils.go +++ b/multicluster/controllers/multicluster/controller_utils.go @@ -26,13 +26,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" "antrea.io/antrea/multicluster/controllers/multicluster/common" ) func validateLocalClusterClaim(c client.Client, clusterSet *multiclusterv1alpha1.ClusterSet) (clusterID common.ClusterID, clusterSetID common.ClusterSetID, err error) { configNamespace := clusterSet.GetNamespace() - clusterClaimList := &multiclusterv1alpha1.ClusterClaimList{} + clusterClaimList := &multiclusterv1alpha2.ClusterClaimList{} klog.InfoS("Validating cluster claim in", "Namespace", configNamespace) if err = c.List(context.TODO(), clusterClaimList, client.InNamespace(configNamespace)); err != nil { return @@ -46,10 +47,10 @@ func validateLocalClusterClaim(c client.Client, clusterSet *multiclusterv1alpha1 wellKnownClusterClaimIDExist := false for _, clusterClaim := range clusterClaimList.Items { klog.InfoS("Processing ClusterClaim", "Name", clusterClaim.Name, "Value", clusterClaim.Value) - if clusterClaim.Name == multiclusterv1alpha1.WellKnownClusterClaimClusterSet { + if clusterClaim.Name == multiclusterv1alpha2.WellKnownClusterClaimClusterSet { wellKnownClusterSetClaimIDExist = true clusterSetID = common.ClusterSetID(clusterClaim.Value) - } else if clusterClaim.Name == multiclusterv1alpha1.WellKnownClusterClaimID { + } else if clusterClaim.Name == multiclusterv1alpha2.WellKnownClusterClaimID { wellKnownClusterClaimIDExist = true clusterID = common.ClusterID(clusterClaim.Value) } @@ -57,19 +58,19 @@ func validateLocalClusterClaim(c client.Client, clusterSet *multiclusterv1alpha1 if !wellKnownClusterSetClaimIDExist { err = fmt.Errorf("ClusterClaim not configured for Name=%s", - multiclusterv1alpha1.WellKnownClusterClaimClusterSet) + multiclusterv1alpha2.WellKnownClusterClaimClusterSet) return } if !wellKnownClusterClaimIDExist { err = fmt.Errorf("ClusterClaim not configured for Name=%s", - multiclusterv1alpha1.WellKnownClusterClaimID) + multiclusterv1alpha2.WellKnownClusterClaimID) return } if clusterSet.Name != string(clusterSetID) { err = fmt.Errorf("ClusterSet Name=%s is not same as ClusterClaim Value=%s for Name=%s", - clusterSet.Name, clusterSetID, multiclusterv1alpha1.WellKnownClusterClaimClusterSet) + clusterSet.Name, clusterSetID, multiclusterv1alpha2.WellKnownClusterClaimClusterSet) return } diff --git a/multicluster/controllers/multicluster/leader_clusterset_controller_test.go b/multicluster/controllers/multicluster/leader_clusterset_controller_test.go index 735cdac93d3..504df969e35 100644 --- a/multicluster/controllers/multicluster/leader_clusterset_controller_test.go +++ b/multicluster/controllers/multicluster/leader_clusterset_controller_test.go @@ -31,6 +31,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" mcsv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + mcsv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" "antrea.io/antrea/multicluster/controllers/multicluster/common" ) @@ -65,22 +66,20 @@ func TestLeaderClusterSetAdd(t *testing.T) { Namespace: "mcs1", }, } - existingClusterClaimList := &mcsv1alpha1.ClusterClaimList{ - Items: []mcsv1alpha1.ClusterClaim{ + existingClusterClaimList := &mcsv1alpha2.ClusterClaimList{ + Items: []mcsv1alpha2.ClusterClaim{ { ObjectMeta: metav1.ObjectMeta{ - Name: "clustersetid", + Name: mcsv1alpha2.WellKnownClusterClaimClusterSet, Namespace: "mcs1", }, - Name: mcsv1alpha1.WellKnownClusterClaimClusterSet, Value: "clusterset1", }, { ObjectMeta: metav1.ObjectMeta{ - Name: "clusterid", + Name: mcsv1alpha2.WellKnownClusterClaimID, Namespace: "mcs1", }, - Name: mcsv1alpha1.WellKnownClusterClaimID, Value: "leader1", }, }, @@ -88,6 +87,7 @@ func TestLeaderClusterSetAdd(t *testing.T) { scheme := runtime.NewScheme() mcsv1alpha1.AddToScheme(scheme) + mcsv1alpha2.AddToScheme(scheme) fakeRemoteClient = fake.NewClientBuilder().WithScheme(scheme). WithObjects(existingClusterSet, &existingClusterClaimList.Items[0], &existingClusterClaimList.Items[1]). Build() diff --git a/multicluster/controllers/multicluster/memberclusterannounce_controller.go b/multicluster/controllers/multicluster/memberclusterannounce_controller.go index 208f345043f..d619e97c49e 100644 --- a/multicluster/controllers/multicluster/memberclusterannounce_controller.go +++ b/multicluster/controllers/multicluster/memberclusterannounce_controller.go @@ -32,6 +32,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" "antrea.io/antrea/multicluster/controllers/multicluster/common" ) @@ -123,10 +124,10 @@ func (r *MemberClusterAnnounceReconciler) Reconcile(ctx context.Context, req ctr memberAnnounce.ClusterID) data.leaderStatus.reason = ReasonNotElectedLeader // Check whether this local cluster is the leader for this member. - clusterClaimList := &multiclusterv1alpha1.ClusterClaimList{} + clusterClaimList := &multiclusterv1alpha2.ClusterClaimList{} if err := r.List(context.TODO(), clusterClaimList, client.InNamespace(req.Namespace)); err == nil { for _, clusterClaim := range clusterClaimList.Items { - if clusterClaim.Name == multiclusterv1alpha1.WellKnownClusterClaimID && + if clusterClaim.Name == multiclusterv1alpha2.WellKnownClusterClaimID && clusterClaim.Value == memberAnnounce.LeaderClusterID { data.leaderStatus.electedLocalAsLeaderCluster = v1.ConditionTrue data.leaderStatus.message = fmt.Sprintf("Local cluster is the elected leader of member: %v", diff --git a/multicluster/controllers/multicluster/memberclusterannounce_controller_test.go b/multicluster/controllers/multicluster/memberclusterannounce_controller_test.go index 44c144d1694..3bcc0a5a53e 100644 --- a/multicluster/controllers/multicluster/memberclusterannounce_controller_test.go +++ b/multicluster/controllers/multicluster/memberclusterannounce_controller_test.go @@ -28,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" mcsv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + mcsv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" ) var ( @@ -60,22 +61,20 @@ func setup() { Namespace: "mcs1", }, } - existingClusterClaimList := &mcsv1alpha1.ClusterClaimList{ - Items: []mcsv1alpha1.ClusterClaim{ + existingClusterClaimList := &mcsv1alpha2.ClusterClaimList{ + Items: []mcsv1alpha2.ClusterClaim{ { ObjectMeta: metav1.ObjectMeta{ - Name: "clustersetid", + Name: mcsv1alpha2.WellKnownClusterClaimClusterSet, Namespace: "mcs1", }, - Name: mcsv1alpha1.WellKnownClusterClaimClusterSet, Value: "clusterset1", }, { ObjectMeta: metav1.ObjectMeta{ - Name: "clusterid", + Name: mcsv1alpha2.WellKnownClusterClaimID, Namespace: "mcs1", }, - Name: mcsv1alpha1.WellKnownClusterClaimID, Value: "leader1", }, }, @@ -83,6 +82,7 @@ func setup() { scheme := runtime.NewScheme() mcsv1alpha1.AddToScheme(scheme) + mcsv1alpha2.AddToScheme(scheme) mcaTestFakeRemoteClient = fake.NewClientBuilder().WithScheme(scheme). WithObjects(existingClusterSet, &existingClusterClaimList.Items[0], &existingClusterClaimList.Items[1]). Build() diff --git a/multicluster/hack/update-codegen-dockerized.sh b/multicluster/hack/update-codegen-dockerized.sh index 939bbf74787..bd1d83f0e7e 100755 --- a/multicluster/hack/update-codegen-dockerized.sh +++ b/multicluster/hack/update-codegen-dockerized.sh @@ -28,12 +28,14 @@ $GOPATH/bin/client-gen \ --clientset-name versioned \ --input-base "${ANTREA_PKG}/multicluster/apis" \ --input "multicluster/v1alpha1" \ + --input "multicluster/v1alpha2" \ --output-package "${ANTREA_PKG}/multicluster/pkg/client/clientset" \ --go-header-file hack/boilerplate.go.txt # Generate listers with K8s codegen tools. $GOPATH/bin/lister-gen \ --input-dirs "${ANTREA_PKG}/multicluster/apis/multicluster/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/multicluster/apis/multicluster/v1alpha2" \ --output-package "${ANTREA_PKG}/multicluster/pkg/client/listers" \ --go-header-file hack/boilerplate.go.txt @@ -41,6 +43,7 @@ $GOPATH/bin/lister-gen \ # Generate informers with K8s codegen tools. $GOPATH/bin/informer-gen \ --input-dirs "${ANTREA_PKG}/multicluster/apis/multicluster/v1alpha1" \ + --input-dirs "${ANTREA_PKG}/multicluster/apis/multicluster/v1alpha2" \ --versioned-clientset-package "${ANTREA_PKG}/multicluster/pkg/client/clientset/versioned" \ --listers-package "${ANTREA_PKG}/multicluster/pkg/client/listers" \ --output-package "${ANTREA_PKG}/multicluster/pkg/client/informers" \ diff --git a/multicluster/pkg/client/clientset/versioned/clientset.go b/multicluster/pkg/client/clientset/versioned/clientset.go index f0e2c32ab2d..60fe9251130 100644 --- a/multicluster/pkg/client/clientset/versioned/clientset.go +++ b/multicluster/pkg/client/clientset/versioned/clientset.go @@ -22,6 +22,7 @@ import ( "net/http" multiclusterv1alpha1 "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -30,6 +31,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface MulticlusterV1alpha1() multiclusterv1alpha1.MulticlusterV1alpha1Interface + MulticlusterV1alpha2() multiclusterv1alpha2.MulticlusterV1alpha2Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -37,6 +39,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient multiclusterV1alpha1 *multiclusterv1alpha1.MulticlusterV1alpha1Client + multiclusterV1alpha2 *multiclusterv1alpha2.MulticlusterV1alpha2Client } // MulticlusterV1alpha1 retrieves the MulticlusterV1alpha1Client @@ -44,6 +47,11 @@ func (c *Clientset) MulticlusterV1alpha1() multiclusterv1alpha1.MulticlusterV1al return c.multiclusterV1alpha1 } +// MulticlusterV1alpha2 retrieves the MulticlusterV1alpha2Client +func (c *Clientset) MulticlusterV1alpha2() multiclusterv1alpha2.MulticlusterV1alpha2Interface { + return c.multiclusterV1alpha2 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -92,6 +100,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.multiclusterV1alpha2, err = multiclusterv1alpha2.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -114,6 +126,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.multiclusterV1alpha1 = multiclusterv1alpha1.New(c) + cs.multiclusterV1alpha2 = multiclusterv1alpha2.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/multicluster/pkg/client/clientset/versioned/fake/clientset_generated.go b/multicluster/pkg/client/clientset/versioned/fake/clientset_generated.go index 5b65267ec52..d816cdd36bc 100644 --- a/multicluster/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/multicluster/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -21,6 +21,8 @@ import ( clientset "antrea.io/antrea/multicluster/pkg/client/clientset/versioned" multiclusterv1alpha1 "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1" fakemulticlusterv1alpha1 "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2" + fakemulticlusterv1alpha2 "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -82,3 +84,8 @@ var ( func (c *Clientset) MulticlusterV1alpha1() multiclusterv1alpha1.MulticlusterV1alpha1Interface { return &fakemulticlusterv1alpha1.FakeMulticlusterV1alpha1{Fake: &c.Fake} } + +// MulticlusterV1alpha2 retrieves the MulticlusterV1alpha2Client +func (c *Clientset) MulticlusterV1alpha2() multiclusterv1alpha2.MulticlusterV1alpha2Interface { + return &fakemulticlusterv1alpha2.FakeMulticlusterV1alpha2{Fake: &c.Fake} +} diff --git a/multicluster/pkg/client/clientset/versioned/fake/register.go b/multicluster/pkg/client/clientset/versioned/fake/register.go index afa5a6d50b8..b79a66c682e 100644 --- a/multicluster/pkg/client/clientset/versioned/fake/register.go +++ b/multicluster/pkg/client/clientset/versioned/fake/register.go @@ -19,6 +19,7 @@ package fake import ( multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,6 +32,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ multiclusterv1alpha1.AddToScheme, + multiclusterv1alpha2.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/multicluster/pkg/client/clientset/versioned/scheme/register.go b/multicluster/pkg/client/clientset/versioned/scheme/register.go index 65c0a88a2bd..b90d76ffc8c 100644 --- a/multicluster/pkg/client/clientset/versioned/scheme/register.go +++ b/multicluster/pkg/client/clientset/versioned/scheme/register.go @@ -19,6 +19,7 @@ package scheme import ( multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,6 +32,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ multiclusterv1alpha1.AddToScheme, + multiclusterv1alpha2.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake/fake_multicluster_client.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake/fake_multicluster_client.go index 16872637200..147911c4ab5 100644 --- a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake/fake_multicluster_client.go +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake/fake_multicluster_client.go @@ -27,10 +27,6 @@ type FakeMulticlusterV1alpha1 struct { *testing.Fake } -func (c *FakeMulticlusterV1alpha1) ClusterClaims(namespace string) v1alpha1.ClusterClaimInterface { - return &FakeClusterClaims{c, namespace} -} - func (c *FakeMulticlusterV1alpha1) ClusterInfoImports(namespace string) v1alpha1.ClusterInfoImportInterface { return &FakeClusterInfoImports{c, namespace} } diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/generated_expansion.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/generated_expansion.go index aa4239ec1e7..54488bceeca 100644 --- a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/generated_expansion.go +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/generated_expansion.go @@ -17,8 +17,6 @@ limitations under the License. package v1alpha1 -type ClusterClaimExpansion interface{} - type ClusterInfoImportExpansion interface{} type ClusterSetExpansion interface{} diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/multicluster_client.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/multicluster_client.go index 22c466f5ffe..f05f08f284c 100644 --- a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/multicluster_client.go +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/multicluster_client.go @@ -27,7 +27,6 @@ import ( type MulticlusterV1alpha1Interface interface { RESTClient() rest.Interface - ClusterClaimsGetter ClusterInfoImportsGetter ClusterSetsGetter GatewaysGetter @@ -41,10 +40,6 @@ type MulticlusterV1alpha1Client struct { restClient rest.Interface } -func (c *MulticlusterV1alpha1Client) ClusterClaims(namespace string) ClusterClaimInterface { - return newClusterClaims(c, namespace) -} - func (c *MulticlusterV1alpha1Client) ClusterInfoImports(namespace string) ClusterInfoImportInterface { return newClusterInfoImports(c, namespace) } diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/clusterclaim.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/clusterclaim.go similarity index 83% rename from multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/clusterclaim.go rename to multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/clusterclaim.go index 14df10da7c7..6fce642c11e 100644 --- a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/clusterclaim.go +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/clusterclaim.go @@ -15,13 +15,13 @@ limitations under the License. */ // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1alpha2 import ( "context" "time" - v1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + v1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" scheme "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,14 +37,14 @@ type ClusterClaimsGetter interface { // ClusterClaimInterface has methods to work with ClusterClaim resources. type ClusterClaimInterface interface { - Create(ctx context.Context, clusterClaim *v1alpha1.ClusterClaim, opts v1.CreateOptions) (*v1alpha1.ClusterClaim, error) - Update(ctx context.Context, clusterClaim *v1alpha1.ClusterClaim, opts v1.UpdateOptions) (*v1alpha1.ClusterClaim, error) + Create(ctx context.Context, clusterClaim *v1alpha2.ClusterClaim, opts v1.CreateOptions) (*v1alpha2.ClusterClaim, error) + Update(ctx context.Context, clusterClaim *v1alpha2.ClusterClaim, opts v1.UpdateOptions) (*v1alpha2.ClusterClaim, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ClusterClaim, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterClaimList, error) + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.ClusterClaim, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ClusterClaimList, error) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterClaim, err error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterClaim, err error) ClusterClaimExpansion } @@ -55,7 +55,7 @@ type clusterClaims struct { } // newClusterClaims returns a ClusterClaims -func newClusterClaims(c *MulticlusterV1alpha1Client, namespace string) *clusterClaims { +func newClusterClaims(c *MulticlusterV1alpha2Client, namespace string) *clusterClaims { return &clusterClaims{ client: c.RESTClient(), ns: namespace, @@ -63,8 +63,8 @@ func newClusterClaims(c *MulticlusterV1alpha1Client, namespace string) *clusterC } // Get takes name of the clusterClaim, and returns the corresponding clusterClaim object, and an error if there is any. -func (c *clusterClaims) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterClaim, err error) { - result = &v1alpha1.ClusterClaim{} +func (c *clusterClaims) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ClusterClaim, err error) { + result = &v1alpha2.ClusterClaim{} err = c.client.Get(). Namespace(c.ns). Resource("clusterclaims"). @@ -76,12 +76,12 @@ func (c *clusterClaims) Get(ctx context.Context, name string, options v1.GetOpti } // List takes label and field selectors, and returns the list of ClusterClaims that match those selectors. -func (c *clusterClaims) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterClaimList, err error) { +func (c *clusterClaims) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ClusterClaimList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.ClusterClaimList{} + result = &v1alpha2.ClusterClaimList{} err = c.client.Get(). Namespace(c.ns). Resource("clusterclaims"). @@ -108,8 +108,8 @@ func (c *clusterClaims) Watch(ctx context.Context, opts v1.ListOptions) (watch.I } // Create takes the representation of a clusterClaim and creates it. Returns the server's representation of the clusterClaim, and an error, if there is any. -func (c *clusterClaims) Create(ctx context.Context, clusterClaim *v1alpha1.ClusterClaim, opts v1.CreateOptions) (result *v1alpha1.ClusterClaim, err error) { - result = &v1alpha1.ClusterClaim{} +func (c *clusterClaims) Create(ctx context.Context, clusterClaim *v1alpha2.ClusterClaim, opts v1.CreateOptions) (result *v1alpha2.ClusterClaim, err error) { + result = &v1alpha2.ClusterClaim{} err = c.client.Post(). Namespace(c.ns). Resource("clusterclaims"). @@ -121,8 +121,8 @@ func (c *clusterClaims) Create(ctx context.Context, clusterClaim *v1alpha1.Clust } // Update takes the representation of a clusterClaim and updates it. Returns the server's representation of the clusterClaim, and an error, if there is any. -func (c *clusterClaims) Update(ctx context.Context, clusterClaim *v1alpha1.ClusterClaim, opts v1.UpdateOptions) (result *v1alpha1.ClusterClaim, err error) { - result = &v1alpha1.ClusterClaim{} +func (c *clusterClaims) Update(ctx context.Context, clusterClaim *v1alpha2.ClusterClaim, opts v1.UpdateOptions) (result *v1alpha2.ClusterClaim, err error) { + result = &v1alpha2.ClusterClaim{} err = c.client.Put(). Namespace(c.ns). Resource("clusterclaims"). @@ -162,8 +162,8 @@ func (c *clusterClaims) DeleteCollection(ctx context.Context, opts v1.DeleteOpti } // Patch applies the patch and returns the patched clusterClaim. -func (c *clusterClaims) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterClaim, err error) { - result = &v1alpha1.ClusterClaim{} +func (c *clusterClaims) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterClaim, err error) { + result = &v1alpha2.ClusterClaim{} err = c.client.Patch(pt). Namespace(c.ns). Resource("clusterclaims"). diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/doc.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/doc.go new file mode 100644 index 00000000000..08302bab378 --- /dev/null +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha2 diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/doc.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/doc.go new file mode 100644 index 00000000000..02265d1ca8d --- /dev/null +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake/fake_clusterclaim.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/fake_clusterclaim.go similarity index 75% rename from multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake/fake_clusterclaim.go rename to multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/fake_clusterclaim.go index b9badd55a6e..1f57d3b1541 100644 --- a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake/fake_clusterclaim.go +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/fake_clusterclaim.go @@ -20,7 +20,7 @@ package fake import ( "context" - v1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + v1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,29 +31,29 @@ import ( // FakeClusterClaims implements ClusterClaimInterface type FakeClusterClaims struct { - Fake *FakeMulticlusterV1alpha1 + Fake *FakeMulticlusterV1alpha2 ns string } -var clusterclaimsResource = schema.GroupVersionResource{Group: "multicluster.crd.antrea.io", Version: "v1alpha1", Resource: "clusterclaims"} +var clusterclaimsResource = schema.GroupVersionResource{Group: "multicluster.crd.antrea.io", Version: "v1alpha2", Resource: "clusterclaims"} -var clusterclaimsKind = schema.GroupVersionKind{Group: "multicluster.crd.antrea.io", Version: "v1alpha1", Kind: "ClusterClaim"} +var clusterclaimsKind = schema.GroupVersionKind{Group: "multicluster.crd.antrea.io", Version: "v1alpha2", Kind: "ClusterClaim"} // Get takes name of the clusterClaim, and returns the corresponding clusterClaim object, and an error if there is any. -func (c *FakeClusterClaims) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterClaim, err error) { +func (c *FakeClusterClaims) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ClusterClaim, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(clusterclaimsResource, c.ns, name), &v1alpha1.ClusterClaim{}) + Invokes(testing.NewGetAction(clusterclaimsResource, c.ns, name), &v1alpha2.ClusterClaim{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.ClusterClaim), err + return obj.(*v1alpha2.ClusterClaim), err } // List takes label and field selectors, and returns the list of ClusterClaims that match those selectors. -func (c *FakeClusterClaims) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterClaimList, err error) { +func (c *FakeClusterClaims) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ClusterClaimList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(clusterclaimsResource, clusterclaimsKind, c.ns, opts), &v1alpha1.ClusterClaimList{}) + Invokes(testing.NewListAction(clusterclaimsResource, clusterclaimsKind, c.ns, opts), &v1alpha2.ClusterClaimList{}) if obj == nil { return nil, err @@ -63,8 +63,8 @@ func (c *FakeClusterClaims) List(ctx context.Context, opts v1.ListOptions) (resu if label == nil { label = labels.Everything() } - list := &v1alpha1.ClusterClaimList{ListMeta: obj.(*v1alpha1.ClusterClaimList).ListMeta} - for _, item := range obj.(*v1alpha1.ClusterClaimList).Items { + list := &v1alpha2.ClusterClaimList{ListMeta: obj.(*v1alpha2.ClusterClaimList).ListMeta} + for _, item := range obj.(*v1alpha2.ClusterClaimList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -80,31 +80,31 @@ func (c *FakeClusterClaims) Watch(ctx context.Context, opts v1.ListOptions) (wat } // Create takes the representation of a clusterClaim and creates it. Returns the server's representation of the clusterClaim, and an error, if there is any. -func (c *FakeClusterClaims) Create(ctx context.Context, clusterClaim *v1alpha1.ClusterClaim, opts v1.CreateOptions) (result *v1alpha1.ClusterClaim, err error) { +func (c *FakeClusterClaims) Create(ctx context.Context, clusterClaim *v1alpha2.ClusterClaim, opts v1.CreateOptions) (result *v1alpha2.ClusterClaim, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(clusterclaimsResource, c.ns, clusterClaim), &v1alpha1.ClusterClaim{}) + Invokes(testing.NewCreateAction(clusterclaimsResource, c.ns, clusterClaim), &v1alpha2.ClusterClaim{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.ClusterClaim), err + return obj.(*v1alpha2.ClusterClaim), err } // Update takes the representation of a clusterClaim and updates it. Returns the server's representation of the clusterClaim, and an error, if there is any. -func (c *FakeClusterClaims) Update(ctx context.Context, clusterClaim *v1alpha1.ClusterClaim, opts v1.UpdateOptions) (result *v1alpha1.ClusterClaim, err error) { +func (c *FakeClusterClaims) Update(ctx context.Context, clusterClaim *v1alpha2.ClusterClaim, opts v1.UpdateOptions) (result *v1alpha2.ClusterClaim, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(clusterclaimsResource, c.ns, clusterClaim), &v1alpha1.ClusterClaim{}) + Invokes(testing.NewUpdateAction(clusterclaimsResource, c.ns, clusterClaim), &v1alpha2.ClusterClaim{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.ClusterClaim), err + return obj.(*v1alpha2.ClusterClaim), err } // Delete takes name of the clusterClaim and deletes it. Returns an error if one occurs. func (c *FakeClusterClaims) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(clusterclaimsResource, c.ns, name, opts), &v1alpha1.ClusterClaim{}) + Invokes(testing.NewDeleteActionWithOptions(clusterclaimsResource, c.ns, name, opts), &v1alpha2.ClusterClaim{}) return err } @@ -113,17 +113,17 @@ func (c *FakeClusterClaims) Delete(ctx context.Context, name string, opts v1.Del func (c *FakeClusterClaims) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { action := testing.NewDeleteCollectionAction(clusterclaimsResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &v1alpha1.ClusterClaimList{}) + _, err := c.Fake.Invokes(action, &v1alpha2.ClusterClaimList{}) return err } // Patch applies the patch and returns the patched clusterClaim. -func (c *FakeClusterClaims) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterClaim, err error) { +func (c *FakeClusterClaims) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterClaim, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(clusterclaimsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ClusterClaim{}) + Invokes(testing.NewPatchSubresourceAction(clusterclaimsResource, c.ns, name, pt, data, subresources...), &v1alpha2.ClusterClaim{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.ClusterClaim), err + return obj.(*v1alpha2.ClusterClaim), err } diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/fake_multicluster_client.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/fake_multicluster_client.go new file mode 100644 index 00000000000..9315822e8ae --- /dev/null +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/fake/fake_multicluster_client.go @@ -0,0 +1,39 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha2 "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeMulticlusterV1alpha2 struct { + *testing.Fake +} + +func (c *FakeMulticlusterV1alpha2) ClusterClaims(namespace string) v1alpha2.ClusterClaimInterface { + return &FakeClusterClaims{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeMulticlusterV1alpha2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/generated_expansion.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/generated_expansion.go new file mode 100644 index 00000000000..36802d6437b --- /dev/null +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/generated_expansion.go @@ -0,0 +1,20 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +type ClusterClaimExpansion interface{} diff --git a/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/multicluster_client.go b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/multicluster_client.go new file mode 100644 index 00000000000..98cfe576c11 --- /dev/null +++ b/multicluster/pkg/client/clientset/versioned/typed/multicluster/v1alpha2/multicluster_client.go @@ -0,0 +1,106 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "net/http" + + v1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" + "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type MulticlusterV1alpha2Interface interface { + RESTClient() rest.Interface + ClusterClaimsGetter +} + +// MulticlusterV1alpha2Client is used to interact with features provided by the multicluster.crd.antrea.io group. +type MulticlusterV1alpha2Client struct { + restClient rest.Interface +} + +func (c *MulticlusterV1alpha2Client) ClusterClaims(namespace string) ClusterClaimInterface { + return newClusterClaims(c, namespace) +} + +// NewForConfig creates a new MulticlusterV1alpha2Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*MulticlusterV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new MulticlusterV1alpha2Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*MulticlusterV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &MulticlusterV1alpha2Client{client}, nil +} + +// NewForConfigOrDie creates a new MulticlusterV1alpha2Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *MulticlusterV1alpha2Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new MulticlusterV1alpha2Client for the given RESTClient. +func New(c rest.Interface) *MulticlusterV1alpha2Client { + return &MulticlusterV1alpha2Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *MulticlusterV1alpha2Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/multicluster/pkg/client/informers/externalversions/generic.go b/multicluster/pkg/client/informers/externalversions/generic.go index a67798d3696..fc57a50872a 100644 --- a/multicluster/pkg/client/informers/externalversions/generic.go +++ b/multicluster/pkg/client/informers/externalversions/generic.go @@ -21,6 +21,7 @@ import ( "fmt" v1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + v1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,8 +53,6 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=multicluster.crd.antrea.io, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("clusterclaims"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Multicluster().V1alpha1().ClusterClaims().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusterinfoimports"): return &genericInformer{resource: resource.GroupResource(), informer: f.Multicluster().V1alpha1().ClusterInfoImports().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clustersets"): @@ -67,6 +66,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("resourceimports"): return &genericInformer{resource: resource.GroupResource(), informer: f.Multicluster().V1alpha1().ResourceImports().Informer()}, nil + // Group=multicluster.crd.antrea.io, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithResource("clusterclaims"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Multicluster().V1alpha2().ClusterClaims().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/multicluster/pkg/client/informers/externalversions/multicluster/interface.go b/multicluster/pkg/client/informers/externalversions/multicluster/interface.go index 58b723c24b9..6f715c51dee 100644 --- a/multicluster/pkg/client/informers/externalversions/multicluster/interface.go +++ b/multicluster/pkg/client/informers/externalversions/multicluster/interface.go @@ -20,12 +20,15 @@ package multicluster import ( internalinterfaces "antrea.io/antrea/multicluster/pkg/client/informers/externalversions/internalinterfaces" v1alpha1 "antrea.io/antrea/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1" + v1alpha2 "antrea.io/antrea/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha2" ) // Interface provides access to each of this group's versions. type Interface interface { // V1alpha1 provides access to shared informers for resources in V1alpha1. V1alpha1() v1alpha1.Interface + // V1alpha2 provides access to shared informers for resources in V1alpha2. + V1alpha2() v1alpha2.Interface } type group struct { @@ -43,3 +46,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha1() v1alpha1.Interface { return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1alpha2 returns a new v1alpha2.Interface. +func (g *group) V1alpha2() v1alpha2.Interface { + return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1/interface.go b/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1/interface.go index 33229c1ff8a..d5c230e67cf 100644 --- a/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1/interface.go +++ b/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1/interface.go @@ -23,8 +23,6 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // ClusterClaims returns a ClusterClaimInformer. - ClusterClaims() ClusterClaimInformer // ClusterInfoImports returns a ClusterInfoImportInformer. ClusterInfoImports() ClusterInfoImportInformer // ClusterSets returns a ClusterSetInformer. @@ -50,11 +48,6 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// ClusterClaims returns a ClusterClaimInformer. -func (v *version) ClusterClaims() ClusterClaimInformer { - return &clusterClaimInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // ClusterInfoImports returns a ClusterInfoImportInformer. func (v *version) ClusterInfoImports() ClusterInfoImportInformer { return &clusterInfoImportInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1/clusterclaim.go b/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha2/clusterclaim.go similarity index 84% rename from multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1/clusterclaim.go rename to multicluster/pkg/client/informers/externalversions/multicluster/v1alpha2/clusterclaim.go index 220a10605ed..aaffc6579db 100644 --- a/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha1/clusterclaim.go +++ b/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha2/clusterclaim.go @@ -15,16 +15,16 @@ limitations under the License. */ // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1alpha2 import ( "context" time "time" - multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" versioned "antrea.io/antrea/multicluster/pkg/client/clientset/versioned" internalinterfaces "antrea.io/antrea/multicluster/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "antrea.io/antrea/multicluster/pkg/client/listers/multicluster/v1alpha1" + v1alpha2 "antrea.io/antrea/multicluster/pkg/client/listers/multicluster/v1alpha2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,7 +35,7 @@ import ( // ClusterClaims. type ClusterClaimInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.ClusterClaimLister + Lister() v1alpha2.ClusterClaimLister } type clusterClaimInformer struct { @@ -61,16 +61,16 @@ func NewFilteredClusterClaimInformer(client versioned.Interface, namespace strin if tweakListOptions != nil { tweakListOptions(&options) } - return client.MulticlusterV1alpha1().ClusterClaims(namespace).List(context.TODO(), options) + return client.MulticlusterV1alpha2().ClusterClaims(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MulticlusterV1alpha1().ClusterClaims(namespace).Watch(context.TODO(), options) + return client.MulticlusterV1alpha2().ClusterClaims(namespace).Watch(context.TODO(), options) }, }, - &multiclusterv1alpha1.ClusterClaim{}, + &multiclusterv1alpha2.ClusterClaim{}, resyncPeriod, indexers, ) @@ -81,9 +81,9 @@ func (f *clusterClaimInformer) defaultInformer(client versioned.Interface, resyn } func (f *clusterClaimInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&multiclusterv1alpha1.ClusterClaim{}, f.defaultInformer) + return f.factory.InformerFor(&multiclusterv1alpha2.ClusterClaim{}, f.defaultInformer) } -func (f *clusterClaimInformer) Lister() v1alpha1.ClusterClaimLister { - return v1alpha1.NewClusterClaimLister(f.Informer().GetIndexer()) +func (f *clusterClaimInformer) Lister() v1alpha2.ClusterClaimLister { + return v1alpha2.NewClusterClaimLister(f.Informer().GetIndexer()) } diff --git a/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha2/interface.go b/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha2/interface.go new file mode 100644 index 00000000000..1833011e947 --- /dev/null +++ b/multicluster/pkg/client/informers/externalversions/multicluster/v1alpha2/interface.go @@ -0,0 +1,44 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + internalinterfaces "antrea.io/antrea/multicluster/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ClusterClaims returns a ClusterClaimInformer. + ClusterClaims() ClusterClaimInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// ClusterClaims returns a ClusterClaimInformer. +func (v *version) ClusterClaims() ClusterClaimInformer { + return &clusterClaimInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/multicluster/pkg/client/listers/multicluster/v1alpha1/expansion_generated.go b/multicluster/pkg/client/listers/multicluster/v1alpha1/expansion_generated.go index d44f48f9245..805d01c9462 100644 --- a/multicluster/pkg/client/listers/multicluster/v1alpha1/expansion_generated.go +++ b/multicluster/pkg/client/listers/multicluster/v1alpha1/expansion_generated.go @@ -17,14 +17,6 @@ limitations under the License. package v1alpha1 -// ClusterClaimListerExpansion allows custom methods to be added to -// ClusterClaimLister. -type ClusterClaimListerExpansion interface{} - -// ClusterClaimNamespaceListerExpansion allows custom methods to be added to -// ClusterClaimNamespaceLister. -type ClusterClaimNamespaceListerExpansion interface{} - // ClusterInfoImportListerExpansion allows custom methods to be added to // ClusterInfoImportLister. type ClusterInfoImportListerExpansion interface{} diff --git a/multicluster/pkg/client/listers/multicluster/v1alpha1/clusterclaim.go b/multicluster/pkg/client/listers/multicluster/v1alpha2/clusterclaim.go similarity index 83% rename from multicluster/pkg/client/listers/multicluster/v1alpha1/clusterclaim.go rename to multicluster/pkg/client/listers/multicluster/v1alpha2/clusterclaim.go index e69fa004365..597622a41e6 100644 --- a/multicluster/pkg/client/listers/multicluster/v1alpha1/clusterclaim.go +++ b/multicluster/pkg/client/listers/multicluster/v1alpha2/clusterclaim.go @@ -15,10 +15,10 @@ limitations under the License. */ // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1alpha2 import ( - v1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + v1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -29,7 +29,7 @@ import ( type ClusterClaimLister interface { // List lists all ClusterClaims in the indexer. // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.ClusterClaim, err error) + List(selector labels.Selector) (ret []*v1alpha2.ClusterClaim, err error) // ClusterClaims returns an object that can list and get ClusterClaims. ClusterClaims(namespace string) ClusterClaimNamespaceLister ClusterClaimListerExpansion @@ -46,9 +46,9 @@ func NewClusterClaimLister(indexer cache.Indexer) ClusterClaimLister { } // List lists all ClusterClaims in the indexer. -func (s *clusterClaimLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterClaim, err error) { +func (s *clusterClaimLister) List(selector labels.Selector) (ret []*v1alpha2.ClusterClaim, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ClusterClaim)) + ret = append(ret, m.(*v1alpha2.ClusterClaim)) }) return ret, err } @@ -63,10 +63,10 @@ func (s *clusterClaimLister) ClusterClaims(namespace string) ClusterClaimNamespa type ClusterClaimNamespaceLister interface { // List lists all ClusterClaims in the indexer for a given namespace. // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.ClusterClaim, err error) + List(selector labels.Selector) (ret []*v1alpha2.ClusterClaim, err error) // Get retrieves the ClusterClaim from the indexer for a given namespace and name. // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.ClusterClaim, error) + Get(name string) (*v1alpha2.ClusterClaim, error) ClusterClaimNamespaceListerExpansion } @@ -78,21 +78,21 @@ type clusterClaimNamespaceLister struct { } // List lists all ClusterClaims in the indexer for a given namespace. -func (s clusterClaimNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterClaim, err error) { +func (s clusterClaimNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.ClusterClaim, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ClusterClaim)) + ret = append(ret, m.(*v1alpha2.ClusterClaim)) }) return ret, err } // Get retrieves the ClusterClaim from the indexer for a given namespace and name. -func (s clusterClaimNamespaceLister) Get(name string) (*v1alpha1.ClusterClaim, error) { +func (s clusterClaimNamespaceLister) Get(name string) (*v1alpha2.ClusterClaim, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("clusterclaim"), name) + return nil, errors.NewNotFound(v1alpha2.Resource("clusterclaim"), name) } - return obj.(*v1alpha1.ClusterClaim), nil + return obj.(*v1alpha2.ClusterClaim), nil } diff --git a/multicluster/pkg/client/listers/multicluster/v1alpha2/expansion_generated.go b/multicluster/pkg/client/listers/multicluster/v1alpha2/expansion_generated.go new file mode 100644 index 00000000000..68d0347746d --- /dev/null +++ b/multicluster/pkg/client/listers/multicluster/v1alpha2/expansion_generated.go @@ -0,0 +1,26 @@ +/* +Copyright 2021 Antrea Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +// ClusterClaimListerExpansion allows custom methods to be added to +// ClusterClaimLister. +type ClusterClaimListerExpansion interface{} + +// ClusterClaimNamespaceListerExpansion allows custom methods to be added to +// ClusterClaimNamespaceLister. +type ClusterClaimNamespaceListerExpansion interface{} diff --git a/multicluster/test/integration/suite_test.go b/multicluster/test/integration/suite_test.go index 6d100522eb6..678884011c8 100644 --- a/multicluster/test/integration/suite_test.go +++ b/multicluster/test/integration/suite_test.go @@ -38,6 +38,7 @@ import ( mcsscheme "sigs.k8s.io/mcs-api/pkg/client/clientset/versioned/scheme" mcsv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + mcsv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" multiclustercontrollers "antrea.io/antrea/multicluster/controllers/multicluster" antreamcscheme "antrea.io/antrea/multicluster/pkg/client/clientset/versioned/scheme" antreascheme "antrea.io/antrea/pkg/client/clientset/versioned/scheme" @@ -188,20 +189,18 @@ var _ = BeforeSuite(func() { }, 60) func configureClusterSet() { - clusterIDClaim := &mcsv1alpha1.ClusterClaim{ + clusterIDClaim := &mcsv1alpha2.ClusterClaim{ ObjectMeta: metav1.ObjectMeta{ Namespace: LeaderNamespace, - Name: "local-cluster-id", + Name: "id.k8s.io", }, - Name: "id.k8s.io", Value: LocalClusterID, } - clusterSetIDClaim := &mcsv1alpha1.ClusterClaim{ + clusterSetIDClaim := &mcsv1alpha2.ClusterClaim{ ObjectMeta: metav1.ObjectMeta{ Namespace: LeaderNamespace, - Name: "clusterset-id", + Name: "clusterset.k8s.io", }, - Name: "clusterset.k8s.io", Value: clusterSetID, } clusterSet := &mcsv1alpha1.ClusterSet{ diff --git a/multicluster/test/yamls/clusterset.yml b/multicluster/test/yamls/clusterset.yml index dde161f1beb..5725cd4f485 100644 --- a/multicluster/test/yamls/clusterset.yml +++ b/multicluster/test/yamls/clusterset.yml @@ -1,17 +1,15 @@ -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: - name: leadercluster-id - namespace: antrea-multicluster -name: id.k8s.io + name: id.k8s.io + namespace: antrea-mcs-ns value: test-cluster-leader --- -apiVersion: multicluster.crd.antrea.io/v1alpha1 +apiVersion: multicluster.crd.antrea.io/v1alpha2 kind: ClusterClaim metadata: - name: clusterset-id - namespace: antrea-multicluster -name: clusterset.k8s.io + name: clusterset.k8s.io + namespace: antrea-mcs-ns value: test-clusterset --- apiVersion: multicluster.crd.antrea.io/v1alpha1 diff --git a/multicluster/test/yamls/west-member-cluster.yml b/multicluster/test/yamls/west-member-cluster.yml index 1b491d29811..4c6aeea99a9 100644 --- a/multicluster/test/yamls/west-member-cluster.yml +++ b/multicluster/test/yamls/west-member-cluster.yml @@ -1,17 +1,15 @@ apiVersion: multicluster.crd.antrea.io/v1alpha1 kind: ClusterClaim metadata: - name: west-membercluster-id + name: id.k8s.io namespace: kube-system -name: id.k8s.io value: test-cluster-west --- apiVersion: multicluster.crd.antrea.io/v1alpha1 kind: ClusterClaim metadata: - name: clusterset-id + name: clusterset.k8s.io namespace: kube-system -name: clusterset.k8s.io value: test-clusterset --- apiVersion: multicluster.crd.antrea.io/v1alpha1 diff --git a/pkg/antctl/raw/multicluster/create/clusterclaim.go b/pkg/antctl/raw/multicluster/create/clusterclaim.go old mode 100644 new mode 100755 index 734ee934206..8af72305114 --- a/pkg/antctl/raw/multicluster/create/clusterclaim.go +++ b/pkg/antctl/raw/multicluster/create/clusterclaim.go @@ -25,7 +25,7 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" "antrea.io/antrea/pkg/antctl/raw" multiclusterscheme "antrea.io/antrea/pkg/antctl/raw/multicluster/scheme" ) @@ -93,59 +93,57 @@ func clusterClaimRunE(cmd *cobra.Command, args []string) error { return err } - clusterClaim := &multiclusterv1alpha1.ClusterClaim{ + clusterClaim := &multiclusterv1alpha2.ClusterClaim{ ObjectMeta: metav1.ObjectMeta{ - Name: multiclusterv1alpha1.WellKnownClusterClaimID, + Name: multiclusterv1alpha2.WellKnownClusterClaimID, Namespace: clusterClaimOpt.namespace, }, Value: clusterClaimOpt.clusterID, - Name: multiclusterv1alpha1.WellKnownClusterClaimID, } var createErr error createErr = k8sClient.Create(context.TODO(), clusterClaim) if createErr != nil { if errors.IsAlreadyExists(createErr) { - fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" already exists\n", multiclusterv1alpha1.WellKnownClusterClaimID) + fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" already exists\n", multiclusterv1alpha2.WellKnownClusterClaimID) createErr = nil } else { - fmt.Fprintf(cmd.OutOrStdout(), "Failed to create ClusterClaim \"%s\", error: %s\n", multiclusterv1alpha1.WellKnownClusterClaimID, createErr.Error()) + fmt.Fprintf(cmd.OutOrStdout(), "Failed to create ClusterClaim \"%s\", error: %s\n", multiclusterv1alpha2.WellKnownClusterClaimID, createErr.Error()) return createErr } } else { - fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" with Value \"%s\" created\n", multiclusterv1alpha1.WellKnownClusterClaimID, clusterClaimOpt.clusterID) + fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" with Value \"%s\" created\n", multiclusterv1alpha2.WellKnownClusterClaimID, clusterClaimOpt.clusterID) defer func() { if createErr != nil { err := k8sClient.Delete(context.TODO(), clusterClaim) if err != nil { fmt.Fprintf(cmd.OutOrStdout(), "Failed to delete ClusterClaim \"%s\", error: \n", err.Error()) } else { - fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" deleted\n", multiclusterv1alpha1.WellKnownClusterClaimID) + fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" deleted\n", multiclusterv1alpha2.WellKnownClusterClaimID) } } }() } - clustersetClaim := &multiclusterv1alpha1.ClusterClaim{ + clustersetClaim := &multiclusterv1alpha2.ClusterClaim{ ObjectMeta: metav1.ObjectMeta{ - Name: multiclusterv1alpha1.WellKnownClusterClaimClusterSet, + Name: multiclusterv1alpha2.WellKnownClusterClaimClusterSet, Namespace: clusterClaimOpt.namespace, }, Value: clusterClaimOpt.clusterSetID, - Name: multiclusterv1alpha1.WellKnownClusterClaimClusterSet, } createErr = k8sClient.Create(context.TODO(), clustersetClaim) if createErr != nil { if errors.IsAlreadyExists(createErr) { - fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" already exists\n", multiclusterv1alpha1.WellKnownClusterClaimClusterSet) + fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" already exists\n", multiclusterv1alpha2.WellKnownClusterClaimClusterSet) createErr = nil } else { - fmt.Fprintf(cmd.OutOrStdout(), "Failed to create ClusterClaim \"%s\", start rollback\n", multiclusterv1alpha1.WellKnownClusterClaimClusterSet) + fmt.Fprintf(cmd.OutOrStdout(), "Failed to create ClusterClaim \"%s\", start rollback\n", multiclusterv1alpha2.WellKnownClusterClaimClusterSet) return createErr } } else { - fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" with Value \"%s\" created\n", multiclusterv1alpha1.WellKnownClusterClaimClusterSet, clusterClaimOpt.clusterSetID) + fmt.Fprintf(cmd.OutOrStdout(), "ClusterClaim \"%s\" with Value \"%s\" created\n", multiclusterv1alpha2.WellKnownClusterClaimClusterSet, clusterClaimOpt.clusterSetID) } return nil diff --git a/pkg/antctl/raw/multicluster/delete/clusterclaim.go b/pkg/antctl/raw/multicluster/delete/clusterclaim.go old mode 100644 new mode 100755 index 83418b37183..174575a4be1 --- a/pkg/antctl/raw/multicluster/delete/clusterclaim.go +++ b/pkg/antctl/raw/multicluster/delete/clusterclaim.go @@ -25,7 +25,7 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1" + multiclusterv1alpha2 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha2" "antrea.io/antrea/pkg/antctl/raw" multiclusterscheme "antrea.io/antrea/pkg/antctl/raw/multicluster/scheme" ) @@ -52,7 +52,7 @@ func (o *clusterClaimOptions) validateAndComplete() error { func NewClusterClaimCmd() *cobra.Command { command := &cobra.Command{ Use: "clusterclaims", - Args: cobra.MaximumNArgs(1), + Args: cobra.MaximumNArgs(0), Short: "Delete the ClusterClaims in a specified Namespace", Long: "Delete the ClusterClaims in a specified Namespace. One for the leader or member cluster, and another for the ClusterSet", Example: clusterClaimExamples, @@ -83,16 +83,16 @@ func clusterClaimRunE(cmd *cobra.Command, args []string) error { return err } - clusterClaims := []*multiclusterv1alpha1.ClusterClaim{ + clusterClaims := []*multiclusterv1alpha2.ClusterClaim{ { ObjectMeta: metav1.ObjectMeta{ - Name: multiclusterv1alpha1.WellKnownClusterClaimID, + Name: multiclusterv1alpha2.WellKnownClusterClaimID, Namespace: clusterClaimOpt.namespace, }, }, { ObjectMeta: metav1.ObjectMeta{ - Name: multiclusterv1alpha1.WellKnownClusterClaimClusterSet, + Name: multiclusterv1alpha2.WellKnownClusterClaimClusterSet, Namespace: clusterClaimOpt.namespace, }, }, @@ -107,7 +107,7 @@ func clusterClaimRunE(cmd *cobra.Command, args []string) error { return nil } -func deleteClusterClaim(cmd *cobra.Command, k8sClient client.Client, clusterClaim *multiclusterv1alpha1.ClusterClaim) error { +func deleteClusterClaim(cmd *cobra.Command, k8sClient client.Client, clusterClaim *multiclusterv1alpha2.ClusterClaim) error { err := k8sClient.Delete(context.TODO(), clusterClaim) if err != nil { if !errors.IsNotFound(err) {