From 3675d42aeafef69a18b88ccbff7bd2292ce3578a Mon Sep 17 00:00:00 2001 From: Lan Luo Date: Mon, 4 Mar 2024 10:16:47 +0800 Subject: [PATCH] Remove deprecated v1alpha2 ClusterGroups Signed-off-by: Lan Luo --- build/charts/antrea/crds/clustergroup.yaml | 131 ------------- build/yamls/antrea-aks.yml | 131 ------------- build/yamls/antrea-crds.yml | 131 ------------- build/yamls/antrea-eks.yml | 131 ------------- build/yamls/antrea-gke.yml | 131 ------------- build/yamls/antrea-ipsec.yml | 131 ------------- build/yamls/antrea.yml | 131 ------------- docs/api.md | 155 +-------------- pkg/apis/crd/v1alpha2/register.go | 2 - pkg/apis/crd/v1alpha2/types.go | 88 --------- pkg/apis/crd/v1alpha2/webhook.go | 81 -------- .../crd/v1alpha2/zz_generated.deepcopy.go | 155 +-------------- pkg/apiserver/apiserver.go | 3 - .../typed/crd/v1alpha2/clustergroup.go | 182 ------------------ .../typed/crd/v1alpha2/crd_client.go | 7 +- .../crd/v1alpha2/fake/fake_clustergroup.go | 131 ------------- .../crd/v1alpha2/fake/fake_crd_client.go | 6 +- .../typed/crd/v1alpha2/generated_expansion.go | 4 +- .../crd/v1alpha2/clustergroup.go | 87 --------- .../crd/v1alpha2/interface.go | 9 +- .../informers/externalversions/generic.go | 4 +- .../listers/crd/v1alpha2/clustergroup.go | 66 ------- .../crd/v1alpha2/expansion_generated.go | 6 +- pkg/controller/networkpolicy/convert.go | 69 ------- 24 files changed, 8 insertions(+), 1964 deletions(-) delete mode 100644 pkg/apis/crd/v1alpha2/webhook.go delete mode 100644 pkg/client/clientset/versioned/typed/crd/v1alpha2/clustergroup.go delete mode 100644 pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_clustergroup.go delete mode 100644 pkg/client/informers/externalversions/crd/v1alpha2/clustergroup.go delete mode 100644 pkg/client/listers/crd/v1alpha2/clustergroup.go delete mode 100644 pkg/controller/networkpolicy/convert.go diff --git a/build/charts/antrea/crds/clustergroup.yaml b/build/charts/antrea/crds/clustergroup.yaml index 34734c27668..4ff7eaf5b9d 100644 --- a/build/charts/antrea/crds/clustergroup.yaml +++ b/build/charts/antrea/crds/clustergroup.yaml @@ -4,131 +4,9 @@ metadata: name: clustergroups.crd.antrea.io labels: app: antrea - served-by: antrea-controller spec: group: crd.antrea.io versions: - - name: v1alpha2 - served: true - storage: false - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - childGroups: - type: array - items: - type: string - podSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - namespaceSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - externalEntitySelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - ipBlock: - type: object - properties: - cidr: - type: string - format: cidr - ipBlocks: - type: array - items: - type: object - properties: - cidr: - type: string - format: cidr - serviceReference: - type: object - properties: - name: - type: string - namespace: - type: string - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - type: - type: string - status: - type: string - lastTransitionTime: - type: string - name: v1alpha3 served: true storage: false @@ -372,15 +250,6 @@ spec: type: string subresources: status: { } - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1", "v1beta1"] - clientConfig: - service: - name: "antrea" - namespace: "kube-system" - path: "/convert/clustergroup" scope: Cluster names: plural: clustergroups diff --git a/build/yamls/antrea-aks.yml b/build/yamls/antrea-aks.yml index 155d2016690..26e209058e4 100644 --- a/build/yamls/antrea-aks.yml +++ b/build/yamls/antrea-aks.yml @@ -308,131 +308,9 @@ metadata: name: clustergroups.crd.antrea.io labels: app: antrea - served-by: antrea-controller spec: group: crd.antrea.io versions: - - name: v1alpha2 - served: true - storage: false - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - childGroups: - type: array - items: - type: string - podSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - namespaceSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - externalEntitySelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - ipBlock: - type: object - properties: - cidr: - type: string - format: cidr - ipBlocks: - type: array - items: - type: object - properties: - cidr: - type: string - format: cidr - serviceReference: - type: object - properties: - name: - type: string - namespace: - type: string - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - type: - type: string - status: - type: string - lastTransitionTime: - type: string - name: v1alpha3 served: true storage: false @@ -676,15 +554,6 @@ spec: type: string subresources: status: { } - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1", "v1beta1"] - clientConfig: - service: - name: "antrea" - namespace: "kube-system" - path: "/convert/clustergroup" scope: Cluster names: plural: clustergroups diff --git a/build/yamls/antrea-crds.yml b/build/yamls/antrea-crds.yml index 7439bdf964d..1b89010db16 100644 --- a/build/yamls/antrea-crds.yml +++ b/build/yamls/antrea-crds.yml @@ -303,131 +303,9 @@ metadata: name: clustergroups.crd.antrea.io labels: app: antrea - served-by: antrea-controller spec: group: crd.antrea.io versions: - - name: v1alpha2 - served: true - storage: false - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - childGroups: - type: array - items: - type: string - podSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - namespaceSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - externalEntitySelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - ipBlock: - type: object - properties: - cidr: - type: string - format: cidr - ipBlocks: - type: array - items: - type: object - properties: - cidr: - type: string - format: cidr - serviceReference: - type: object - properties: - name: - type: string - namespace: - type: string - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - type: - type: string - status: - type: string - lastTransitionTime: - type: string - name: v1alpha3 served: true storage: false @@ -671,15 +549,6 @@ spec: type: string subresources: status: { } - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1", "v1beta1"] - clientConfig: - service: - name: "antrea" - namespace: "kube-system" - path: "/convert/clustergroup" scope: Cluster names: plural: clustergroups diff --git a/build/yamls/antrea-eks.yml b/build/yamls/antrea-eks.yml index 3775ab5a638..cdc54666085 100644 --- a/build/yamls/antrea-eks.yml +++ b/build/yamls/antrea-eks.yml @@ -308,131 +308,9 @@ metadata: name: clustergroups.crd.antrea.io labels: app: antrea - served-by: antrea-controller spec: group: crd.antrea.io versions: - - name: v1alpha2 - served: true - storage: false - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - childGroups: - type: array - items: - type: string - podSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - namespaceSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - externalEntitySelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - ipBlock: - type: object - properties: - cidr: - type: string - format: cidr - ipBlocks: - type: array - items: - type: object - properties: - cidr: - type: string - format: cidr - serviceReference: - type: object - properties: - name: - type: string - namespace: - type: string - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - type: - type: string - status: - type: string - lastTransitionTime: - type: string - name: v1alpha3 served: true storage: false @@ -676,15 +554,6 @@ spec: type: string subresources: status: { } - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1", "v1beta1"] - clientConfig: - service: - name: "antrea" - namespace: "kube-system" - path: "/convert/clustergroup" scope: Cluster names: plural: clustergroups diff --git a/build/yamls/antrea-gke.yml b/build/yamls/antrea-gke.yml index d8be7ff47f5..b7b307535aa 100644 --- a/build/yamls/antrea-gke.yml +++ b/build/yamls/antrea-gke.yml @@ -308,131 +308,9 @@ metadata: name: clustergroups.crd.antrea.io labels: app: antrea - served-by: antrea-controller spec: group: crd.antrea.io versions: - - name: v1alpha2 - served: true - storage: false - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - childGroups: - type: array - items: - type: string - podSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - namespaceSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - externalEntitySelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - ipBlock: - type: object - properties: - cidr: - type: string - format: cidr - ipBlocks: - type: array - items: - type: object - properties: - cidr: - type: string - format: cidr - serviceReference: - type: object - properties: - name: - type: string - namespace: - type: string - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - type: - type: string - status: - type: string - lastTransitionTime: - type: string - name: v1alpha3 served: true storage: false @@ -676,15 +554,6 @@ spec: type: string subresources: status: { } - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1", "v1beta1"] - clientConfig: - service: - name: "antrea" - namespace: "kube-system" - path: "/convert/clustergroup" scope: Cluster names: plural: clustergroups diff --git a/build/yamls/antrea-ipsec.yml b/build/yamls/antrea-ipsec.yml index 5d77441ce72..a13d5c042d6 100644 --- a/build/yamls/antrea-ipsec.yml +++ b/build/yamls/antrea-ipsec.yml @@ -308,131 +308,9 @@ metadata: name: clustergroups.crd.antrea.io labels: app: antrea - served-by: antrea-controller spec: group: crd.antrea.io versions: - - name: v1alpha2 - served: true - storage: false - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - childGroups: - type: array - items: - type: string - podSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - namespaceSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - externalEntitySelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - ipBlock: - type: object - properties: - cidr: - type: string - format: cidr - ipBlocks: - type: array - items: - type: object - properties: - cidr: - type: string - format: cidr - serviceReference: - type: object - properties: - name: - type: string - namespace: - type: string - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - type: - type: string - status: - type: string - lastTransitionTime: - type: string - name: v1alpha3 served: true storage: false @@ -676,15 +554,6 @@ spec: type: string subresources: status: { } - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1", "v1beta1"] - clientConfig: - service: - name: "antrea" - namespace: "kube-system" - path: "/convert/clustergroup" scope: Cluster names: plural: clustergroups diff --git a/build/yamls/antrea.yml b/build/yamls/antrea.yml index 411ec97391f..c515d3a1b2a 100644 --- a/build/yamls/antrea.yml +++ b/build/yamls/antrea.yml @@ -308,131 +308,9 @@ metadata: name: clustergroups.crd.antrea.io labels: app: antrea - served-by: antrea-controller spec: group: crd.antrea.io versions: - - name: v1alpha2 - served: true - storage: false - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - childGroups: - type: array - items: - type: string - podSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - namespaceSelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - externalEntitySelector: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist - type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: - x-kubernetes-preserve-unknown-fields: true - ipBlock: - type: object - properties: - cidr: - type: string - format: cidr - ipBlocks: - type: array - items: - type: object - properties: - cidr: - type: string - format: cidr - serviceReference: - type: object - properties: - name: - type: string - namespace: - type: string - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - type: - type: string - status: - type: string - lastTransitionTime: - type: string - name: v1alpha3 served: true storage: false @@ -676,15 +554,6 @@ spec: type: string subresources: status: { } - conversion: - strategy: Webhook - webhook: - conversionReviewVersions: ["v1", "v1beta1"] - clientConfig: - service: - name: "antrea" - namespace: "kube-system" - path: "/convert/clustergroup" scope: Cluster names: plural: clustergroups diff --git a/docs/api.md b/docs/api.md index b0eceb221f5..6d039cea37e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -28,7 +28,6 @@ These are the CRDs currently available in `crd.antrea.io`. |---|---|---|---|---| | `AntreaAgentInfo` | v1beta1 | v1.0.0 | N/A | N/A | | `AntreaControllerInfo` | v1beta1 | v1.0.0 | N/A | N/A | -| `ClusterGroup` | v1alpha2 | v1.0.0 | v1.1.0 | v2.0.0 | | `ClusterGroup` | v1alpha3 | v1.1.0 | v1.13.0 | N/A | | `ClusterGroup` | v1beta1 | v1.13.0 | N/A | N/A | | `ClusterNetworkPolicy` | v1alpha1 | v1.0.0 | v1.13.0 | N/A | @@ -81,156 +80,4 @@ These are the API group versions which are currently available when using Antrea | CRD | CRD version | Introduced in | Deprecated in | Removed in | |---|---|---|---|---| - -## API renaming from `*.antrea.tanzu.vmware.com` to `*.antrea.io` - -For the v1.0 release, we undertook to rename all Antrea APIs to use the -`antrea.io` suffix instead of the `antrea.tanzu.vmware.com` suffix. For more -information about the motivations behind this undertaking, please refer to -[Github issue #1715](https://github.com/antrea-io/antrea/issues/1715). - -From the v1.6 release, all legacy APIs (ending with the -`antrea.tanzu.vmware.com` suffix) have been completely removed. If you are -running an Antrea version older than v1.0 and you want to upgrade to Antrea v1.6 -or greater and migrate your API resources, you will first need to do an -intermediate upgrade to an Antrea version >= v1.0 and <= v1.5. You will then be -able to migrate all your API resources to the new (`*.antrea.io`) API, by -following the steps below. Finally, you will be able to upgrade to your desired -Antrea version (>= v1.6). - -As part of the API renaming, and to avoid proliferation of API groups, we have -decided to group all the Custom Resource Definitions (CRDs) defined by Antrea in -a single API group: `crd.antrea.io`. - -To avoid disruptions to existing Antrea users, our requirements for this -renaming process were as follows: - -1. As per our [upgrade - policy](versioning.md#antrea-upgrade-and-supported-version-skew), older - Agents need to be able to communicate with a new upgraded Controller, using - the old `controlplane.antrea.tanzu.vmware.com` API. Once both the Controller - and the Agent are upgraded, they communicate using `controlplane.antrea.io`. -2. API Services can be accessed using either API version. -3. After upgrade, Custom Resources can be managed using either API - version. Resources created using the old API (before or after upgrade) can be - accessed using the new API (or the old one). -4. For each resource in each API group, the new resource type should be - backward-compatible with the old resource type, and, whenever possible, - forward-compatible. This simplifies the upgrade of existing client - applications which leverage the Antrea API. These applications can be easily - upgraded to use the new API version, with no change to the business - logic. Custom Resources created before upgrading the application can be - accessed through the new API with no loss of information. - -To achieve our 3rd goal, we introduced a new Kubernetes controller in the Antrea -Controller, in charge of mirroring "old" Custom Resources (created using the -`*.antrea.tanzu.vmware.com` API groups) to the new (`*.antrea.io`) API. This new -mirroring controller is enabled by default, but can be disabled by setting -`legacyCRDMirroring` to `false` in the `antrea-controller` configuration -options. Thanks to this controller, the Antrea components (Agent and Controller) -only need to watch Custom Resources created with the new API group. If any -client still uses the old (or "legacy") API groups, these Custom Resources will -be mirrored to the new API group and handled as expected. - -The mirroring controller behaves as follows: - -* If a Custom Resource is created with the legacy API, it will create a new - Custom Resource with the same `Spec` and `Labels` as the legacy one. -* Any update to the `Spec` and / or `Labels` of the legacy Custom Resource will - be reflected identically in the new Custom Resource. -* Any update to the `Status` of the new mirrored Custom Resource (assuming it - has a `Status` field) will be reflected back identically in the legacy Custom - Resource. -* If the legacy Custom Resource is deleted, the mirrored one will be deleted - automatically as well. -* Manual updates to new mirrored Custom Resources will be overwritten by the - controller. -* If a legacy Custom Resource is annotated with `"crd.antrea.io/stop-mirror"`, - it will then be ignored, and updates to the corresponding new Custom - Resource will no longer be overwritten. - -This gives us the following upgrade sequence for a client application which uses -the legacy Antrea CRDs: - -1. Ensure that Antrea has been upgraded in the cluster to a version greater than - or equal to v1.0, and that legacy CRD mirroring is enabled (this is the case - by default). - -2. Check that all Custom Resources have been mirrored. All the new ones should - be annotated with `"crd.antrea.io/managed-by": - "crdmirroring-controller"`. The first command below will display all the - legacy AntreaNetworkPolicies (ANPs). The second one will display all the ones - which exist in the new `crd.antrea.io` API group. You can then compare the - two lists. - - ```bash - kubectl get lanp.security.antrea.tanzu.vmware.com -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' - kubectl get anp.crd.antrea.io -o jsonpath='{range .items[?(@.metadata.annotations.crd\.antrea\.io/managed-by=="crdmirroring-controller")]}{.metadata.name}{"\n"}{end}' - ``` - -3. Stop the old version of the application, which uses the legacy CRDs. - -4. Annotate all existing Custom Resources managed by the application with - `"crd.antrea.io/stop-mirror"`. From now on, the mirroring controller will - ignore these legacy resources: updates to the legacy resources (including - deletions) are not applied to the corresponding new resource any more, and - changes to the new resources are now possible (they will not be overwritten - by the controller). As an example, the command below will annotate *all* ANPs - in the current Namespace with `"crd.antrea.io/stop-mirror"`. - - ```bash - kubectl annotate lanp.security.antrea.tanzu.vmware.com --all crd.antrea.io/stop-mirror='' - ``` - -5. Check that none of the new Custom Resources still have the - `"crd.antrea.io/managed-by": "crdmirroring-controller"` annotation. Running - the same command as before should return an empty list: - - ```bash - kubectl get anp.crd.antrea.io -o jsonpath='{range .items[?(@.metadata.annotations.crd\.antrea\.io/managed-by=="crdmirroring-controller")]}{.metadata.name}{"\n"}{end}' - ``` - - If you remove the filter, all your ANPs should still exist: - - ```bash - kubectl get anp.crd.antrea.io -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' - ``` - -6. Safely delete all legacy CRDs previously managed by the application. As an - example, the command below will delete *all* legacy ANPs in the current - Namespace: - - ```bash - kubectl delete lanp.security.antrea.tanzu.vmware.com - ``` - - Once again, all new ANPs should still exist, which can be confirmed with: - - ```bash - kubectl get anp.crd.antrea.io -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' - ``` - -7. Start the new version of the application, which uses the new CRDs. All - mirrored Custom Resources should be available for the application to access. - -8. At this stage, if all applications have been updated, legacy CRD mirroring - can be disabled in the Antrea Controller configuration. - -Note that for CRDs which are "owned" by Antrea, `AntreaAgentInfo` and -`AntreaControllerInfo`, resources are automatically created by the Antrea -components using both API versions. - -### Deleting legacy Kubernetes resources after an upgrade - -After a successful upgrade from Antrea < v1.6 to Antrea >= v1.6, you may want to -manually clean up legacy Kubernetes resources which were created by an old -Antrea version but are no longer needed. Note that keeping these resource will -not impact any Antrea functions. - -To delete these legacy resources (CRDs and webhooks), run: - -```bash -kubectl get crds -o=name --no-headers=true | grep "antrea\.tanzu\.vmware\.com" | xargs -r kubectl delete -kubectl get mutatingwebhookconfigurations -o=name --no-headers=true | grep "antrea\.tanzu\.vmware\.com" | xargs -r kubectl delete -kubectl get validatingwebhookconfigurations -o=name --no-headers=true | grep "antrea\.tanzu\.vmware\.com" | xargs -r kubectl delete -``` +| `ClusterGroup` | v1alpha2 | v1.0.0 | v1.1.0 | v2.0.0 | diff --git a/pkg/apis/crd/v1alpha2/register.go b/pkg/apis/crd/v1alpha2/register.go index 0ea568f710f..56e0777d2f7 100644 --- a/pkg/apis/crd/v1alpha2/register.go +++ b/pkg/apis/crd/v1alpha2/register.go @@ -46,8 +46,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &ExternalEntity{}, &ExternalEntityList{}, - &ClusterGroup{}, - &ClusterGroupList{}, &Egress{}, &EgressList{}, &ExternalIPPool{}, diff --git a/pkg/apis/crd/v1alpha2/types.go b/pkg/apis/crd/v1alpha2/types.go index 6de016631b1..ad67d8004bd 100644 --- a/pkg/apis/crd/v1alpha2/types.go +++ b/pkg/apis/crd/v1alpha2/types.go @@ -17,8 +17,6 @@ package v1alpha2 import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "antrea.io/antrea/pkg/apis/crd/v1alpha1" ) // +genclient @@ -77,92 +75,6 @@ type ExternalEntityList struct { Items []ExternalEntity `json:"items,omitempty"` } -// ClusterGroupReference represent reference to a ClusterGroup. -type ClusterGroupReference string - -// +genclient -// +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -type ClusterGroup struct { - metav1.TypeMeta `json:",inline"` - // Standard metadata of the object. - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Desired state of the group. - Spec GroupSpec `json:"spec"` - // Most recently observed status of the group. - Status GroupStatus `json:"status"` -} - -type GroupSpec struct { - // Select Pods matching the labels set in the PodSelector in - // AppliedTo/To/From fields. If set with NamespaceSelector, Pods are - // matched from Namespaces matched by the NamespaceSelector. - // Cannot be set with any other selector except NamespaceSelector. - // +optional - PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"` - // Select all Pods from Namespaces matched by this selector, as - // workloads in AppliedTo/To/From fields. If set with PodSelector, - // Pods are matched from Namespaces matched by the NamespaceSelector. - // Cannot be set with any other selector except PodSelector. - // +optional - NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"` - // IPBlock describes the IPAddresses/IPBlocks that is matched in to/from. - // IPBlock cannot be set as part of the AppliedTo field. - // Cannot be set with any other selector or ServiceReference. - // Cannot be set with IPBlocks. - // +optional - IPBlock *v1alpha1.IPBlock `json:"ipBlock,omitempty"` - // IPBlocks is a list of IPAddresses/IPBlocks that is matched in to/from. - // IPBlock cannot be set as part of the AppliedTo field. - // Cannot be set with any other selector or ServiceReference. - // Cannot be set with IPBlock. - // +optional - IPBlocks []v1alpha1.IPBlock `json:"ipBlocks,omitempty"` - // Select backend Pods of the referred Service. - // Cannot be set with any other selector or ipBlock. - // +optional - ServiceReference *v1alpha1.NamespacedName `json:"serviceReference,omitempty"` - // Select ExternalEntities from all Namespaces as workloads - // in AppliedTo/To/From fields. If set with NamespaceSelector, - // ExternalEntities are matched from Namespaces matched by the - // NamespaceSelector. - // Cannot be set with any other selector except NamespaceSelector. - // +optional - ExternalEntitySelector *metav1.LabelSelector `json:"externalEntitySelector,omitempty"` - // Select other ClusterGroups by name. The ClusterGroups must already - // exist and must not contain ChildGroups themselves. - // Cannot be set with any selector/IPBlock/ServiceReference. - // +optional - ChildGroups []ClusterGroupReference `json:"childGroups,omitempty"` -} - -type GroupConditionType string - -const GroupMembersComputed GroupConditionType = "GroupMembersComputed" - -type GroupCondition struct { - Type GroupConditionType `json:"type"` - Status v1.ConditionStatus `json:"status"` - LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` -} - -// GroupStatus represents information about the status of a Group. -type GroupStatus struct { - Conditions []GroupCondition `json:"conditions,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -type ClusterGroupList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - Items []ClusterGroup `json:"items,omitempty"` -} - // AppliedTo selects the entities to which a policy is applied. type AppliedTo struct { // Select Pods matched by this selector. If set with NamespaceSelector, diff --git a/pkg/apis/crd/v1alpha2/webhook.go b/pkg/apis/crd/v1alpha2/webhook.go deleted file mode 100644 index 41e4b03b64c..00000000000 --- a/pkg/apis/crd/v1alpha2/webhook.go +++ /dev/null @@ -1,81 +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 v1alpha2 - -import ( - "fmt" - "reflect" - - "k8s.io/apimachinery/pkg/runtime" -) - -// WebhookImpl implements webhook validator of a resource. -type WebhookImpl interface { - Default(in *ExternalEntity) - ValidateCreate(in *ExternalEntity) error - ValidateUpdate(in *ExternalEntity, old runtime.Object) error - ValidateDelete(in *ExternalEntity) error -} - -var ( - externalEntityWebhook WebhookImpl -) - -// RegisterWebhook registers webhook implementation of a resource. -func RegisterWebhook(in runtime.Object, webhook WebhookImpl) error { - switch in.(type) { - case *ExternalEntity: - if externalEntityWebhook != nil { - return fmt.Errorf("externalEntityWebhook already registered") - } - externalEntityWebhook = webhook - default: - return fmt.Errorf("unknown type %s to register webhook", reflect.TypeOf(in).Elem().Name()) - } - return nil -} - -// Default implements webhook Defaulter. -func (in *ExternalEntity) Default() { - if externalEntityWebhook != nil { - externalEntityWebhook.Default(in) - } - return -} - -// ValidateCreate implements webhook Validator. -func (in *ExternalEntity) ValidateCreate() error { - if externalEntityWebhook != nil { - return externalEntityWebhook.ValidateCreate(in) - } - return nil -} - -// ValidateUpdate implements webhook Validator. -func (in *ExternalEntity) ValidateUpdate(old runtime.Object) error { - if externalEntityWebhook != nil { - return externalEntityWebhook.ValidateUpdate(in, old) - } - - return nil -} - -// ValidateDelete implements webhook Validator. -func (in *ExternalEntity) ValidateDelete() error { - if externalEntityWebhook != nil { - return externalEntityWebhook.ValidateDelete(in) - } - return nil -} diff --git a/pkg/apis/crd/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/crd/v1alpha2/zz_generated.deepcopy.go index 737aa9fb1c8..faacef4a4f1 100644 --- a/pkg/apis/crd/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/crd/v1alpha2/zz_generated.deepcopy.go @@ -1,7 +1,7 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// Copyright 2023 Antrea Authors +// Copyright 2024 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ package v1alpha2 import ( - v1alpha1 "antrea.io/antrea/pkg/apis/crd/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -56,67 +55,6 @@ func (in *AppliedTo) DeepCopy() *AppliedTo { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterGroup) DeepCopyInto(out *ClusterGroup) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterGroup. -func (in *ClusterGroup) DeepCopy() *ClusterGroup { - if in == nil { - return nil - } - out := new(ClusterGroup) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterGroup) 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 *ClusterGroupList) DeepCopyInto(out *ClusterGroupList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ClusterGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterGroupList. -func (in *ClusterGroupList) DeepCopy() *ClusterGroupList { - if in == nil { - return nil - } - out := new(ClusterGroupList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterGroupList) 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 *ERSPANTunnel) DeepCopyInto(out *ERSPANTunnel) { *out = *in @@ -504,97 +442,6 @@ func (in *GRETunnel) DeepCopy() *GRETunnel { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GroupCondition) DeepCopyInto(out *GroupCondition) { - *out = *in - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupCondition. -func (in *GroupCondition) DeepCopy() *GroupCondition { - if in == nil { - return nil - } - out := new(GroupCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GroupSpec) DeepCopyInto(out *GroupSpec) { - *out = *in - if in.PodSelector != nil { - in, out := &in.PodSelector, &out.PodSelector - *out = new(v1.LabelSelector) - (*in).DeepCopyInto(*out) - } - if in.NamespaceSelector != nil { - in, out := &in.NamespaceSelector, &out.NamespaceSelector - *out = new(v1.LabelSelector) - (*in).DeepCopyInto(*out) - } - if in.IPBlock != nil { - in, out := &in.IPBlock, &out.IPBlock - *out = new(v1alpha1.IPBlock) - **out = **in - } - if in.IPBlocks != nil { - in, out := &in.IPBlocks, &out.IPBlocks - *out = make([]v1alpha1.IPBlock, len(*in)) - copy(*out, *in) - } - if in.ServiceReference != nil { - in, out := &in.ServiceReference, &out.ServiceReference - *out = new(v1alpha1.NamespacedName) - **out = **in - } - if in.ExternalEntitySelector != nil { - in, out := &in.ExternalEntitySelector, &out.ExternalEntitySelector - *out = new(v1.LabelSelector) - (*in).DeepCopyInto(*out) - } - if in.ChildGroups != nil { - in, out := &in.ChildGroups, &out.ChildGroups - *out = make([]ClusterGroupReference, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupSpec. -func (in *GroupSpec) DeepCopy() *GroupSpec { - if in == nil { - return nil - } - out := new(GroupSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GroupStatus) DeepCopyInto(out *GroupStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]GroupCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupStatus. -func (in *GroupStatus) DeepCopy() *GroupStatus { - if in == nil { - return nil - } - out := new(GroupStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPAddressOwner) DeepCopyInto(out *IPAddressOwner) { *out = *in diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index b5d8787ffaa..ffaca21bb44 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -314,9 +314,6 @@ func installHandlers(c *ExtraConfig, s *genericapiserver.GenericAPIServer) { s.Handler.NonGoRestfulMux.HandleFunc("/validate/clustergroup", webhook.HandlerForValidateFunc(v.Validate)) s.Handler.NonGoRestfulMux.HandleFunc("/validate/group", webhook.HandlerForValidateFunc(v.Validate)) - // Install handlers for CRD conversion between versions - s.Handler.NonGoRestfulMux.HandleFunc("/convert/clustergroup", webhook.HandleCRDConversion(controllernetworkpolicy.ConvertClusterGroupCRD)) - // Install a post start hook to initialize Tiers on start-up s.AddPostStartHook("initialize-tiers", func(context genericapiserver.PostStartHookContext) error { go c.networkPolicyController.InitializeTiers() diff --git a/pkg/client/clientset/versioned/typed/crd/v1alpha2/clustergroup.go b/pkg/client/clientset/versioned/typed/crd/v1alpha2/clustergroup.go deleted file mode 100644 index 16fbad832f2..00000000000 --- a/pkg/client/clientset/versioned/typed/crd/v1alpha2/clustergroup.go +++ /dev/null @@ -1,182 +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. - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - "context" - "time" - - v1alpha2 "antrea.io/antrea/pkg/apis/crd/v1alpha2" - scheme "antrea.io/antrea/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ClusterGroupsGetter has a method to return a ClusterGroupInterface. -// A group's client should implement this interface. -type ClusterGroupsGetter interface { - ClusterGroups() ClusterGroupInterface -} - -// ClusterGroupInterface has methods to work with ClusterGroup resources. -type ClusterGroupInterface interface { - Create(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.CreateOptions) (*v1alpha2.ClusterGroup, error) - Update(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.UpdateOptions) (*v1alpha2.ClusterGroup, error) - UpdateStatus(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.UpdateOptions) (*v1alpha2.ClusterGroup, 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) (*v1alpha2.ClusterGroup, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ClusterGroupList, 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 *v1alpha2.ClusterGroup, err error) - ClusterGroupExpansion -} - -// clusterGroups implements ClusterGroupInterface -type clusterGroups struct { - client rest.Interface -} - -// newClusterGroups returns a ClusterGroups -func newClusterGroups(c *CrdV1alpha2Client) *clusterGroups { - return &clusterGroups{ - client: c.RESTClient(), - } -} - -// Get takes name of the clusterGroup, and returns the corresponding clusterGroup object, and an error if there is any. -func (c *clusterGroups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ClusterGroup, err error) { - result = &v1alpha2.ClusterGroup{} - err = c.client.Get(). - Resource("clustergroups"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ClusterGroups that match those selectors. -func (c *clusterGroups) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ClusterGroupList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha2.ClusterGroupList{} - err = c.client.Get(). - Resource("clustergroups"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested clusterGroups. -func (c *clusterGroups) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Resource("clustergroups"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a clusterGroup and creates it. Returns the server's representation of the clusterGroup, and an error, if there is any. -func (c *clusterGroups) Create(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.CreateOptions) (result *v1alpha2.ClusterGroup, err error) { - result = &v1alpha2.ClusterGroup{} - err = c.client.Post(). - Resource("clustergroups"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterGroup). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a clusterGroup and updates it. Returns the server's representation of the clusterGroup, and an error, if there is any. -func (c *clusterGroups) Update(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.UpdateOptions) (result *v1alpha2.ClusterGroup, err error) { - result = &v1alpha2.ClusterGroup{} - err = c.client.Put(). - Resource("clustergroups"). - Name(clusterGroup.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterGroup). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *clusterGroups) UpdateStatus(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.UpdateOptions) (result *v1alpha2.ClusterGroup, err error) { - result = &v1alpha2.ClusterGroup{} - err = c.client.Put(). - Resource("clustergroups"). - Name(clusterGroup.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterGroup). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the clusterGroup and deletes it. Returns an error if one occurs. -func (c *clusterGroups) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Resource("clustergroups"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *clusterGroups) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Resource("clustergroups"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched clusterGroup. -func (c *clusterGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterGroup, err error) { - result = &v1alpha2.ClusterGroup{} - err = c.client.Patch(pt). - Resource("clustergroups"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/crd/v1alpha2/crd_client.go b/pkg/client/clientset/versioned/typed/crd/v1alpha2/crd_client.go index b486fca3717..a688d2d2816 100644 --- a/pkg/client/clientset/versioned/typed/crd/v1alpha2/crd_client.go +++ b/pkg/client/clientset/versioned/typed/crd/v1alpha2/crd_client.go @@ -1,4 +1,4 @@ -// Copyright 2022 Antrea Authors +// Copyright 2024 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import ( type CrdV1alpha2Interface interface { RESTClient() rest.Interface - ClusterGroupsGetter EgressesGetter ExternalEntitiesGetter ExternalIPPoolsGetter @@ -39,10 +38,6 @@ type CrdV1alpha2Client struct { restClient rest.Interface } -func (c *CrdV1alpha2Client) ClusterGroups() ClusterGroupInterface { - return newClusterGroups(c) -} - func (c *CrdV1alpha2Client) Egresses() EgressInterface { return newEgresses(c) } diff --git a/pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_clustergroup.go b/pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_clustergroup.go deleted file mode 100644 index 750a9492a2b..00000000000 --- a/pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_clustergroup.go +++ /dev/null @@ -1,131 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1alpha2 "antrea.io/antrea/pkg/apis/crd/v1alpha2" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeClusterGroups implements ClusterGroupInterface -type FakeClusterGroups struct { - Fake *FakeCrdV1alpha2 -} - -var clustergroupsResource = schema.GroupVersionResource{Group: "crd.antrea.io", Version: "v1alpha2", Resource: "clustergroups"} - -var clustergroupsKind = schema.GroupVersionKind{Group: "crd.antrea.io", Version: "v1alpha2", Kind: "ClusterGroup"} - -// Get takes name of the clusterGroup, and returns the corresponding clusterGroup object, and an error if there is any. -func (c *FakeClusterGroups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ClusterGroup, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(clustergroupsResource, name), &v1alpha2.ClusterGroup{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.ClusterGroup), err -} - -// List takes label and field selectors, and returns the list of ClusterGroups that match those selectors. -func (c *FakeClusterGroups) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ClusterGroupList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(clustergroupsResource, clustergroupsKind, opts), &v1alpha2.ClusterGroupList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha2.ClusterGroupList{ListMeta: obj.(*v1alpha2.ClusterGroupList).ListMeta} - for _, item := range obj.(*v1alpha2.ClusterGroupList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested clusterGroups. -func (c *FakeClusterGroups) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchAction(clustergroupsResource, opts)) -} - -// Create takes the representation of a clusterGroup and creates it. Returns the server's representation of the clusterGroup, and an error, if there is any. -func (c *FakeClusterGroups) Create(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.CreateOptions) (result *v1alpha2.ClusterGroup, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(clustergroupsResource, clusterGroup), &v1alpha2.ClusterGroup{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.ClusterGroup), err -} - -// Update takes the representation of a clusterGroup and updates it. Returns the server's representation of the clusterGroup, and an error, if there is any. -func (c *FakeClusterGroups) Update(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.UpdateOptions) (result *v1alpha2.ClusterGroup, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(clustergroupsResource, clusterGroup), &v1alpha2.ClusterGroup{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.ClusterGroup), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeClusterGroups) UpdateStatus(ctx context.Context, clusterGroup *v1alpha2.ClusterGroup, opts v1.UpdateOptions) (*v1alpha2.ClusterGroup, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(clustergroupsResource, "status", clusterGroup), &v1alpha2.ClusterGroup{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.ClusterGroup), err -} - -// Delete takes name of the clusterGroup and deletes it. Returns an error if one occurs. -func (c *FakeClusterGroups) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(clustergroupsResource, name, opts), &v1alpha2.ClusterGroup{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeClusterGroups) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(clustergroupsResource, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha2.ClusterGroupList{}) - return err -} - -// Patch applies the patch and returns the patched clusterGroup. -func (c *FakeClusterGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterGroup, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clustergroupsResource, name, pt, data, subresources...), &v1alpha2.ClusterGroup{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.ClusterGroup), err -} diff --git a/pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_crd_client.go b/pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_crd_client.go index 9e616b87e44..37c4d039032 100644 --- a/pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_crd_client.go +++ b/pkg/client/clientset/versioned/typed/crd/v1alpha2/fake/fake_crd_client.go @@ -1,4 +1,4 @@ -// Copyright 2022 Antrea Authors +// Copyright 2024 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,10 +26,6 @@ type FakeCrdV1alpha2 struct { *testing.Fake } -func (c *FakeCrdV1alpha2) ClusterGroups() v1alpha2.ClusterGroupInterface { - return &FakeClusterGroups{c} -} - func (c *FakeCrdV1alpha2) Egresses() v1alpha2.EgressInterface { return &FakeEgresses{c} } diff --git a/pkg/client/clientset/versioned/typed/crd/v1alpha2/generated_expansion.go b/pkg/client/clientset/versioned/typed/crd/v1alpha2/generated_expansion.go index 83ac45a1e33..fab8277a83c 100644 --- a/pkg/client/clientset/versioned/typed/crd/v1alpha2/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/crd/v1alpha2/generated_expansion.go @@ -1,4 +1,4 @@ -// Copyright 2022 Antrea Authors +// Copyright 2024 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package v1alpha2 -type ClusterGroupExpansion interface{} - type EgressExpansion interface{} type ExternalEntityExpansion interface{} diff --git a/pkg/client/informers/externalversions/crd/v1alpha2/clustergroup.go b/pkg/client/informers/externalversions/crd/v1alpha2/clustergroup.go deleted file mode 100644 index 14bc4344bf2..00000000000 --- a/pkg/client/informers/externalversions/crd/v1alpha2/clustergroup.go +++ /dev/null @@ -1,87 +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. - -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - "context" - time "time" - - crdv1alpha2 "antrea.io/antrea/pkg/apis/crd/v1alpha2" - versioned "antrea.io/antrea/pkg/client/clientset/versioned" - internalinterfaces "antrea.io/antrea/pkg/client/informers/externalversions/internalinterfaces" - v1alpha2 "antrea.io/antrea/pkg/client/listers/crd/v1alpha2" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// ClusterGroupInformer provides access to a shared informer and lister for -// ClusterGroups. -type ClusterGroupInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha2.ClusterGroupLister -} - -type clusterGroupInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewClusterGroupInformer constructs a new informer for ClusterGroup type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewClusterGroupInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredClusterGroupInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredClusterGroupInformer constructs a new informer for ClusterGroup type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterGroupInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.CrdV1alpha2().ClusterGroups().List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.CrdV1alpha2().ClusterGroups().Watch(context.TODO(), options) - }, - }, - &crdv1alpha2.ClusterGroup{}, - resyncPeriod, - indexers, - ) -} - -func (f *clusterGroupInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredClusterGroupInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *clusterGroupInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&crdv1alpha2.ClusterGroup{}, f.defaultInformer) -} - -func (f *clusterGroupInformer) Lister() v1alpha2.ClusterGroupLister { - return v1alpha2.NewClusterGroupLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/crd/v1alpha2/interface.go b/pkg/client/informers/externalversions/crd/v1alpha2/interface.go index a15d69484b0..9422cd985f1 100644 --- a/pkg/client/informers/externalversions/crd/v1alpha2/interface.go +++ b/pkg/client/informers/externalversions/crd/v1alpha2/interface.go @@ -1,4 +1,4 @@ -// Copyright 2023 Antrea Authors +// Copyright 2024 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -22,8 +22,6 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // ClusterGroups returns a ClusterGroupInformer. - ClusterGroups() ClusterGroupInformer // Egresses returns a EgressInformer. Egresses() EgressInformer // ExternalEntities returns a ExternalEntityInformer. @@ -47,11 +45,6 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// ClusterGroups returns a ClusterGroupInformer. -func (v *version) ClusterGroups() ClusterGroupInformer { - return &clusterGroupInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - // Egresses returns a EgressInformer. func (v *version) Egresses() EgressInformer { return &egressInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index b5e7ce3c762..e3f7e903ce7 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -1,4 +1,4 @@ -// Copyright 2023 Antrea Authors +// Copyright 2024 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -68,8 +68,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Crd().V1alpha1().Traceflows().Informer()}, nil // Group=crd.antrea.io, Version=v1alpha2 - case v1alpha2.SchemeGroupVersion.WithResource("clustergroups"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Crd().V1alpha2().ClusterGroups().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("egresses"): return &genericInformer{resource: resource.GroupResource(), informer: f.Crd().V1alpha2().Egresses().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("externalentities"): diff --git a/pkg/client/listers/crd/v1alpha2/clustergroup.go b/pkg/client/listers/crd/v1alpha2/clustergroup.go deleted file mode 100644 index 68be2b49da5..00000000000 --- a/pkg/client/listers/crd/v1alpha2/clustergroup.go +++ /dev/null @@ -1,66 +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. - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - v1alpha2 "antrea.io/antrea/pkg/apis/crd/v1alpha2" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ClusterGroupLister helps list ClusterGroups. -// All objects returned here must be treated as read-only. -type ClusterGroupLister interface { - // List lists all ClusterGroups in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha2.ClusterGroup, err error) - // Get retrieves the ClusterGroup from the index for a given name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha2.ClusterGroup, error) - ClusterGroupListerExpansion -} - -// clusterGroupLister implements the ClusterGroupLister interface. -type clusterGroupLister struct { - indexer cache.Indexer -} - -// NewClusterGroupLister returns a new ClusterGroupLister. -func NewClusterGroupLister(indexer cache.Indexer) ClusterGroupLister { - return &clusterGroupLister{indexer: indexer} -} - -// List lists all ClusterGroups in the indexer. -func (s *clusterGroupLister) List(selector labels.Selector) (ret []*v1alpha2.ClusterGroup, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha2.ClusterGroup)) - }) - return ret, err -} - -// Get retrieves the ClusterGroup from the index for a given name. -func (s *clusterGroupLister) Get(name string) (*v1alpha2.ClusterGroup, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha2.Resource("clustergroup"), name) - } - return obj.(*v1alpha2.ClusterGroup), nil -} diff --git a/pkg/client/listers/crd/v1alpha2/expansion_generated.go b/pkg/client/listers/crd/v1alpha2/expansion_generated.go index 6cc05d345cb..be752c2fa33 100644 --- a/pkg/client/listers/crd/v1alpha2/expansion_generated.go +++ b/pkg/client/listers/crd/v1alpha2/expansion_generated.go @@ -1,4 +1,4 @@ -// Copyright 2022 Antrea Authors +// Copyright 2024 Antrea Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,10 +16,6 @@ package v1alpha2 -// ClusterGroupListerExpansion allows custom methods to be added to -// ClusterGroupLister. -type ClusterGroupListerExpansion interface{} - // EgressListerExpansion allows custom methods to be added to // EgressLister. type EgressListerExpansion interface{} diff --git a/pkg/controller/networkpolicy/convert.go b/pkg/controller/networkpolicy/convert.go deleted file mode 100644 index 50ca307d7f6..00000000000 --- a/pkg/controller/networkpolicy/convert.go +++ /dev/null @@ -1,69 +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 networkpolicy - -import ( - "fmt" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/klog/v2" -) - -func statusErrorWithMessage(msg string, params ...interface{}) metav1.Status { - return metav1.Status{ - Message: fmt.Sprintf(msg, params...), - Status: metav1.StatusFailure, - } -} - -func ConvertClusterGroupCRD(Object *unstructured.Unstructured, toVersion string) (*unstructured.Unstructured, metav1.Status) { - klog.V(2).Infof("Converting CRD for ClusterGroup %s", Object.GetName()) - convertedObject := Object.DeepCopy() - fromVersion := Object.GetAPIVersion() - if toVersion == fromVersion { - return nil, statusErrorWithMessage("conversion from a version to itself should not call the webhook: %s", toVersion) - } - switch Object.GetAPIVersion() { - case "crd.antrea.io/v1alpha2": - switch toVersion { - case "crd.antrea.io/v1alpha3", "crd.antrea.io/v1beta1": - ipb, found, err := unstructured.NestedMap(convertedObject.Object, "spec", "ipBlock") - if err == nil && found && len(ipb) > 0 { - unstructured.RemoveNestedField(convertedObject.Object, "spec", "ipBlock") - // unstructured.SetNestedSlice expects a slice of interface as value - ipBlocks := make([]interface{}, 1) - ipBlocks[0] = ipb - unstructured.SetNestedSlice(convertedObject.Object, ipBlocks, "spec", "ipBlocks") - } - default: - return nil, statusErrorWithMessage("unexpected conversion version %q", toVersion) - } - case "crd.antrea.io/v1alpha3", "crd.antrea.io/v1beta1": - switch toVersion { - case "crd.antrea.io/v1alpha2", "crd.antrea.io/v1alpha3", "crd.antrea.io/v1beta1": - return convertedObject, metav1.Status{ - Status: metav1.StatusSuccess, - } - default: - return nil, statusErrorWithMessage("unexpected conversion version %q", toVersion) - } - default: - return nil, statusErrorWithMessage("unexpected conversion version %q", fromVersion) - } - return convertedObject, metav1.Status{ - Status: metav1.StatusSuccess, - } -}