From 8b09d25f94f2b6aef5bc2e6422fa9af7070f8c07 Mon Sep 17 00:00:00 2001 From: cyclinder Date: Tue, 3 Dec 2024 17:33:07 +0800 Subject: [PATCH] update spiderpool apis from v2beta1 to v1 Signed-off-by: cyclinder api: update enableRdma/rdmaIsolation field for spiderMultusConfig Signed-off-by: Cyclinder Kuo --- ...rpool.spidernet.io_spidercoordinators.yaml | 9 - ...spiderpool.spidernet.io_spiderippools.yaml | 6 - ...pool.spidernet.io_spidermultusconfigs.yaml | 79 +- ...spiderpool.spidernet.io_spidersubnets.yaml | 6 - cmd/spiderpool-agent/cmd/coordinator.go | 4 +- cmd/spiderpool-agent/cmd/crd_manager.go | 16 +- cmd/spiderpool-controller/cmd/clean.go | 19 +- cmd/spiderpool-controller/cmd/crd_manager.go | 12 +- .../cmd/metrics_server.go | 6 +- cmd/spiderpool-init/cmd/client.go | 12 +- cmd/spiderpool-init/cmd/config.go | 8 +- cmd/spiderpool-init/cmd/root.go | 22 +- docs/concepts/coordinator-zh_CN.md | 12 +- docs/concepts/coordinator.md | 12 +- docs/example/basic/custom-ipv4-ippool.yaml | 2 +- docs/example/basic/custom-ipv4-subnet.yaml | 2 +- docs/example/basic/custom-ipv6-ippool.yaml | 2 +- docs/example/basic/custom-ipv6-subnet.yaml | 2 +- .../master-ipv4-ippool.yaml | 2 +- .../worker-ipv4-ippool.yaml | 2 +- .../occupied-static-ipv4-ippool.yaml | 2 +- .../shared-static-ipv4-ippool.yaml | 2 +- .../static-ipv4-subnet.yaml | 2 +- .../test-ns-ipv4-ippool.yaml | 2 +- .../ippool-multi/test-ipv4-ippools.yaml | 4 +- .../ns1-default-ipv4-ippool.yaml | 2 +- .../different-segment-ipv4-ippools.yaml | 4 +- .../different-segment-ipv4-subnets.yaml | 4 +- .../reserved-ip/already-in-use-ippool.yaml | 2 +- .../created-by-someone-else-ippool.yaml | 2 +- .../not-use-excludeips-ippool.yaml | 2 +- .../example/reserved-ip/test-ipv4-ippool.yaml | 2 +- .../reserved-ip/test-ipv4-reservedip.yaml | 2 +- .../reserved-ip/use-excludeips-ippool.yaml | 2 +- docs/example/route/ippool-route.yaml | 2 +- docs/example/route/subnet-route.yaml | 2 +- .../spider-subnet/multiple-interfaces.yaml | 8 +- docs/example/spider-subnet/subnet-demo.yaml | 4 +- docs/reference/crd-spiderclaimparameter.md | 2 +- docs/reference/crd-spidercoordinator.md | 2 +- docs/reference/crd-spiderendpoint.md | 2 +- docs/reference/crd-spiderippool.md | 2 +- docs/reference/crd-spidermultusconfig.md | 11 +- docs/reference/crd-spiderreservedip.md | 2 +- docs/reference/crd-spidersubnet.md | 2 +- .../install/ai/get-started-macvlan-zh_CN.md | 9 +- docs/usage/install/ai/get-started-macvlan.md | 9 +- .../install/ai/get-started-sriov-zh_CN.md | 24 +- docs/usage/install/ai/get-started-sriov.md | 14 +- .../cloud/get-started-alibaba-zh_CN.md | 12 +- .../install/cloud/get-started-alibaba.md | 12 +- .../install/cloud/get-started-aws-zh_CN.md | 10 +- docs/usage/install/cloud/get-started-aws.md | 10 +- .../overlay/get-started-calico-zh_cn.md | 10 +- .../install/overlay/get-started-calico.md | 10 +- .../overlay/get-started-cilium-zh_cn.md | 10 +- .../install/overlay/get-started-cilium.md | 10 +- .../underlay/get-started-calico-zh_CN.md | 2 +- .../install/underlay/get-started-calico.md | 2 +- .../underlay/get-started-macvlan-zh_CN.md | 6 +- .../install/underlay/get-started-macvlan.md | 6 +- .../install/underlay/get-started-ovs-zh_CN.md | 6 +- .../usage/install/underlay/get-started-ovs.md | 6 +- .../underlay/get-started-sriov-zh_CN.md | 4 +- .../install/underlay/get-started-sriov.md | 4 +- .../underlay/get-started-weave-zh_CN.md | 2 +- .../install/underlay/get-started-weave.md | 2 +- docs/usage/ipoib-zh_CN.md | 4 +- docs/usage/ipoib.md | 4 +- docs/usage/ipvlan_bandwidth-zh_CN.md | 2 +- docs/usage/ipvlan_bandwidth.md | 2 +- docs/usage/istio-zh_CN.md | 4 +- docs/usage/istio.md | 4 +- docs/usage/network-topology-zh_CN.md | 6 +- docs/usage/network-topology.md | 6 +- docs/usage/operator-zh_CN.md | 2 +- docs/usage/operator.md | 2 +- docs/usage/reserved-ip-zh_CN.md | 6 +- docs/usage/reserved-ip.md | 6 +- docs/usage/route-zh_CN.md | 4 +- docs/usage/route.md | 4 +- docs/usage/spider-affinity-zh_CN.md | 18 +- docs/usage/spider-affinity.md | 16 +- docs/usage/spider-ippool-zh_CN.md | 2 +- docs/usage/spider-ippool.md | 2 +- docs/usage/spider-multus-config-zh_CN.md | 36 +- docs/usage/spider-multus-config.md | 36 +- docs/usage/spider-subnet-zh_CN.md | 10 +- docs/usage/spider-subnet.md | 10 +- docs/usage/statefulset-zh_CN.md | 4 +- docs/usage/statefulset.md | 4 +- docs/usage/submariner-zh_CN.md | 8 +- docs/usage/submariner.md | 8 +- docs/usage/underlay_cni_service-zh_CN.md | 4 +- docs/usage/underlay_cni_service.md | 4 +- pkg/applicationcontroller/app_controller.go | 8 +- .../applicationcontroller_suite_test.go | 4 +- .../applicationinformers/utils.go | 6 +- .../applicationinformers/utils_test.go | 12 +- .../coordinator_informer.go | 28 +- pkg/coordinatormanager/coordinator_mutate.go | 7 +- .../coordinator_validate.go | 21 +- pkg/coordinatormanager/coordinator_webhook.go | 12 +- pkg/gcmanager/scanAll_IPPool.go | 6 +- pkg/ipam/allocate.go | 18 +- pkg/ipam/pool_selections.go | 12 +- pkg/ipam/release.go | 6 +- pkg/ipam/types.go | 8 +- pkg/ipam/utils.go | 11 +- pkg/ippoolmanager/ippool_informer.go | 18 +- pkg/ippoolmanager/ippool_informer_test.go | 16 +- pkg/ippoolmanager/ippool_manager.go | 20 +- .../ippool_manager_suite_test.go | 28 +- pkg/ippoolmanager/ippool_manager_test.go | 30 +- pkg/ippoolmanager/ippool_mutate.go | 12 +- pkg/ippoolmanager/ippool_subnet_validate.go | 12 +- pkg/ippoolmanager/ippool_validate.go | 26 +- pkg/ippoolmanager/ippool_webhook.go | 14 +- pkg/ippoolmanager/ippool_webhook_test.go | 62 +- pkg/ippoolmanager/utils.go | 8 +- pkg/ippoolmanager/utils_test.go | 22 +- .../apis/spiderpool.spidernet.io/v1/doc.go | 6 + .../v1/groupversion_info.go | 26 + .../apis/spiderpool.spidernet.io/v1/rbac.go | 24 + .../spiderpool.spidernet.io/v1/register.go | 16 + .../v1/spidercoordinator_types.go | 129 ++ .../v1/spiderendpoint_types.go | 98 ++ .../v1/spiderippool_types.go | 124 ++ .../v1/spidermultus_types.go | 260 ++++ .../v1/spiderreservedip_types.go | 44 + .../v1/spidersubnet_types.go | 85 ++ .../v1/types_string.go | 215 +++ .../v1/zz_generated.deepcopy.go | 1216 +++++++++++++++++ .../v2beta1/spidermultus_types.go | 61 +- .../client/clientset/versioned/clientset.go | 13 + .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../typed/spiderpool.spidernet.io/v1/doc.go | 7 + .../spiderpool.spidernet.io/v1/fake/doc.go | 7 + .../v1/fake/fake_spidercoordinator.go | 119 ++ .../v1/fake/fake_spiderippool.go | 119 ++ .../v1/fake/fake_spidermultusconfig.go | 116 ++ .../fake_spiderpool.spidernet.io_client.go | 39 + .../v1/fake/fake_spidersubnet.go | 119 ++ .../v1/generated_expansion.go | 14 + .../v1/spidercoordinator.go | 171 +++ .../v1/spiderippool.go | 171 +++ .../v1/spidermultusconfig.go | 165 +++ .../v1/spiderpool.spidernet.io_client.go | 109 ++ .../v1/spidersubnet.go | 171 +++ .../informers/externalversions/generic.go | 13 +- .../spiderpool.spidernet.io/interface.go | 8 + .../spiderpool.spidernet.io/v1/interface.go | 53 + .../v1/spidercoordinator.go | 76 ++ .../v1/spiderippool.go | 76 ++ .../v1/spidermultusconfig.go | 77 ++ .../v1/spidersubnet.go | 76 ++ .../v1/expansion_generated.go | 26 + .../v1/spidercoordinator.go | 55 + .../v1/spiderippool.go | 55 + .../v1/spidermultusconfig.go | 86 ++ .../v1/spidersubnet.go | 55 + .../spidercliamparameter_webhook.go | 141 -- pkg/multuscniconfig/multusconfig_informer.go | 30 +- pkg/multuscniconfig/multusconfig_mutate.go | 39 +- pkg/multuscniconfig/multusconfig_validate.go | 22 +- pkg/multuscniconfig/multusconfig_webhook.go | 16 +- pkg/multuscniconfig/utils.go | 31 +- pkg/podmanager/utils.go | 17 +- pkg/podmanager/utils_test.go | 28 +- .../mock/reservedip_manager_mock.go | 2 +- pkg/reservedipmanager/reservedip_manager.go | 14 +- .../reservedip_manager_suite_test.go | 20 +- .../reservedip_manager_test.go | 12 +- pkg/reservedipmanager/reservedip_mutate.go | 4 +- pkg/reservedipmanager/reservedip_validate.go | 10 +- pkg/reservedipmanager/reservedip_webhook.go | 12 +- .../reservedip_webhook_test.go | 8 +- pkg/subnetmanager/subnet_informer.go | 36 +- pkg/subnetmanager/subnet_informer_test.go | 44 +- pkg/subnetmanager/subnet_manager.go | 36 +- .../subnet_manager_suite_test.go | 16 +- pkg/subnetmanager/subnet_manager_test.go | 10 +- pkg/subnetmanager/subnet_mutate.go | 4 +- pkg/subnetmanager/subnet_validate.go | 24 +- pkg/subnetmanager/subnet_webhook.go | 14 +- pkg/subnetmanager/subnet_webhook_test.go | 72 +- pkg/utils/convert/convert.go | 38 +- pkg/workloadendpointmanager/utils.go | 4 +- pkg/workloadendpointmanager/utils_test.go | 16 +- .../workloadendpoint_manager.go | 46 +- .../workloadendpoint_manager_suite_test.go | 12 +- .../workloadendpoint_manager_test.go | 32 +- test/e2e/affinity/affinity_suite_test.go | 2 +- test/e2e/affinity/affinity_test.go | 12 +- test/e2e/annotation/annotation_suite_test.go | 2 +- test/e2e/annotation/annotation_test.go | 79 +- test/e2e/assignip/assiginip_suite_test.go | 2 +- test/e2e/assignip/assignip_test.go | 6 +- test/e2e/common/reservedip.go | 2 +- test/e2e/common/spiderpool.go | 37 +- test/e2e/common/spidersubnet.go | 2 +- .../macvlan_overlay_one_suite_test.go | 4 +- .../macvlan_overlay_one_test.go | 62 +- .../macvlan_underlay_one_suite_test.go | 2 +- .../macvlan_underlay_one_test.go | 12 +- test/e2e/ifacer/ifacer_suite_test.go | 2 +- test/e2e/ifacer/ifacer_test.go | 22 +- test/e2e/ippoolcr/ippoolcr_suite_test.go | 2 +- test/e2e/ippoolcr/ippoolcr_test.go | 82 +- test/e2e/kruise/kruise_suite_test.go | 2 +- test/e2e/kruise/kruise_test.go | 4 +- test/e2e/kubevirt/kubevirt_suite_test.go | 8 +- test/e2e/kubevirt/kubevirt_test.go | 4 +- .../e2e/performance/performance_suite_test.go | 2 +- test/e2e/performance/performance_test.go | 4 +- test/e2e/podwebhook/podwebhook_suite_test.go | 2 +- test/e2e/podwebhook/podwebhook_test.go | 3 +- test/e2e/reclaim/chaos_test.go | 2 +- test/e2e/reclaim/reclaim_suite_test.go | 2 +- test/e2e/reclaim/reclaim_test.go | 2 +- .../e2e/reliability/reliability_suite_test.go | 2 +- test/e2e/reservedip/reservedip_suite_test.go | 2 +- test/e2e/reservedip/reservedip_test.go | 8 +- .../spiderclaimparameter_suite_test.go | 35 - .../spiderclaimparameter_test.go | 159 --- .../spidercoordinator_suite_test.go | 10 +- .../spidercoordinator_test.go | 6 +- .../spidermultus/spidermultus_suite_test.go | 2 +- test/e2e/spidermultus/spidermultus_test.go | 180 ++- test/e2e/subnet/subnet_suite_test.go | 2 +- test/e2e/subnet/subnet_test.go | 2 +- test/scripts/install-multus.sh | 20 +- .../update-controller-gen.sh | 4 +- .../e2eframework/framework/spidermultus.go | 2 +- 236 files changed, 5427 insertions(+), 1628 deletions(-) create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/doc.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/groupversion_info.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/rbac.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/register.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/spidercoordinator_types.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderendpoint_types.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderippool_types.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/spidermultus_types.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderreservedip_types.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/spidersubnet_types.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/types_string.go create mode 100644 pkg/k8s/apis/spiderpool.spidernet.io/v1/zz_generated.deepcopy.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/doc.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/doc.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidercoordinator.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderippool.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidermultusconfig.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderpool.spidernet.io_client.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidersubnet.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/generated_expansion.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidercoordinator.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderippool.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidermultusconfig.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderpool.spidernet.io_client.go create mode 100644 pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidersubnet.go create mode 100644 pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/interface.go create mode 100644 pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidercoordinator.go create mode 100644 pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spiderippool.go create mode 100644 pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidermultusconfig.go create mode 100644 pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidersubnet.go create mode 100644 pkg/k8s/client/listers/spiderpool.spidernet.io/v1/expansion_generated.go create mode 100644 pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidercoordinator.go create mode 100644 pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spiderippool.go create mode 100644 pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidermultusconfig.go create mode 100644 pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidersubnet.go delete mode 100644 pkg/manager/spidercliamparameter/spidercliamparameter_webhook.go delete mode 100644 test/e2e/spiderclaimparameter/spiderclaimparameter_suite_test.go delete mode 100644 test/e2e/spiderclaimparameter/spiderclaimparameter_test.go diff --git a/charts/spiderpool/crds/spiderpool.spidernet.io_spidercoordinators.yaml b/charts/spiderpool/crds/spiderpool.spidernet.io_spidercoordinators.yaml index 00dc8d9239..2e0b517b8c 100644 --- a/charts/spiderpool/crds/spiderpool.spidernet.io_spidercoordinators.yaml +++ b/charts/spiderpool/crds/spiderpool.spidernet.io_spidercoordinators.yaml @@ -54,15 +54,6 @@ spec: items: type: string type: array - hostRPFilter: - default: 0 - description: 'HostRPFilter is used for coordiantor to help set the - rp_filter parameters of the node. NOTE: This field is considered - deprecated in the future. the rp_filter of the node should be configured - by spiderpool-agent rather than coordinator plugin. Configurable - values: /0/1/2, -1 means leave it as it is. the - default value is 0.' - type: integer hostRuleTable: default: 500 description: HostRuleTable specifies the table number of the routing diff --git a/charts/spiderpool/crds/spiderpool.spidernet.io_spiderippools.yaml b/charts/spiderpool/crds/spiderpool.spidernet.io_spiderippools.yaml index 4753a3b4df..cd0f40aeb5 100644 --- a/charts/spiderpool/crds/spiderpool.spidernet.io_spiderippools.yaml +++ b/charts/spiderpool/crds/spiderpool.spidernet.io_spiderippools.yaml @@ -277,12 +277,6 @@ spec: type: array subnet: type: string - vlan: - description: 'DEPRECATED: Vlan is deprecated.' - format: int64 - maximum: 4094 - minimum: 0 - type: integer required: - subnet type: object diff --git a/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml b/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml index 461d27a569..6059069d64 100644 --- a/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml +++ b/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml @@ -74,15 +74,6 @@ spec: items: type: string type: array - hostRPFilter: - default: 0 - description: 'HostRPFilter is used for coordiantor to help set - the rp_filter parameters of the node. NOTE: This field is considered - deprecated in the future. the rp_filter of the node should be - configured by spiderpool-agent rather than coordinator plugin. - Configurable values: /0/1/2, -1 means leave - it as it is. the default value is 0.' - type: integer hostRuleTable: default: 500 description: HostRuleTable specifies the table number of the routing @@ -163,6 +154,7 @@ spec: properties: ibKubernetesEnabled: default: false + description: Enforces ib-sriov-cni to work with ib-kubernetes. type: boolean ippools: description: SpiderpoolPools could specify the IPAM spiderpool @@ -179,17 +171,30 @@ spec: type: object linkState: default: enable + description: 'Enforces link state for the VF. Allowed values: + auto, enable, disable.' enum: - auto - enable - disable type: string pkey: + description: infiniBand pkey for VF, this field is used by ib-kubernetes + to add pkey with guid to InfiniBand subnet manager client e.g. + Mellanox UFM, OpenSM type: string rdmaIsolation: default: true + description: rdmaIsolation enablw RDMA CNI plugin is intended + to be run as a chained CNI plugin. it ensures isolation of RDMA + traffic from other workloads in the system by moving the associated + RDMA interfaces of the provided network interface to the container's + network namespace path. type: boolean resourceName: + description: The SR-IOV RDMA resource name of the SpiderMultusConfig. + the SR-IOV RDMA resource is often reported to kubelet by the + sriov-device-plugin. type: string required: - resourceName @@ -210,11 +215,14 @@ spec: type: array type: object master: + description: name of the host interface to create the link from. type: string type: object ipvlan: properties: bond: + description: Optional bond configuration for the CNI. It must + not be nil if the multiple master interfaces are specified. properties: mode: format: int32 @@ -229,10 +237,6 @@ spec: - mode - name type: object - enableRdma: - default: false - description: enable share rdma for ipvlan - type: boolean ippools: description: SpiderpoolPools could specify the IPAM spiderpool CNI configuration default IPv4&IPv6 pools. @@ -247,15 +251,23 @@ spec: type: array type: object master: + description: The master interface(s) for the CNI configuration. + At least one master interface must be specified. If multiple + master interfaces are specified, the spiderpool will create + a bond device with the bondConfig by the ifacer plugin. items: type: string type: array rdmaResourceName: - description: Resource name of the rdma device-plugin, If it's - empty and enableRdma is true, the value will be auto set by - operator. and the user can also set this value manually. + description: The RDMA resource name of the nic. the RDMA resource + is often reported to kubelet by the k8s-rdma-shared-dev-plugin. + when it is not empty and spiderpool podResourceInject feature + is enabled, spiderpool can automatically inject it into the + container's resources via webhook. type: string vlanID: + description: 'The VLAN ID for the CNI configuration, optional + and must be within the specified range: [0.4096).' format: int32 maximum: 4094 minimum: 0 @@ -266,6 +278,8 @@ spec: macvlan: properties: bond: + description: Optional bond configuration for the CNI. It must + not be nil if the multiple master interfaces are specified. properties: mode: format: int32 @@ -280,10 +294,6 @@ spec: - mode - name type: object - enableRdma: - default: false - description: enable share rdma for macvlan - type: boolean ippools: description: SpiderpoolPools could specify the IPAM spiderpool CNI configuration default IPv4&IPv6 pools. @@ -298,15 +308,23 @@ spec: type: array type: object master: + description: The master interface(s) for the CNI configuration. + At least one master interface must be specified. If multiple + master interfaces are specified, the spiderpool will create + a bond device with the bondConfig by the ifacer plugin. items: type: string type: array rdmaResourceName: - description: Resource name of the rdma device-plugin, If it's - empty and enableRdma is true, the value will be auto set by - operator. and the user can also set this value manually. + description: The RDMA resource name of the nic. the RDMA resource + is often reported to kubelet by the k8s-rdma-shared-dev-plugin. + when it is not empty and spiderpool podResourceInject feature + is enabled, spiderpool can automatically inject it into the + container's resources via webhook. type: string vlanID: + description: 'The VLAN ID for the CNI configuration, optional + and must be within the specified range: [0.4096).' format: int32 maximum: 4094 minimum: 0 @@ -361,6 +379,7 @@ spec: properties: enableRdma: default: false + description: DEPRECATED, use RdmaIsolation flled instead. type: boolean ippools: description: SpiderpoolPools could specify the IPAM spiderpool @@ -376,14 +395,28 @@ spec: type: array type: object maxTxRateMbps: + description: Mbps, 0 = disable rate limiting minimum: 0 type: integer minTxRateMbps: minimum: 0 type: integer + rdmaIsolation: + default: false + description: rdmaIsolation enable RDMA CNI plugin is intended + to be run as a chained CNI plugin. it ensures isolation of RDMA + traffic from other workloads in the system by moving the associated + RDMA interfaces of the provided network interface to the container's + network namespace path. + type: boolean resourceName: + description: The SR-IOV RDMA resource name of the SpiderMultusConfig. + the SR-IOV RDMA resource is often reported to kubelet by the + sriov-device-plugin. type: string vlanID: + description: 'The VLAN ID for the CNI configuration, optional + and must be within the specified range: [0.4096).' format: int32 maximum: 4094 minimum: 0 diff --git a/charts/spiderpool/crds/spiderpool.spidernet.io_spidersubnets.yaml b/charts/spiderpool/crds/spiderpool.spidernet.io_spidersubnets.yaml index 3a367467b3..3e324639dd 100644 --- a/charts/spiderpool/crds/spiderpool.spidernet.io_spidersubnets.yaml +++ b/charts/spiderpool/crds/spiderpool.spidernet.io_spidersubnets.yaml @@ -85,12 +85,6 @@ spec: type: array subnet: type: string - vlan: - description: 'DEPRECATED: Vlan is deprecated.' - format: int64 - maximum: 4094 - minimum: 0 - type: integer required: - subnet type: object diff --git a/cmd/spiderpool-agent/cmd/coordinator.go b/cmd/spiderpool-agent/cmd/coordinator.go index 1697d2a8ca..22609aefce 100644 --- a/cmd/spiderpool-agent/cmd/coordinator.go +++ b/cmd/spiderpool-agent/cmd/coordinator.go @@ -16,7 +16,7 @@ import ( "github.com/spidernet-io/spiderpool/api/v1/agent/server/restapi/daemonset" "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/coordinatormanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) var unixGetCoordinatorConfig = &_unixGetCoordinatorConfig{} @@ -30,7 +30,7 @@ func (g *_unixGetCoordinatorConfig) Handle(params daemonset.GetCoordinatorConfig podClient := agentContext.PodManager kubevirtMgr := agentContext.KubevirtManager - var coordList spiderpoolv2beta1.SpiderCoordinatorList + var coordList spiderpoolv1.SpiderCoordinatorList if err := crdClient.List(ctx, &coordList); err != nil { return daemonset.NewGetCoordinatorConfigFailure().WithPayload(models.Error(err.Error())) } diff --git a/cmd/spiderpool-agent/cmd/crd_manager.go b/cmd/spiderpool-agent/cmd/crd_manager.go index 8a37619aa8..db4ae54218 100644 --- a/cmd/spiderpool-agent/cmd/crd_manager.go +++ b/cmd/spiderpool-agent/cmd/crd_manager.go @@ -17,14 +17,14 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) var scheme = runtime.NewScheme() func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(spiderpoolv2beta1.AddToScheme(scheme)) + utilruntime.Must(spiderpoolv1.AddToScheme(scheme)) utilruntime.Must(kubevirtv1.AddToScheme(scheme)) } @@ -47,22 +47,22 @@ func newCRDManager() (ctrl.Manager, error) { return nil, err } - if err := mgr.GetFieldIndexer().IndexField(agentContext.InnerCtx, &spiderpoolv2beta1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + if err := mgr.GetFieldIndexer().IndexField(agentContext.InnerCtx, &spiderpoolv1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) return []string{strconv.FormatBool(*ipPool.Spec.Default)} }); err != nil { return nil, err } - if err := mgr.GetFieldIndexer().IndexField(agentContext.InnerCtx, &spiderpoolv2beta1.SpiderIPPool{}, constant.SpecIPVersionField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + if err := mgr.GetFieldIndexer().IndexField(agentContext.InnerCtx, &spiderpoolv1.SpiderIPPool{}, constant.SpecIPVersionField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) return []string{strconv.FormatInt(*ipPool.Spec.IPVersion, 10)} }); err != nil { return nil, err } - if err := mgr.GetFieldIndexer().IndexField(agentContext.InnerCtx, &spiderpoolv2beta1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { - reservedIP := raw.(*spiderpoolv2beta1.SpiderReservedIP) + if err := mgr.GetFieldIndexer().IndexField(agentContext.InnerCtx, &spiderpoolv1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { + reservedIP := raw.(*spiderpoolv1.SpiderReservedIP) return []string{strconv.FormatInt(*reservedIP.Spec.IPVersion, 10)} }); err != nil { return nil, err diff --git a/cmd/spiderpool-controller/cmd/clean.go b/cmd/spiderpool-controller/cmd/clean.go index bc1f86b923..168e3e89d1 100644 --- a/cmd/spiderpool-controller/cmd/clean.go +++ b/cmd/spiderpool-controller/cmd/clean.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/go-multierror" "github.com/spf13/cobra" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/k8s/utils" "github.com/spidernet-io/spiderpool/pkg/utils/retry" webhook "k8s.io/api/admissionregistration/v1" @@ -107,37 +107,32 @@ func (c *CoreClient) clean(validate, mutating string) error { } // Clean up SpiderIPPool resources of spiderpool - if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv2beta1.SpiderIPPoolList{}, constant.KindSpiderIPPool); err != nil { + if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv1.SpiderIPPoolList{}, constant.KindSpiderIPPool); err != nil { jobResult = multierror.Append(jobResult, err) } // Clean up SpiderSubnet resources of spiderpool - if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv2beta1.SpiderSubnetList{}, constant.KindSpiderSubnet); err != nil { + if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv1.SpiderSubnetList{}, constant.KindSpiderSubnet); err != nil { jobResult = multierror.Append(jobResult, err) } // Clean up SpiderEndpoint resources of spiderpool - if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv2beta1.SpiderEndpointList{}, constant.KindSpiderEndpoint); err != nil { + if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv1.SpiderEndpointList{}, constant.KindSpiderEndpoint); err != nil { jobResult = multierror.Append(jobResult, err) } // Clean up SpiderReservedIP resources of spiderpool - if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv2beta1.SpiderReservedIPList{}, constant.KindSpiderReservedIP); err != nil { + if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv1.SpiderReservedIPList{}, constant.KindSpiderReservedIP); err != nil { jobResult = multierror.Append(jobResult, err) } // Clean up SpiderMultusConfig resources of spiderpool - if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv2beta1.SpiderMultusConfigList{}, constant.KindSpiderMultusConfig); err != nil { + if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv1.SpiderMultusConfigList{}, constant.KindSpiderMultusConfig); err != nil { jobResult = multierror.Append(jobResult, err) } // Clean up SpiderCoordinator resources of spiderpool - if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv2beta1.SpiderCoordinatorList{}, constant.KindSpiderCoordinator); err != nil { - jobResult = multierror.Append(jobResult, err) - } - - // Clean up SpiderClaimParameter resources of spiderpool - if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv2beta1.SpiderClaimParameterList{}, constant.KindSpiderClaimParameter); err != nil { + if err := c.cleanSpiderpoolResources(ctx, &spiderpoolv1.SpiderCoordinatorList{}, constant.KindSpiderCoordinator); err != nil { jobResult = multierror.Append(jobResult, err) } diff --git a/cmd/spiderpool-controller/cmd/crd_manager.go b/cmd/spiderpool-controller/cmd/crd_manager.go index b50ed9ea6d..c16a5c3e86 100644 --- a/cmd/spiderpool-controller/cmd/crd_manager.go +++ b/cmd/spiderpool-controller/cmd/crd_manager.go @@ -24,14 +24,14 @@ import ( runtimeWebhook "sigs.k8s.io/controller-runtime/pkg/webhook" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) var scheme = runtime.NewScheme() func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(spiderpoolv2beta1.AddToScheme(scheme)) + utilruntime.Must(spiderpoolv1.AddToScheme(scheme)) utilruntime.Must(calicov1.AddToScheme(scheme)) utilruntime.Must(multusv1.AddToScheme(scheme)) utilruntime.Must(apiextensionsv1.AddToScheme(scheme)) @@ -67,15 +67,15 @@ func newCRDManager() (ctrl.Manager, error) { return nil, err } - if err := mgr.GetFieldIndexer().IndexField(controllerContext.InnerCtx, &spiderpoolv2beta1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + if err := mgr.GetFieldIndexer().IndexField(controllerContext.InnerCtx, &spiderpoolv1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) return []string{strconv.FormatBool(*ipPool.Spec.Default)} }); err != nil { return nil, err } - if err := mgr.GetFieldIndexer().IndexField(controllerContext.InnerCtx, &spiderpoolv2beta1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { - reservedIP := raw.(*spiderpoolv2beta1.SpiderReservedIP) + if err := mgr.GetFieldIndexer().IndexField(controllerContext.InnerCtx, &spiderpoolv1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { + reservedIP := raw.(*spiderpoolv1.SpiderReservedIP) return []string{strconv.FormatInt(*reservedIP.Spec.IPVersion, 10)} }); err != nil { return nil, err diff --git a/cmd/spiderpool-controller/cmd/metrics_server.go b/cmd/spiderpool-controller/cmd/metrics_server.go index bd05cb5c50..01419aa490 100644 --- a/cmd/spiderpool-controller/cmd/metrics_server.go +++ b/cmd/spiderpool-controller/cmd/metrics_server.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/metric" ) @@ -59,7 +59,7 @@ func monitorMetrics(ctx context.Context) { // record IPPool counts metric go wait.UntilWithContext(ctx, func(ctx context.Context) { - var poolList spiderpoolv2beta1.SpiderIPPoolList + var poolList spiderpoolv1.SpiderIPPoolList err := client.List(ctx, &poolList) if nil != err { logger.Sugar().Errorf("failed to monitor metric TotalIPPoolCounts, error: %v", err) @@ -71,7 +71,7 @@ func monitorMetrics(ctx context.Context) { if controllerContext.Cfg.EnableSpiderSubnet { // record Subnet counts metric go wait.UntilWithContext(ctx, func(ctx context.Context) { - var subnetList spiderpoolv2beta1.SpiderSubnetList + var subnetList spiderpoolv1.SpiderSubnetList err := client.List(ctx, &subnetList) if nil != err { logger.Sugar().Errorf("failed to monitor metric TotalSubnetCounts, error: %v", err) diff --git a/cmd/spiderpool-init/cmd/client.go b/cmd/spiderpool-init/cmd/client.go index 2e57bcbe5b..23fc0bac82 100644 --- a/cmd/spiderpool-init/cmd/client.go +++ b/cmd/spiderpool-init/cmd/client.go @@ -16,7 +16,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" ) @@ -24,7 +24,7 @@ var scheme = runtime.NewScheme() func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(spiderpoolv2beta1.AddToScheme(scheme)) + utilruntime.Must(spiderpoolv1.AddToScheme(scheme)) } const retryIntervalSec = 2 @@ -45,7 +45,7 @@ func NewCoreClient() (*CoreClient, error) { return &CoreClient{Client: client}, nil } -func (c *CoreClient) WaitForCoordinatorCreated(ctx context.Context, coord *spiderpoolv2beta1.SpiderCoordinator) error { +func (c *CoreClient) WaitForCoordinatorCreated(ctx context.Context, coord *spiderpoolv1.SpiderCoordinator) error { logger := logutils.FromContext(ctx) for { @@ -66,7 +66,7 @@ func (c *CoreClient) WaitForCoordinatorCreated(ctx context.Context, coord *spide } } -func (c *CoreClient) WaitForSubnetCreated(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) error { +func (c *CoreClient) WaitForSubnetCreated(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) error { logger := logutils.FromContext(ctx) for { @@ -87,7 +87,7 @@ func (c *CoreClient) WaitForSubnetCreated(ctx context.Context, subnet *spiderpoo } } -func (c *CoreClient) WaitForIPPoolCreated(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) error { +func (c *CoreClient) WaitForIPPoolCreated(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) error { logger := logutils.FromContext(ctx) for { @@ -140,7 +140,7 @@ func (c *CoreClient) CheckEndpointsAvailable(ctx context.Context, namespace, nam return false } -func (c *CoreClient) WaitMultusCNIConfigCreated(ctx context.Context, multuscniconfig *spiderpoolv2beta1.SpiderMultusConfig) error { +func (c *CoreClient) WaitMultusCNIConfigCreated(ctx context.Context, multuscniconfig *spiderpoolv1.SpiderMultusConfig) error { logger := logutils.FromContext(ctx) for { diff --git a/cmd/spiderpool-init/cmd/config.go b/cmd/spiderpool-init/cmd/config.go index 65fe70948c..a5138df2fb 100644 --- a/cmd/spiderpool-init/cmd/config.go +++ b/cmd/spiderpool-init/cmd/config.go @@ -16,7 +16,7 @@ import ( coordinatorcmd "github.com/spidernet-io/spiderpool/cmd/coordinator/cmd" "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) const ( @@ -351,7 +351,7 @@ func parseCNIFromConfig(cniConfigPath string) (string, string, error) { return cniName, cniType, nil } -func getMultusCniConfig(cniName, cniType string, ns string) *spiderpoolv2beta1.SpiderMultusConfig { +func getMultusCniConfig(cniName, cniType string, ns string) *spiderpoolv1.SpiderMultusConfig { annotations := make(map[string]string) // change calico cni name from k8s-pod-network to calico // more datails see: @@ -360,13 +360,13 @@ func getMultusCniConfig(cniName, cniType string, ns string) *spiderpoolv2beta1.S cniName = calicoCniName annotations[constant.AnnoNetAttachConfName] = legacyCalicoCniName } - return &spiderpoolv2beta1.SpiderMultusConfig{ + return &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: cniName, Namespace: ns, Annotations: annotations, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(cniType), EnableCoordinator: ptr.To(false), }, diff --git a/cmd/spiderpool-init/cmd/root.go b/cmd/spiderpool-init/cmd/root.go index 151ac337b2..8d7af2531c 100644 --- a/cmd/spiderpool-init/cmd/root.go +++ b/cmd/spiderpool-init/cmd/root.go @@ -11,7 +11,7 @@ import ( "k8s.io/utils/ptr" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" ) @@ -36,11 +36,11 @@ func Execute() { if len(config.CoordinatorName) != 0 { logger.Sugar().Infof("Try to create default Coordinator %s", config.CoordinatorName) - coord := &spiderpoolv2beta1.SpiderCoordinator{ + coord := &spiderpoolv1.SpiderCoordinator{ ObjectMeta: metav1.ObjectMeta{ Name: config.CoordinatorName, }, - Spec: spiderpoolv2beta1.CoordinatorSpec{ + Spec: spiderpoolv1.CoordinatorSpec{ Mode: &config.CoordinatorMode, PodCIDRType: &config.CoordinatorPodCIDRType, TunePodRoutes: &config.CoordinatorTunePodRoutes, @@ -60,11 +60,11 @@ func Execute() { if len(config.V4SubnetName) != 0 { logger.Sugar().Infof("Try to create default IPv4 Subnet %s", config.V4SubnetName) - subnet := &spiderpoolv2beta1.SpiderSubnet{ + subnet := &spiderpoolv1.SpiderSubnet{ ObjectMeta: metav1.ObjectMeta{ Name: config.V4SubnetName, }, - Spec: spiderpoolv2beta1.SubnetSpec{ + Spec: spiderpoolv1.SubnetSpec{ IPVersion: ptr.To(constant.IPv4), Subnet: config.V4CIDR, IPs: config.V4IPRanges, @@ -82,11 +82,11 @@ func Execute() { if len(config.V6SubnetName) != 0 { logger.Sugar().Infof("Try to create default IPv6 Subnet %s", config.V6SubnetName) - subnet := &spiderpoolv2beta1.SpiderSubnet{ + subnet := &spiderpoolv1.SpiderSubnet{ ObjectMeta: metav1.ObjectMeta{ Name: config.V6SubnetName, }, - Spec: spiderpoolv2beta1.SubnetSpec{ + Spec: spiderpoolv1.SubnetSpec{ IPVersion: ptr.To(constant.IPv6), Subnet: config.V6CIDR, IPs: config.V6IPRanges, @@ -104,11 +104,11 @@ func Execute() { if len(config.V4IPPoolName) != 0 { logger.Sugar().Infof("Try to create default IPv4 IPPool %s", config.V4IPPoolName) - ipPool := &spiderpoolv2beta1.SpiderIPPool{ + ipPool := &spiderpoolv1.SpiderIPPool{ ObjectMeta: metav1.ObjectMeta{ Name: config.V4IPPoolName, }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv4), Subnet: config.V4CIDR, IPs: config.V4IPRanges, @@ -127,11 +127,11 @@ func Execute() { if len(config.V6IPPoolName) != 0 { logger.Sugar().Infof("Try to create default IPv6 IPPool %s", config.V6IPPoolName) - ipPool := &spiderpoolv2beta1.SpiderIPPool{ + ipPool := &spiderpoolv1.SpiderIPPool{ ObjectMeta: metav1.ObjectMeta{ Name: config.V6IPPoolName, }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv6), Subnet: config.V6CIDR, IPs: config.V6IPRanges, diff --git a/docs/concepts/coordinator-zh_CN.md b/docs/concepts/coordinator-zh_CN.md index 4a958314de..b9f479ef00 100644 --- a/docs/concepts/coordinator-zh_CN.md +++ b/docs/concepts/coordinator-zh_CN.md @@ -64,7 +64,7 @@ ClusterIP 的路由,导致无法访问。 我们可以通过 Spidermultusconfig 配置它: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: detect-ip @@ -87,7 +87,7 @@ spec: 我们可以通过 Spidermultusconfig 配置它: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: detect-gateway @@ -117,7 +117,7 @@ spec: 我们可以通过 Spidermultusconfig 配置它: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: overwrite-mac @@ -138,7 +138,7 @@ spec: 传输队列长度(txqueuelen)是TCP/IP协议栈网络接口的一个值,它设置了网络接口设备内核传输队列中允许的数据包数量。如果txqueuelen值过小,可能导致在Pod之间的通信中丢失数据包。如果需要,我们可以对其进行配置: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: txqueue-demo @@ -157,7 +157,7 @@ spec: 默认情况下,Coordinator 不会为 veth0 网卡配置本地链路地址。但有些场景下(比如服务网格),经过 veth0 网卡流入的网格流量会随 istio 设置的 iptables 规则重定向,如果 veth0 没有 IP 地址,这会导致这部分流量被丢弃(见[#Issue3568](https://github.com/spidernet-io/spiderpool/issues/3568))。所以在这个场景下,我们需要为 veth0 配置一个本地链路地址。 ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: istio-demo @@ -201,7 +201,7 @@ status: type: Ready ~# kubectl get spidercoordinators.spiderpool.spidernet.io default -o yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderCoordinator metadata: creationTimestamp: "2024-01-25T08:41:50Z" diff --git a/docs/concepts/coordinator.md b/docs/concepts/coordinator.md index ffd053f5c8..d2e298c496 100644 --- a/docs/concepts/coordinator.md +++ b/docs/concepts/coordinator.md @@ -62,7 +62,7 @@ If the MAC address of the reply packet does not belong to the Pod NIC, we consid Additionally, we will default to release the whole allocated IPs for the **stateless** Pod to make it try to reallocate those no-conflict IPs in the next CNI call for the Pod. For the **stable** Pod with conflict IPs, we would not release its IPs to keep the IPs own the stable feature either. You can use spiderpool-agent [ENV](../reference/spiderpool-agent.md#env) `SPIDERPOOL_ENABLED_RELEASE_CONFLICT_IPS` to control this feature. ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: detect-ip @@ -85,7 +85,7 @@ Gateway addresses for IPv4 and IPv6 can be detected. We send an ARP probe packet We can configure it via Spidermultusconfig: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: detect-gateway @@ -117,7 +117,7 @@ Note: We can configure it via Spidermultusconfig: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: overwrite-mac @@ -140,7 +140,7 @@ The Transmit Queue Length (txqueuelen) is a TCP/IP stack network interface value We can configure it via Spidermultusconfig: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: txqueue-demo @@ -159,7 +159,7 @@ spec: By default, Coordinator does not configure a link-local address for the veth0 interface. However, in some scenarios (such as service mesh), mesh traffic flowing through the veth0 interface will be redirected according to iptables rules set by Istio. If veth0 does not have an IP address, this can cause that traffic to be dropped (see #Issue3568). Therefore, in this scenario, we need to configure a link-local address for veth0. ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: istio-demo @@ -203,7 +203,7 @@ status: type: Ready ~# kubectl get spidercoordinators.spiderpool.spidernet.io default -o yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderCoordinator metadata: creationTimestamp: "2024-01-25T08:41:50Z" diff --git a/docs/example/basic/custom-ipv4-ippool.yaml b/docs/example/basic/custom-ipv4-ippool.yaml index 5217f429dd..f74427acb4 100644 --- a/docs/example/basic/custom-ipv4-ippool.yaml +++ b/docs/example/basic/custom-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: custom-ipv4-ippool diff --git a/docs/example/basic/custom-ipv4-subnet.yaml b/docs/example/basic/custom-ipv4-subnet.yaml index 823da31406..4237b6eef0 100644 --- a/docs/example/basic/custom-ipv4-subnet.yaml +++ b/docs/example/basic/custom-ipv4-subnet.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: custom-ipv4-subnet diff --git a/docs/example/basic/custom-ipv6-ippool.yaml b/docs/example/basic/custom-ipv6-ippool.yaml index 842ceb9e78..cbba5e1104 100644 --- a/docs/example/basic/custom-ipv6-ippool.yaml +++ b/docs/example/basic/custom-ipv6-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: custom-ipv6-ippool diff --git a/docs/example/basic/custom-ipv6-subnet.yaml b/docs/example/basic/custom-ipv6-subnet.yaml index 8d6e143d81..25430ac81c 100644 --- a/docs/example/basic/custom-ipv6-subnet.yaml +++ b/docs/example/basic/custom-ipv6-subnet.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: custom-ipv6-subnet diff --git a/docs/example/ippool-affinity-node/master-ipv4-ippool.yaml b/docs/example/ippool-affinity-node/master-ipv4-ippool.yaml index cde1c5b3e1..aedf407701 100644 --- a/docs/example/ippool-affinity-node/master-ipv4-ippool.yaml +++ b/docs/example/ippool-affinity-node/master-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: master-ipv4-ippool diff --git a/docs/example/ippool-affinity-node/worker-ipv4-ippool.yaml b/docs/example/ippool-affinity-node/worker-ipv4-ippool.yaml index 2f7095ec39..c5dd2f540a 100644 --- a/docs/example/ippool-affinity-node/worker-ipv4-ippool.yaml +++ b/docs/example/ippool-affinity-node/worker-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: worker-ipv4-ippool diff --git a/docs/example/ippool-affinity-pod/occupied-static-ipv4-ippool.yaml b/docs/example/ippool-affinity-pod/occupied-static-ipv4-ippool.yaml index b73dc39702..c790d14a80 100644 --- a/docs/example/ippool-affinity-pod/occupied-static-ipv4-ippool.yaml +++ b/docs/example/ippool-affinity-pod/occupied-static-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: occupied-static-ipv4-ippool diff --git a/docs/example/ippool-affinity-pod/shared-static-ipv4-ippool.yaml b/docs/example/ippool-affinity-pod/shared-static-ipv4-ippool.yaml index e192ae7c78..147811e079 100644 --- a/docs/example/ippool-affinity-pod/shared-static-ipv4-ippool.yaml +++ b/docs/example/ippool-affinity-pod/shared-static-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: shared-static-ipv4-ippool diff --git a/docs/example/ippool-affinity-pod/static-ipv4-subnet.yaml b/docs/example/ippool-affinity-pod/static-ipv4-subnet.yaml index 893632279a..51789f8273 100644 --- a/docs/example/ippool-affinity-pod/static-ipv4-subnet.yaml +++ b/docs/example/ippool-affinity-pod/static-ipv4-subnet.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: static-ipv4-subnet diff --git a/docs/example/ippool-affnity-namespace/test-ns-ipv4-ippool.yaml b/docs/example/ippool-affnity-namespace/test-ns-ipv4-ippool.yaml index d490560413..ef51471d04 100644 --- a/docs/example/ippool-affnity-namespace/test-ns-ipv4-ippool.yaml +++ b/docs/example/ippool-affnity-namespace/test-ns-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: test-ns-ipv4-ippool diff --git a/docs/example/ippool-multi/test-ipv4-ippools.yaml b/docs/example/ippool-multi/test-ipv4-ippools.yaml index 0cb05cd79e..9475000c80 100644 --- a/docs/example/ippool-multi/test-ipv4-ippools.yaml +++ b/docs/example/ippool-multi/test-ipv4-ippools.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: default-ipv4-ippool @@ -9,7 +9,7 @@ spec: ips: - 172.18.41.40-172.18.41.41 --- -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: backup-ipv4-ippool diff --git a/docs/example/ippool-namespace/ns1-default-ipv4-ippool.yaml b/docs/example/ippool-namespace/ns1-default-ipv4-ippool.yaml index 4ef23eab09..1a4a1b78b0 100644 --- a/docs/example/ippool-namespace/ns1-default-ipv4-ippool.yaml +++ b/docs/example/ippool-namespace/ns1-default-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: ns1-default-ipv4-ippool diff --git a/docs/example/multi-interfaces-annotation/different-segment-ipv4-ippools.yaml b/docs/example/multi-interfaces-annotation/different-segment-ipv4-ippools.yaml index 3de5497379..b96c91047e 100644 --- a/docs/example/multi-interfaces-annotation/different-segment-ipv4-ippools.yaml +++ b/docs/example/multi-interfaces-annotation/different-segment-ipv4-ippools.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: ippool-test-ens192 @@ -8,7 +8,7 @@ spec: subnet: 10.6.0.1/16 gateway: 10.6.0.1 --- -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: ippool-test-ens224 diff --git a/docs/example/multi-interfaces-annotation/different-segment-ipv4-subnets.yaml b/docs/example/multi-interfaces-annotation/different-segment-ipv4-subnets.yaml index 4dbfcabab2..10975df97b 100644 --- a/docs/example/multi-interfaces-annotation/different-segment-ipv4-subnets.yaml +++ b/docs/example/multi-interfaces-annotation/different-segment-ipv4-subnets.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-test-ens192 @@ -9,7 +9,7 @@ spec: gateway: 10.6.0.1 vlan: 0 --- -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-test-ens224 diff --git a/docs/example/reserved-ip/already-in-use-ippool.yaml b/docs/example/reserved-ip/already-in-use-ippool.yaml index 08a24079e8..5c93289314 100644 --- a/docs/example/reserved-ip/already-in-use-ippool.yaml +++ b/docs/example/reserved-ip/already-in-use-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: already-in-use diff --git a/docs/example/reserved-ip/created-by-someone-else-ippool.yaml b/docs/example/reserved-ip/created-by-someone-else-ippool.yaml index 4f285ecfe9..7693c5a65d 100644 --- a/docs/example/reserved-ip/created-by-someone-else-ippool.yaml +++ b/docs/example/reserved-ip/created-by-someone-else-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: created-by-someone-else diff --git a/docs/example/reserved-ip/not-use-excludeips-ippool.yaml b/docs/example/reserved-ip/not-use-excludeips-ippool.yaml index ecb3b5c825..5a416cce0e 100644 --- a/docs/example/reserved-ip/not-use-excludeips-ippool.yaml +++ b/docs/example/reserved-ip/not-use-excludeips-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: not-use-excludeips diff --git a/docs/example/reserved-ip/test-ipv4-ippool.yaml b/docs/example/reserved-ip/test-ipv4-ippool.yaml index a54d87dfbc..184be651b9 100644 --- a/docs/example/reserved-ip/test-ipv4-ippool.yaml +++ b/docs/example/reserved-ip/test-ipv4-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: test-ipv4-ippool diff --git a/docs/example/reserved-ip/test-ipv4-reservedip.yaml b/docs/example/reserved-ip/test-ipv4-reservedip.yaml index 481d246949..366f708246 100644 --- a/docs/example/reserved-ip/test-ipv4-reservedip.yaml +++ b/docs/example/reserved-ip/test-ipv4-reservedip.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderReservedIP metadata: name: test-ipv4-reservedip diff --git a/docs/example/reserved-ip/use-excludeips-ippool.yaml b/docs/example/reserved-ip/use-excludeips-ippool.yaml index 6bc0941dd8..80a1827f6e 100644 --- a/docs/example/reserved-ip/use-excludeips-ippool.yaml +++ b/docs/example/reserved-ip/use-excludeips-ippool.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: use-excludeips diff --git a/docs/example/route/ippool-route.yaml b/docs/example/route/ippool-route.yaml index 4d831b4f18..0692782b11 100644 --- a/docs/example/route/ippool-route.yaml +++ b/docs/example/route/ippool-route.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: ipv4-ippool-route diff --git a/docs/example/route/subnet-route.yaml b/docs/example/route/subnet-route.yaml index f68b749b2b..33c799dfd3 100644 --- a/docs/example/route/subnet-route.yaml +++ b/docs/example/route/subnet-route.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: ipv4-subnet-route diff --git a/docs/example/spider-subnet/multiple-interfaces.yaml b/docs/example/spider-subnet/multiple-interfaces.yaml index 720fdff8ef..548a036405 100644 --- a/docs/example/spider-subnet/multiple-interfaces.yaml +++ b/docs/example/spider-subnet/multiple-interfaces.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-demo-v4-1 @@ -7,7 +7,7 @@ spec: ips: - 172.15.41.1-172.15.41.200 --- -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-demo-v6-1 @@ -16,7 +16,7 @@ spec: ips: - 2002::ac0f:2901-2002::ac0f:29c8 --- -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-demo-v4-2 @@ -25,7 +25,7 @@ spec: ips: - 172.14.41.1-172.14.41.200 --- -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-demo-v6-2 diff --git a/docs/example/spider-subnet/subnet-demo.yaml b/docs/example/spider-subnet/subnet-demo.yaml index 05ae1405d9..fb5af4bb28 100644 --- a/docs/example/spider-subnet/subnet-demo.yaml +++ b/docs/example/spider-subnet/subnet-demo.yaml @@ -1,4 +1,4 @@ -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-demo-v4 @@ -7,7 +7,7 @@ spec: ips: - 172.16.41.1-172.16.41.200 --- -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: subnet-demo-v6 diff --git a/docs/reference/crd-spiderclaimparameter.md b/docs/reference/crd-spiderclaimparameter.md index 296c208fb7..5a6f1fc163 100644 --- a/docs/reference/crd-spiderclaimparameter.md +++ b/docs/reference/crd-spiderclaimparameter.md @@ -5,7 +5,7 @@ A SpiderClaimParameter resource is used to describe the resourceclaim and affect ## Sample YAML ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderClaimParameter metadata: name: demo diff --git a/docs/reference/crd-spidercoordinator.md b/docs/reference/crd-spidercoordinator.md index 23ba528b46..b3d02ef85e 100644 --- a/docs/reference/crd-spidercoordinator.md +++ b/docs/reference/crd-spidercoordinator.md @@ -7,7 +7,7 @@ A Spidercoordinator resource represents the global default configuration of the ## Sample YAML ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderCoordinator metadata: name: default diff --git a/docs/reference/crd-spiderendpoint.md b/docs/reference/crd-spiderendpoint.md index 237a670d16..2bcc7f8126 100644 --- a/docs/reference/crd-spiderendpoint.md +++ b/docs/reference/crd-spiderendpoint.md @@ -7,7 +7,7 @@ A SpiderEndpoint resource represents IP address allocation details for the corre ## Sample YAML ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderEndpoint metadata: name: test-app-1-9dc78fb9-rs99d diff --git a/docs/reference/crd-spiderippool.md b/docs/reference/crd-spiderippool.md index 0372a00c96..cdc9f85e89 100644 --- a/docs/reference/crd-spiderippool.md +++ b/docs/reference/crd-spiderippool.md @@ -5,7 +5,7 @@ A SpiderIPPool resource represents a collection of IP addresses from which Spide ## Sample YAML ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: master-172 diff --git a/docs/reference/crd-spidermultusconfig.md b/docs/reference/crd-spidermultusconfig.md index 3ce8f583c2..25b6a5a34e 100644 --- a/docs/reference/crd-spidermultusconfig.md +++ b/docs/reference/crd-spidermultusconfig.md @@ -7,7 +7,7 @@ For details on using this CRD, please read the [SpiderMultusConfig guide](./../u ## Sample YAML ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: demo @@ -71,6 +71,7 @@ This is the SpiderReservedIP spec for users to configure. | master | the Interfaces on your master, you could specify a single one Interface
or multiple Interfaces to generate one bond Interface | list of strings | required | | | vlanID | vlan ID | int | optional | [0,4094] | | bond | expected bond Interface configurations | [BondConfig](./crd-spidermultusconfig.md#bondconfig) | optional | | +| rdmaResourceName | rdma resource name of the spiderMultusConfig, it often reported to kubelet by the k8s-rdma-shared-dev-plugin. when it is not empty and spiderpool podResourceInject feature is enabled, spiderpool can automatically inject it into the container's resources via webhook | string | optional | | | ippools | the default IPPools in your CNI configurations | [SpiderpoolPools](./crd-spidermultusconfig.md#spiderpoolpools) | optional | | #### SpiderIPvlanCniConfig @@ -80,24 +81,26 @@ This is the SpiderReservedIP spec for users to configure. | master | the Interfaces on your master, you could specify a single one Interface
or multiple Interfaces to generate one bond Interface | list of strings | required | | | vlanID | vlan ID | int | optional | [0,4094] | | bond | expected bond Interface configurations | [BondConfig](./crd-spidermultusconfig.md#bondconfig) | optional | | +| rdmaResourceName | rdma resource name of the spiderMultusConfig, it often reported to kubelet by the k8s-rdma-shared-dev-plugin. when it is not empty and spiderpool podResourceInject feature is enabled, spiderpool can automatically inject it into the container's resources via webhook | string | optional | | | ippools | the default IPPools in your CNI configurations | [SpiderpoolPools](./crd-spidermultusconfig.md#spiderpoolpools) | optional | | #### SpiderSRIOVCniConfig | Field | Description | Schema | Validation | |---------------|-------------------------------------------------------------------------------------------|----------------------------------------------------------------|------------| -| resourceName | this property will create an annotation for Multus net-attach-def to cooperate with SRIOV | string | required | +| resourceName | this property will create an annotation for Multus net-attach-def to cooperate with SRIOV, if spiderpool podResourceInject feature is enabled, spiderpool can automatically inject it into the container's resources via webhook | string | required | | vlanID | vlan ID | int | optional | | minTxRateMbps | change the allowed minimum transmit bandwidth, in Mbps, for the VF. Setting this to 0 disables rate limiting. The min_tx_rate value should be <= max_tx_rate. Support of this feature depends on NICs and drivers | int | optional | | maxTxRateMbps | change the allowed maximum transmit bandwidth, in Mbps, for the VF. Setting this to 0 disables rate limiting | int | optional | -| enableRdma | enable rdma chain cni to isolate the rdma device | bool | optional | +| enableRdma(deprecated) | It will be remove in the furture, use rdmaIsolation instead. | bool | optional | + rdmaIsolation | rdmaIsolation enable RDMA CNI plugin is intended to be run as a chained CNI plugin. it ensures isolation of RDMA traffic from other workloads in the system by moving the associated RDMA interfaces of the provided network interface to the container's network namespace path. | bool | optional | | ippools | the default IPPools in your CNI configurations | [SpiderpoolPools](./crd-spidermultusconfig.md#spiderpoolpools) | optional | #### SpiderIBSRIOVCniConfig | Field | Description | Schema | Validation | |----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|------------| -| resourceName | this property will create an annotation for Multus net-attach-def to cooperate with ib-sriov | string | required | +| resourceName | this property will create an annotation for Multus net-attach-def to cooperate with SRIOV, if spiderpool podResourceInject feature is enabled, spiderpool can automatically inject it into the container's resources via webhook | string | required | | pkey | InfiniBand pkey for VF, this field is used by [ib-kubernetes](https://github.com/Mellanox/ib-kubernetes) to add pkey with guid to InfiniBand subnet manager client e.g. [Mellanox UFM](https://www.nvidia.com/en-us/networking/infiniband/ufm/) | string | optional | | linkState | Enforces link state for the VF. Allowed values: auto, enable [default], disable | string | optional | | rdmaIsolation | Enable RDMA network namespace isolation for RDMA workloads, default to true | bool | optional | diff --git a/docs/reference/crd-spiderreservedip.md b/docs/reference/crd-spiderreservedip.md index 4f2eefad30..8647f7a2ee 100644 --- a/docs/reference/crd-spiderreservedip.md +++ b/docs/reference/crd-spiderreservedip.md @@ -7,7 +7,7 @@ For details on using this CRD, please read the [SpiderReservedIP guide](./../usa ## Sample YAML ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: exclude-ips diff --git a/docs/reference/crd-spidersubnet.md b/docs/reference/crd-spidersubnet.md index f6fe247cc6..6962aaca35 100644 --- a/docs/reference/crd-spidersubnet.md +++ b/docs/reference/crd-spidersubnet.md @@ -7,7 +7,7 @@ For details on using this CRD, please read the [SpiderSubnet guide](./../usage/s ## Sample YAML ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderSubnet metadata: name: default-v4-subnet diff --git a/docs/usage/install/ai/get-started-macvlan-zh_CN.md b/docs/usage/install/ai/get-started-macvlan-zh_CN.md index 6fd0586d3b..fb1c10ef46 100644 --- a/docs/usage/install/ai/get-started-macvlan-zh_CN.md +++ b/docs/usage/install/ai/get-started-macvlan-zh_CN.md @@ -221,7 +221,7 @@ ```shell $ cat < - `dst` 和 `gw` 字段都为必填 ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: ipv4-ippool-route diff --git a/docs/usage/route.md b/docs/usage/route.md index 139cfe7eb6..27a85c5d8e 100644 --- a/docs/usage/route.md +++ b/docs/usage/route.md @@ -11,7 +11,7 @@ Spiderpool supports the configuration of routing information for Pods. When setting the **gateway address** (`spec.gateway`) for a SpiderIPPool resource, a default route will be generated for Pods based on that gateway address: ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: ipv4-ippool-route @@ -30,7 +30,7 @@ SpiderIPPool resources also support configuring routes (`spec.routes`), which w > - Both `dst` and `gw` fields are required. ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: ipv4-ippool-route diff --git a/docs/usage/spider-affinity-zh_CN.md b/docs/usage/spider-affinity-zh_CN.md index 603afac04e..4c5d3d300b 100644 --- a/docs/usage/spider-affinity-zh_CN.md +++ b/docs/usage/spider-affinity-zh_CN.md @@ -18,7 +18,7 @@ SpiderIPPool 资源代表 IP 地址的集合,一个 Subnet 中的不同 IP 地 这些字段不仅起到**过滤**的作用,同时也会起到一个**排序**的效果,若匹配的字段越多,越优先使用该 IP 池。 ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: test-pod-ippool @@ -61,7 +61,7 @@ SpiderIPPool 提供了 `podAffinity` 字段,当应用创建时,尝试从 Spi ```bash ~# cat < - 可为多个 IPPool 资源设置为集群默认级别。 ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: master-172 diff --git a/docs/usage/spider-ippool.md b/docs/usage/spider-ippool.md index 4bd5c64ae4..e84b4d0201 100644 --- a/docs/usage/spider-ippool.md +++ b/docs/usage/spider-ippool.md @@ -152,7 +152,7 @@ In the [SpiderIPPool CRD](./../reference/crd-spiderippool.md), the `spec.default > - Multiple IPPool resources can be set as the cluster default level. ```yaml -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderIPPool metadata: name: master-172 diff --git a/docs/usage/spider-multus-config-zh_CN.md b/docs/usage/spider-multus-config-zh_CN.md index c5a1a9e4d6..de2b6fc077 100644 --- a/docs/usage/spider-multus-config-zh_CN.md +++ b/docs/usage/spider-multus-config-zh_CN.md @@ -109,7 +109,7 @@ MACVLAN_MASTER_INTERFACE="ens192" MACVLAN_MULTUS_NAME="macvlan-$MACVLAN_MASTER_INTERFACE" cat < Delete -> Create a Pod with the same namespace and name in @@ -292,7 +292,7 @@ func (i *ipam) retrieveExistingIPAllocation(ctx context.Context, uid, nic string return addResp, nil } -func (i *ipam) allocateInStandardMode(ctx context.Context, addArgs *models.IpamAddArgs, pod *corev1.Pod, endpoint *spiderpoolv2beta1.SpiderEndpoint, podController types.PodTopController) (*models.IpamAddResponse, error) { +func (i *ipam) allocateInStandardMode(ctx context.Context, addArgs *models.IpamAddArgs, pod *corev1.Pod, endpoint *spiderpoolv1.SpiderEndpoint, podController types.PodTopController) (*models.IpamAddResponse, error) { logger := logutils.FromContext(ctx) isMultipleNicWithNoName := IsMultipleNicWithNoName(pod.Annotations) @@ -582,7 +582,7 @@ func (i *ipam) filterPoolCandidates(ctx context.Context, t *ToBeAllocated, pod * return nil } -func (i *ipam) selectByPod(ctx context.Context, version types.IPVersion, ipPool *spiderpoolv2beta1.SpiderIPPool, pod *corev1.Pod, podTopController types.PodTopController, nic string) error { +func (i *ipam) selectByPod(ctx context.Context, version types.IPVersion, ipPool *spiderpoolv1.SpiderIPPool, pod *corev1.Pod, podTopController types.PodTopController, nic string) error { if ipPool.DeletionTimestamp != nil { return fmt.Errorf("terminating IPPool %s", ipPool.Name) } @@ -740,7 +740,7 @@ func (i *ipam) selectByPod(ctx context.Context, version types.IPVersion, ipPool func (i *ipam) verifyPoolCandidates(tt ToBeAllocateds) error { // for _, t := range tt { - // var allIPPools []*spiderpoolv2beta1.SpiderIPPool + // var allIPPools []*spiderpoolv1.SpiderIPPool // for _, c := range t.PoolCandidates { // allIPPools = append(allIPPools, c.PToIPPool.IPPools()...) // } @@ -766,7 +766,7 @@ func sortPoolCandidates(preliminary ToBeAllocateds) { poolNameList := []string{} // collect all IPPool resource from PoolCandidate.PToIPPool - pools := []*spiderpoolv2beta1.SpiderIPPool{} + pools := []*spiderpoolv1.SpiderIPPool{} for _, tmpPool := range poolCandidate.PToIPPool { pools = append(pools, tmpPool.DeepCopy()) } diff --git a/pkg/ipam/pool_selections.go b/pkg/ipam/pool_selections.go index 1aa2854326..c03d6f37f5 100644 --- a/pkg/ipam/pool_selections.go +++ b/pkg/ipam/pool_selections.go @@ -20,7 +20,7 @@ import ( "github.com/spidernet-io/spiderpool/api/v1/agent/models" "github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/namespacemanager" "github.com/spidernet-io/spiderpool/pkg/types" @@ -131,7 +131,7 @@ func (i *ipam) getPoolFromSubnetAnno(ctx context.Context, pod *corev1.Pod, nic s return nil, err } - var v4PoolCandidate, v6PoolCandidate *spiderpoolv2beta1.SpiderIPPool + var v4PoolCandidate, v6PoolCandidate *spiderpoolv1.SpiderIPPool var errV4, errV6 error var wg sync.WaitGroup @@ -210,10 +210,10 @@ func (i *ipam) getPoolFromSubnetAnno(ctx context.Context, pod *corev1.Pod, nic s } // findAppAutoPool only fetches kubernetes basic controller(like Deployment, StatefulSet etc...) corresponding auto-created IPPools. -func (i *ipam) findAppAutoPool(ctx context.Context, subnetName, ifName, labelIPPoolIPVersionValue string, desiredIPNumber int, podController types.PodTopController) (*spiderpoolv2beta1.SpiderIPPool, error) { +func (i *ipam) findAppAutoPool(ctx context.Context, subnetName, ifName, labelIPPoolIPVersionValue string, desiredIPNumber int, podController types.PodTopController) (*spiderpoolv1.SpiderIPPool, error) { log := logutils.FromContext(ctx) - var pool *spiderpoolv2beta1.SpiderIPPool + var pool *spiderpoolv1.SpiderIPPool matchLabels := client.MatchingLabels{ constant.LabelIPPoolOwnerSpiderSubnet: subnetName, constant.LabelIPPoolOwnerApplicationGV: applicationinformers.ApplicationLabelGV(podController.APIVersion), @@ -259,10 +259,10 @@ func (i *ipam) findAppAutoPool(ctx context.Context, subnetName, ifName, labelIPP // applyThirdControllerAutoPool will fetch or reconcile third-party controller corresponding auto-created IPPools, // and the kubernetes basic controller like Deployment,StatefulSet etc... We'll reconcile their auto-created IPPools in spiderpool-controller component. -func (i *ipam) applyThirdControllerAutoPool(ctx context.Context, subnetName string, podController types.PodTopController, autoPoolProperty types.AutoPoolProperty) (*spiderpoolv2beta1.SpiderIPPool, error) { +func (i *ipam) applyThirdControllerAutoPool(ctx context.Context, subnetName string, podController types.PodTopController, autoPoolProperty types.AutoPoolProperty) (*spiderpoolv1.SpiderIPPool, error) { log := logutils.FromContext(ctx) - var pool *spiderpoolv2beta1.SpiderIPPool + var pool *spiderpoolv1.SpiderIPPool matchLabels := client.MatchingLabels{ constant.LabelIPPoolOwnerSpiderSubnet: subnetName, constant.LabelIPPoolOwnerApplicationGV: applicationinformers.ApplicationLabelGV(podController.APIVersion), diff --git a/pkg/ipam/release.go b/pkg/ipam/release.go index 887e7b78f6..08ce8039fb 100644 --- a/pkg/ipam/release.go +++ b/pkg/ipam/release.go @@ -20,7 +20,7 @@ import ( "github.com/spidernet-io/spiderpool/api/v1/agent/models" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/metric" "github.com/spidernet-io/spiderpool/pkg/podmanager" @@ -105,7 +105,7 @@ func (i *ipam) Release(ctx context.Context, delArgs *models.IpamDelArgs) error { return nil } -func (i *ipam) releaseForAllNICs(ctx context.Context, uid, nic string, endpoint *spiderpoolv2beta1.SpiderEndpoint) error { +func (i *ipam) releaseForAllNICs(ctx context.Context, uid, nic string, endpoint *spiderpoolv1.SpiderEndpoint) error { logger := logutils.FromContext(ctx) // Check whether an StatefulSet needs to release its currently allocated IP addresses. @@ -162,7 +162,7 @@ func (i *ipam) releaseForAllNICs(ctx context.Context, uid, nic string, endpoint return nil } -func (i *ipam) release(ctx context.Context, uid string, details []spiderpoolv2beta1.IPAllocationDetail) error { +func (i *ipam) release(ctx context.Context, uid string, details []spiderpoolv1.IPAllocationDetail) error { logger := logutils.FromContext(ctx) pius := convert.GroupIPAllocationDetails(uid, details) diff --git a/pkg/ipam/types.go b/pkg/ipam/types.go index 5014493651..86ca545d00 100644 --- a/pkg/ipam/types.go +++ b/pkg/ipam/types.go @@ -6,7 +6,7 @@ package ipam import ( "fmt" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" ) @@ -59,10 +59,10 @@ func (c *PoolCandidate) String() string { return fmt.Sprintf("%+v", *c) } -type PoolNameToIPPool map[string]*spiderpoolv2beta1.SpiderIPPool +type PoolNameToIPPool map[string]*spiderpoolv1.SpiderIPPool -func (ptp *PoolNameToIPPool) IPPools() []*spiderpoolv2beta1.SpiderIPPool { - var ipPools []*spiderpoolv2beta1.SpiderIPPool +func (ptp *PoolNameToIPPool) IPPools() []*spiderpoolv1.SpiderIPPool { + var ipPools []*spiderpoolv1.SpiderIPPool for _, p := range *ptp { ipPools = append(ipPools, p) } diff --git a/pkg/ipam/utils.go b/pkg/ipam/utils.go index 433b513682..519905242f 100644 --- a/pkg/ipam/utils.go +++ b/pkg/ipam/utils.go @@ -7,18 +7,19 @@ import ( "context" "encoding/json" "fmt" + "net" + "strconv" + appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" "k8s.io/utils/strings/slices" - "net" - "strconv" "github.com/spidernet-io/spiderpool/api/v1/agent/models" subnetmanagercontrollers "github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers" "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/utils/convert" @@ -148,8 +149,8 @@ func getAutoPoolIPNumber(pod *corev1.Pod, podController types.PodTopController) return poolIPNum, nil } -// isPoolIPsDesired checks the auto-created IPPool's IPs whether matches its AutoDesiredIPCount -func isPoolIPsDesired(pool *spiderpoolv2beta1.SpiderIPPool, desiredIPCount int) bool { +// isPoolIPsDesired checks tspiderpoolv1PPool's IPs whether matches its AutoDesiredIPCount +func isPoolIPsDesired(pool *spiderpoolv1.SpiderIPPool, desiredIPCount int) bool { totalIPs, err := spiderpoolip.AssembleTotalIPs(*pool.Spec.IPVersion, pool.Spec.IPs, pool.Spec.ExcludeIPs) if nil != err { return false diff --git a/pkg/ippoolmanager/ippool_informer.go b/pkg/ippoolmanager/ippool_informer.go index 6cba9e95d0..1d610a6afa 100644 --- a/pkg/ippoolmanager/ippool_informer.go +++ b/pkg/ippoolmanager/ippool_informer.go @@ -26,11 +26,11 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/election" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" crdclientset "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions" - informers "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v2beta1" - listers "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v2beta1" + informers "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1" + listers "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/metric" "github.com/spidernet-io/spiderpool/pkg/types" @@ -109,7 +109,7 @@ func (ic *IPPoolController) SetupInformer(ctx context.Context, client crdclients informerLogger.Info("create SpiderIPPool informer") factory := externalversions.NewSharedInformerFactory(client, ic.ResyncPeriod) - err := ic.addEventHandlers(factory.Spiderpool().V2beta1().SpiderIPPools()) + err := ic.addEventHandlers(factory.Spiderpool().V1().SpiderIPPools()) if nil != err { informerLogger.Error(err.Error()) continue @@ -151,7 +151,7 @@ func (ic *IPPoolController) addEventHandlers(poolInformer informers.SpiderIPPool // enqueueIPPool will check the given pool and enqueue them into different workqueue func (ic *IPPoolController) enqueueIPPool(obj interface{}) { - pool := obj.(*spiderpoolv2beta1.SpiderIPPool) + pool := obj.(*spiderpoolv1.SpiderIPPool) // the Normal IPPools enqueue the corresponding NormalPoolWorkqueue if ic.poolWorkqueue.Len() >= ic.MaxWorkqueueLength { @@ -266,7 +266,7 @@ func (ic *IPPoolController) processNextWorkItem() bool { return true } -func (ic *IPPoolController) handleIPPool(ctx context.Context, pool *spiderpoolv2beta1.SpiderIPPool) (err error) { +func (ic *IPPoolController) handleIPPool(ctx context.Context, pool *spiderpoolv1.SpiderIPPool) (err error) { // checkout the Auto-created IPPools whether need to scale or clean up legacies if ic.EnableSpiderSubnet && ic.EnableAutoPoolForApplication && IsAutoCreatedIPPool(pool) { err := ic.cleanAutoIPPoolLegacy(ctx, pool) @@ -297,7 +297,7 @@ func (ic *IPPoolController) handleIPPool(ctx context.Context, pool *spiderpoolv2 // syncHandler will calculate and update the provided SpiderIPPool status AllocatedIPCount or TotalIPCount. // And it will also remove finalizer once the IPPool is dying and no longer being used. -func (ic *IPPoolController) syncHandler(ctx context.Context, pool *spiderpoolv2beta1.SpiderIPPool) error { +func (ic *IPPoolController) syncHandler(ctx context.Context, pool *spiderpoolv1.SpiderIPPool) error { //remove finalizer to delete the dying IPPool when the IPPool is no longer being used if pool.DeletionTimestamp != nil && pool.Status.AllocatedIPs == nil { err := ic.removeFinalizer(ctx, pool) @@ -339,7 +339,7 @@ func (ic *IPPoolController) syncHandler(ctx context.Context, pool *spiderpoolv2b } // removeFinalizer removes SpiderIPPool finalizer -func (ic *IPPoolController) removeFinalizer(ctx context.Context, pool *spiderpoolv2beta1.SpiderIPPool) error { +func (ic *IPPoolController) removeFinalizer(ctx context.Context, pool *spiderpoolv1.SpiderIPPool) error { if !controllerutil.ContainsFinalizer(pool, constant.SpiderFinalizer) { return nil } @@ -354,7 +354,7 @@ func (ic *IPPoolController) removeFinalizer(ctx context.Context, pool *spiderpoo } // cleanAutoIPPoolLegacy checks whether the given IPPool should be deleted or not -func (ic *IPPoolController) cleanAutoIPPoolLegacy(ctx context.Context, pool *spiderpoolv2beta1.SpiderIPPool) error { +func (ic *IPPoolController) cleanAutoIPPoolLegacy(ctx context.Context, pool *spiderpoolv1.SpiderIPPool) error { if pool.DeletionTimestamp != nil { return nil } diff --git a/pkg/ippoolmanager/ippool_informer_test.go b/pkg/ippoolmanager/ippool_informer_test.go index 605bea4711..5ea7b92726 100644 --- a/pkg/ippoolmanager/ippool_informer_test.go +++ b/pkg/ippoolmanager/ippool_informer_test.go @@ -23,7 +23,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" spiderpoolfake "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/fake" "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions" "github.com/spidernet-io/spiderpool/pkg/metric" @@ -37,9 +37,9 @@ var _ = Describe("IPPool-informer", Label("unittest"), Ordered, func() { Expect(err).NotTo(HaveOccurred()) }) - var pool *spiderpoolv2beta1.SpiderIPPool + var pool *spiderpoolv1.SpiderIPPool BeforeEach(func() { - pool = &spiderpoolv2beta1.SpiderIPPool{ + pool = &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -48,12 +48,12 @@ var _ = Describe("IPPool-informer", Label("unittest"), Ordered, func() { Name: "test-ippool", Labels: map[string]string{}, }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(int64(4)), Subnet: "10.1.0.0/16", IPs: []string{"10.1.0.1-10.1.0.10"}, }, - Status: spiderpoolv2beta1.IPPoolStatus{ + Status: spiderpoolv1.IPPoolStatus{ AllocatedIPs: nil, TotalIPCount: ptr.To(int64(10)), AllocatedIPCount: ptr.To(int64(0)), @@ -65,7 +65,7 @@ var _ = Describe("IPPool-informer", Label("unittest"), Ordered, func() { var control *poolController BeforeEach(func() { scheme = runtime.NewScheme() - err := spiderpoolv2beta1.AddToScheme(scheme) + err := spiderpoolv1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) err = appsv1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) @@ -73,7 +73,7 @@ var _ = Describe("IPPool-informer", Label("unittest"), Ordered, func() { control = newController() fakeClientSet := spiderpoolfake.NewSimpleClientset() factory := externalversions.NewSharedInformerFactory(fakeClientSet, 0) - err = control.addEventHandlers(factory.Spiderpool().V2beta1().SpiderIPPools()) + err = control.addEventHandlers(factory.Spiderpool().V1().SpiderIPPools()) Expect(err).NotTo(HaveOccurred()) control.ipPoolStore = factory.Spiderpool().V2beta1().SpiderIPPools().Informer().GetStore() }) @@ -83,7 +83,7 @@ var _ = Describe("IPPool-informer", Label("unittest"), Ordered, func() { ctx, cancel := context.WithCancel(context.TODO()) defer cancel() - pool.Status = spiderpoolv2beta1.IPPoolStatus{} + pool.Status = spiderpoolv1.IPPoolStatus{} go func() { defer GinkgoRecover() diff --git a/pkg/ippoolmanager/ippool_manager.go b/pkg/ippoolmanager/ippool_manager.go index febbf9e1a6..c3c88c0e34 100644 --- a/pkg/ippoolmanager/ippool_manager.go +++ b/pkg/ippoolmanager/ippool_manager.go @@ -21,7 +21,7 @@ import ( "github.com/spidernet-io/spiderpool/api/v1/agent/models" "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/metric" "github.com/spidernet-io/spiderpool/pkg/reservedipmanager" @@ -31,8 +31,8 @@ import ( ) type IPPoolManager interface { - GetIPPoolByName(ctx context.Context, poolName string, cached bool) (*spiderpoolv2beta1.SpiderIPPool, error) - ListIPPools(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderIPPoolList, error) + GetIPPoolByName(ctx context.Context, poolName string, cached bool) (*spiderpoolv1.SpiderIPPool, error) + ListIPPools(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderIPPoolList, error) AllocateIP(ctx context.Context, poolName, nic string, pod *corev1.Pod, podController types.PodTopController) (*models.IPConfig, error) ReleaseIP(ctx context.Context, poolName string, ipAndUIDs []types.IPAndUID) error UpdateAllocatedIPs(ctx context.Context, poolName, namespacedName string, ipAndCIDs []types.IPAndUID) error @@ -65,13 +65,13 @@ func NewIPPoolManager(config IPPoolManagerConfig, client client.Client, apiReade }, nil } -func (im *ipPoolManager) GetIPPoolByName(ctx context.Context, poolName string, cached bool) (*spiderpoolv2beta1.SpiderIPPool, error) { +func (im *ipPoolManager) GetIPPoolByName(ctx context.Context, poolName string, cached bool) (*spiderpoolv1.SpiderIPPool, error) { reader := im.apiReader if cached == constant.UseCache { reader = im.client } - var ipPool spiderpoolv2beta1.SpiderIPPool + var ipPool spiderpoolv1.SpiderIPPool if err := reader.Get(ctx, apitypes.NamespacedName{Name: poolName}, &ipPool); err != nil { return nil, err } @@ -79,13 +79,13 @@ func (im *ipPoolManager) GetIPPoolByName(ctx context.Context, poolName string, c return &ipPool, nil } -func (im *ipPoolManager) ListIPPools(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderIPPoolList, error) { +func (im *ipPoolManager) ListIPPools(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderIPPoolList, error) { reader := im.apiReader if cached == constant.UseCache { reader = im.client } - var ipPoolList spiderpoolv2beta1.SpiderIPPoolList + var ipPoolList spiderpoolv1.SpiderIPPoolList if err := reader.List(ctx, &ipPoolList, opts...); err != nil { return nil, err } @@ -141,7 +141,7 @@ func (im *ipPoolManager) AllocateIP(ctx context.Context, poolName, nic string, p return ipConfig, nil } -func (im *ipPoolManager) genRandomIP(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool, pod *corev1.Pod, podController types.PodTopController) (net.IP, error) { +func (im *ipPoolManager) genRandomIP(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool, pod *corev1.Pod, podController types.PodTopController) (net.IP, error) { logger := logutils.FromContext(ctx) var tmpPod *corev1.Pod @@ -198,9 +198,9 @@ func (im *ipPoolManager) genRandomIP(ctx context.Context, ipPool *spiderpoolv2be resIP := availableIPs[0] if allocatedRecords == nil { - allocatedRecords = spiderpoolv2beta1.PoolIPAllocations{} + allocatedRecords = spiderpoolv1.PoolIPAllocations{} } - allocatedRecords[resIP.String()] = spiderpoolv2beta1.PoolIPAllocation{ + allocatedRecords[resIP.String()] = spiderpoolv1.PoolIPAllocation{ NamespacedName: key, PodUID: string(pod.UID), } diff --git a/pkg/ippoolmanager/ippool_manager_suite_test.go b/pkg/ippoolmanager/ippool_manager_suite_test.go index 94fbc82a8d..1e6e31827e 100644 --- a/pkg/ippoolmanager/ippool_manager_suite_test.go +++ b/pkg/ippoolmanager/ippool_manager_suite_test.go @@ -21,7 +21,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" electionmock "github.com/spidernet-io/spiderpool/pkg/election/mock" "github.com/spidernet-io/spiderpool/pkg/ippoolmanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/metric" reservedipmanagermock "github.com/spidernet-io/spiderpool/pkg/reservedipmanager/mock" ) @@ -47,27 +47,27 @@ func TestIPPoolManager(t *testing.T) { var _ = BeforeSuite(func() { scheme = runtime.NewScheme() - err := spiderpoolv2beta1.AddToScheme(scheme) + err := spiderpoolv1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) fakeClient = fake.NewClientBuilder(). WithScheme(scheme). - WithIndex(&spiderpoolv2beta1.SpiderIPPool{}, metav1.ObjectNameField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + WithIndex(&spiderpoolv1.SpiderIPPool{}, metav1.ObjectNameField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) return []string{ipPool.GetObjectMeta().GetName()} }). - WithIndex(&spiderpoolv2beta1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + WithIndex(&spiderpoolv1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) return []string{strconv.FormatBool(*ipPool.Spec.Default)} }). - WithIndex(&spiderpoolv2beta1.SpiderIPPool{}, constant.SpecIPVersionField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + WithIndex(&spiderpoolv1.SpiderIPPool{}, constant.SpecIPVersionField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) if ipPool.Spec.IPVersion != nil { return []string{strconv.FormatInt(*ipPool.Spec.IPVersion, 10)} } return []string{} }). - WithStatusSubresource(&spiderpoolv2beta1.SpiderIPPool{}). + WithStatusSubresource(&spiderpoolv1.SpiderIPPool{}). Build() _, err = metric.InitMetric(context.TODO(), constant.SpiderpoolAgent, false, false) Expect(err).NotTo(HaveOccurred()) @@ -78,15 +78,15 @@ var _ = BeforeSuite(func() { fakeAPIReader = fake.NewClientBuilder(). WithScheme(scheme). WithObjectTracker(tracker). - WithIndex(&spiderpoolv2beta1.SpiderIPPool{}, metav1.ObjectNameField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + WithIndex(&spiderpoolv1.SpiderIPPool{}, metav1.ObjectNameField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) return []string{ipPool.GetObjectMeta().GetName()} }). - WithIndex(&spiderpoolv2beta1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { - ipPool := raw.(*spiderpoolv2beta1.SpiderIPPool) + WithIndex(&spiderpoolv1.SpiderIPPool{}, constant.SpecDefaultField, func(raw client.Object) []string { + ipPool := raw.(*spiderpoolv1.SpiderIPPool) return []string{strconv.FormatBool(*ipPool.Spec.Default)} }). - WithStatusSubresource(&spiderpoolv2beta1.SpiderIPPool{}). + WithStatusSubresource(&spiderpoolv1.SpiderIPPool{}). Build() mockLeaderElector = electionmock.NewMockSpiderLeaseElector(mockCtrl) diff --git a/pkg/ippoolmanager/ippool_manager_test.go b/pkg/ippoolmanager/ippool_manager_test.go index f1fa2ca715..631073c0d5 100644 --- a/pkg/ippoolmanager/ippool_manager_test.go +++ b/pkg/ippoolmanager/ippool_manager_test.go @@ -27,7 +27,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/ippoolmanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" spiderpooltypes "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/utils/convert" ) @@ -85,7 +85,7 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { var count uint64 var ipPoolName string var labels map[string]string - var ipPoolT *spiderpoolv2beta1.SpiderIPPool + var ipPoolT *spiderpoolv1.SpiderIPPool BeforeEach(func() { ctx = context.TODO() @@ -93,7 +93,7 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { atomic.AddUint64(&count, 1) ipPoolName = fmt.Sprintf("ippool-%v", count) labels = map[string]string{"foo": fmt.Sprintf("bar-%v", count)} - ipPoolT = &spiderpoolv2beta1.SpiderIPPool{ + ipPoolT = &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -102,7 +102,7 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { Name: ipPoolName, Labels: labels, }, - Spec: spiderpoolv2beta1.IPPoolSpec{}, + Spec: spiderpoolv1.IPPoolSpec{}, } }) @@ -431,8 +431,8 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { key, err := cache.MetaNamespaceKeyFunc(podT) Expect(err).NotTo(HaveOccurred()) - records := spiderpoolv2beta1.PoolIPAllocations{ - ip.String(): spiderpoolv2beta1.PoolIPAllocation{ + records := spiderpoolv1.PoolIPAllocations{ + ip.String(): spiderpoolv1.PoolIPAllocation{ NamespacedName: key, PodUID: string(podT.UID), }, @@ -440,7 +440,7 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { allocatedIPs, err := json.Marshal(records) Expect(err).NotTo(HaveOccurred()) - ipPoolT.Status = spiderpoolv2beta1.IPPoolStatus{ + ipPoolT.Status = spiderpoolv1.IPPoolStatus{ AllocatedIPs: ptr.To(string(allocatedIPs)), TotalIPCount: ptr.To(int64(1)), AllocatedIPCount: ptr.To(int64(1)), @@ -465,13 +465,13 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { Describe("ReleaseIP", func() { var ip string var uid string - var records spiderpoolv2beta1.PoolIPAllocations + var records spiderpoolv1.PoolIPAllocations BeforeEach(func() { ip = "172.18.40.40" uid = string(uuid.NewUUID()) - records = spiderpoolv2beta1.PoolIPAllocations{ - ip: spiderpoolv2beta1.PoolIPAllocation{ + records = spiderpoolv1.PoolIPAllocations{ + ip: spiderpoolv1.PoolIPAllocation{ NamespacedName: "default/pod", PodUID: uid, }, @@ -542,7 +542,7 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { err = ipPoolManager.ReleaseIP(ctx, ipPoolName, []spiderpooltypes.IPAndUID{{IP: ip, UID: uid}}) Expect(err).NotTo(HaveOccurred()) - var ipPool spiderpoolv2beta1.SpiderIPPool + var ipPool spiderpoolv1.SpiderIPPool err = fakeClient.Get(ctx, types.NamespacedName{Name: ipPoolT.Name}, &ipPool) Expect(err).NotTo(HaveOccurred()) @@ -555,13 +555,13 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { Describe("UpdateAllocatedIPs", func() { var ip string var uid string - var records spiderpoolv2beta1.PoolIPAllocations + var records spiderpoolv1.PoolIPAllocations BeforeEach(func() { ip = "172.18.40.40" uid = string(uuid.NewUUID()) - records = spiderpoolv2beta1.PoolIPAllocations{ - ip: spiderpoolv2beta1.PoolIPAllocation{ + records = spiderpoolv1.PoolIPAllocations{ + ip: spiderpoolv1.PoolIPAllocation{ NamespacedName: "default/pod", PodUID: uid, }, @@ -650,7 +650,7 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() { err = ipPoolManager.UpdateAllocatedIPs(ctx, ipPoolName, "default/pod", []spiderpooltypes.IPAndUID{{IP: ip, UID: newUID}}) Expect(err).NotTo(HaveOccurred()) - var ipPool spiderpoolv2beta1.SpiderIPPool + var ipPool spiderpoolv1.SpiderIPPool err = fakeClient.Get(ctx, types.NamespacedName{Name: ipPoolT.Name}, &ipPool) Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/ippoolmanager/ippool_mutate.go b/pkg/ippoolmanager/ippool_mutate.go index 7510ba951b..3773df183f 100644 --- a/pkg/ippoolmanager/ippool_mutate.go +++ b/pkg/ippoolmanager/ippool_mutate.go @@ -16,12 +16,12 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/types" ) -func (iw *IPPoolWebhook) mutateIPPool(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) error { +func (iw *IPPoolWebhook) mutateIPPool(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) error { logger := logutils.FromContext(ctx) logger.Info("Start to mutate IPPool") @@ -100,7 +100,7 @@ func (iw *IPPoolWebhook) mutateIPPool(ctx context.Context, ipPool *spiderpoolv2b return nil } -func (iw *IPPoolWebhook) setControllerSubnet(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) (*spiderpoolv2beta1.SpiderSubnet, error) { +func (iw *IPPoolWebhook) setControllerSubnet(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) (*spiderpoolv1.SpiderSubnet, error) { logger := logutils.FromContext(ctx) owner := metav1.GetControllerOf(ipPool) @@ -113,7 +113,7 @@ func (iw *IPPoolWebhook) setControllerSubnet(ctx context.Context, ipPool *spider return nil, fmt.Errorf("failed to parse CIDR %s as a valid label value: %v", ipPool.Spec.Subnet, err) } - var subnetList spiderpoolv2beta1.SpiderSubnetList + var subnetList spiderpoolv1.SpiderSubnetList if err := iw.Client.List( ctx, &subnetList, @@ -142,14 +142,14 @@ func (iw *IPPoolWebhook) setControllerSubnet(ctx context.Context, ipPool *spider return subnet, nil } -func InheritSubnetProperties(subnet *spiderpoolv2beta1.SpiderSubnet, ipPool *spiderpoolv2beta1.SpiderIPPool) { +func InheritSubnetProperties(subnet *spiderpoolv1.SpiderSubnet, ipPool *spiderpoolv1.SpiderIPPool) { if subnet.Spec.Gateway != nil && ipPool.Spec.Gateway == nil { ipPool.Spec.Gateway = ptr.To(*subnet.Spec.Gateway) } // if customer set empty route for this IPPool, it would not inherit the SpiderSubnet.Spec.Routes if len(subnet.Spec.Routes) != 0 && ipPool.Spec.Routes == nil { - routes := make([]spiderpoolv2beta1.Route, len(subnet.Spec.Routes)) + routes := make([]spiderpoolv1.Route, len(subnet.Spec.Routes)) copy(routes, subnet.Spec.Routes) ipPool.Spec.Routes = routes } diff --git a/pkg/ippoolmanager/ippool_subnet_validate.go b/pkg/ippoolmanager/ippool_subnet_validate.go index cc68fe7535..44e7072bc7 100644 --- a/pkg/ippoolmanager/ippool_subnet_validate.go +++ b/pkg/ippoolmanager/ippool_subnet_validate.go @@ -16,11 +16,11 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/utils/convert" ) -func (iw *IPPoolWebhook) validateCreateIPPoolWhileEnableSpiderSubnet(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) field.ErrorList { +func (iw *IPPoolWebhook) validateCreateIPPoolWhileEnableSpiderSubnet(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) field.ErrorList { if errs := iw.validateCreateIPPool(ctx, ipPool); len(errs) != 0 { return errs } @@ -34,7 +34,7 @@ func (iw *IPPoolWebhook) validateCreateIPPoolWhileEnableSpiderSubnet(ctx context return nil } -func (iw *IPPoolWebhook) validateUpdateIPPoolWhileEnableSpiderSubnet(ctx context.Context, oldIPPool, newIPPool *spiderpoolv2beta1.SpiderIPPool) field.ErrorList { +func (iw *IPPoolWebhook) validateUpdateIPPoolWhileEnableSpiderSubnet(ctx context.Context, oldIPPool, newIPPool *spiderpoolv1.SpiderIPPool) field.ErrorList { if errs := iw.validateUpdateIPPool(ctx, oldIPPool, newIPPool); len(errs) != 0 { return errs } @@ -48,7 +48,7 @@ func (iw *IPPoolWebhook) validateUpdateIPPoolWhileEnableSpiderSubnet(ctx context return nil } -func (iw *IPPoolWebhook) validateSubnetTotalIPsContainsIPPoolTotalIPs(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) *field.Error { +func (iw *IPPoolWebhook) validateSubnetTotalIPsContainsIPPoolTotalIPs(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) *field.Error { owner := metav1.GetControllerOf(ipPool) if owner == nil { return nil @@ -62,7 +62,7 @@ func (iw *IPPoolWebhook) validateSubnetTotalIPsContainsIPPoolTotalIPs(ctx contex return nil } - var subnet spiderpoolv2beta1.SpiderSubnet + var subnet spiderpoolv1.SpiderSubnet if err := iw.APIReader.Get(ctx, apitypes.NamespacedName{Name: owner.Name}, &subnet); err != nil { return field.InternalError(subnetField, fmt.Errorf("failed to get controller Subnet %s: %v", owner.Name, err)) } @@ -88,7 +88,7 @@ func (iw *IPPoolWebhook) validateSubnetTotalIPsContainsIPPoolTotalIPs(ctx contex return nil } -func validateNewAutoPoolTotalIPsWithinSubnet(pool *spiderpoolv2beta1.SpiderIPPool, subnet *spiderpoolv2beta1.SpiderSubnet) *field.Error { +func validateNewAutoPoolTotalIPsWithinSubnet(pool *spiderpoolv1.SpiderIPPool, subnet *spiderpoolv1.SpiderSubnet) *field.Error { var subnetPreAllocateIPs []net.IP poolTotalIPs, err := spiderpoolip.AssembleTotalIPs(*pool.Spec.IPVersion, pool.Spec.IPs, pool.Spec.ExcludeIPs) diff --git a/pkg/ippoolmanager/ippool_validate.go b/pkg/ippoolmanager/ippool_validate.go index 1b09e43f2a..0b21d8af2e 100644 --- a/pkg/ippoolmanager/ippool_validate.go +++ b/pkg/ippoolmanager/ippool_validate.go @@ -16,7 +16,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/utils/convert" ) @@ -30,7 +30,7 @@ var ( podAffinityField *field.Path = field.NewPath("spec").Child("podAffinity") ) -func (iw *IPPoolWebhook) validateCreateIPPool(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) field.ErrorList { +func (iw *IPPoolWebhook) validateCreateIPPool(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) field.ErrorList { if err := iw.validateIPPoolIPVersion(ipPool.Spec.IPVersion); err != nil { return field.ErrorList{err} } @@ -56,7 +56,7 @@ func (iw *IPPoolWebhook) validateCreateIPPool(ctx context.Context, ipPool *spide return errs } -func (iw *IPPoolWebhook) validateUpdateIPPool(ctx context.Context, oldIPPool, newIPPool *spiderpoolv2beta1.SpiderIPPool) field.ErrorList { +func (iw *IPPoolWebhook) validateUpdateIPPool(ctx context.Context, oldIPPool, newIPPool *spiderpoolv1.SpiderIPPool) field.ErrorList { if err := validateIPPoolShouldNotBeChanged(oldIPPool, newIPPool); err != nil { return field.ErrorList{err} } @@ -86,7 +86,7 @@ func (iw *IPPoolWebhook) validateUpdateIPPool(ctx context.Context, oldIPPool, ne return errs } -func validateIPPoolShouldNotBeChanged(oldIPPool, newIPPool *spiderpoolv2beta1.SpiderIPPool) *field.Error { +func validateIPPoolShouldNotBeChanged(oldIPPool, newIPPool *spiderpoolv1.SpiderIPPool) *field.Error { if newIPPool.Spec.IPVersion != nil && oldIPPool.Spec.IPVersion != nil && *newIPPool.Spec.IPVersion != *oldIPPool.Spec.IPVersion { return field.Forbidden( @@ -105,7 +105,7 @@ func validateIPPoolShouldNotBeChanged(oldIPPool, newIPPool *spiderpoolv2beta1.Sp return nil } -func (iw *IPPoolWebhook) validateIPPoolSpec(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) *field.Error { +func (iw *IPPoolWebhook) validateIPPoolSpec(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) *field.Error { if err := iw.validateIPPoolAvailableIPs(ctx, ipPool); err != nil { return err } @@ -116,7 +116,7 @@ func (iw *IPPoolWebhook) validateIPPoolSpec(ctx context.Context, ipPool *spiderp return validateIPPoolRoutes(*ipPool.Spec.IPVersion, ipPool.Spec.Subnet, ipPool.Spec.Routes) } -func validateIPPoolIPInUse(ipPool *spiderpoolv2beta1.SpiderIPPool) *field.Error { +func validateIPPoolIPInUse(ipPool *spiderpoolv1.SpiderIPPool) *field.Error { allocatedRecords, err := convert.UnmarshalIPPoolAllocatedIPs(ipPool.Status.AllocatedIPs) if err != nil { return field.InternalError(ipsField, fmt.Errorf("failed to unmarshal the allocated IP records of IPPool %s: %v", ipPool.Name, err)) @@ -180,7 +180,7 @@ func (iw *IPPoolWebhook) validateIPPoolIPVersion(version *types.IPVersion) *fiel return nil } -func (iw *IPPoolWebhook) validateIPPoolCIDR(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) *field.Error { +func (iw *IPPoolWebhook) validateIPPoolCIDR(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) *field.Error { if err := spiderpoolip.IsCIDR(*ipPool.Spec.IPVersion, ipPool.Spec.Subnet); err != nil { return field.Invalid( subnetField, @@ -192,7 +192,7 @@ func (iw *IPPoolWebhook) validateIPPoolCIDR(ctx context.Context, ipPool *spiderp return field.Invalid(subnetField, ipPool.Spec.Subnet, err.Error()) } - var ipPoolList spiderpoolv2beta1.SpiderIPPoolList + var ipPoolList spiderpoolv1.SpiderIPPoolList if err := iw.APIReader.List(ctx, &ipPoolList); err != nil { return field.InternalError(subnetField, fmt.Errorf("failed to list IPPools: %v", err)) } @@ -227,7 +227,7 @@ func (iw *IPPoolWebhook) validateIPPoolCIDR(ctx context.Context, ipPool *spiderp return nil } -func (iw *IPPoolWebhook) validateIPPoolAvailableIPs(ctx context.Context, ipPool *spiderpoolv2beta1.SpiderIPPool) *field.Error { +func (iw *IPPoolWebhook) validateIPPoolAvailableIPs(ctx context.Context, ipPool *spiderpoolv1.SpiderIPPool) *field.Error { newPool, err := spiderpoolip.NewCIDR(ipPool.Spec.Subnet, ipPool.Spec.IPs, ipPool.Spec.ExcludeIPs) if err != nil { return field.Invalid(subnetField, ipPool.Spec.Subnet, err.Error()) @@ -238,7 +238,7 @@ func (iw *IPPoolWebhook) validateIPPoolAvailableIPs(ctx context.Context, ipPool return field.InternalError(ipsField, fmt.Errorf("failed to parse CIDR %s as a valid label value: %v", ipPool.Spec.Subnet, err)) } - var ipPoolList spiderpoolv2beta1.SpiderIPPoolList + var ipPoolList spiderpoolv1.SpiderIPPoolList if err := iw.APIReader.List( ctx, &ipPoolList, @@ -265,7 +265,7 @@ func (iw *IPPoolWebhook) validateIPPoolAvailableIPs(ctx context.Context, ipPool return nil } -func validateIPPoolGateway(ipPool *spiderpoolv2beta1.SpiderIPPool) *field.Error { +func validateIPPoolGateway(ipPool *spiderpoolv1.SpiderIPPool) *field.Error { if ipPool.Spec.Gateway == nil { return nil } @@ -295,7 +295,7 @@ func validateIPPoolGateway(ipPool *spiderpoolv2beta1.SpiderIPPool) *field.Error return nil } -func validateIPPoolRoutes(version types.IPVersion, subnet string, routes []spiderpoolv2beta1.Route) *field.Error { +func validateIPPoolRoutes(version types.IPVersion, subnet string, routes []spiderpoolv1.Route) *field.Error { if len(routes) == 0 { return nil } @@ -378,7 +378,7 @@ func ValidateContainsIP(fieldPath *field.Path, version types.IPVersion, subnet s return nil } -func validateIPPoolPodAffinity(fieldPath *field.Path, ipPool *spiderpoolv2beta1.SpiderIPPool) field.ErrorList { +func validateIPPoolPodAffinity(fieldPath *field.Path, ipPool *spiderpoolv1.SpiderIPPool) field.ErrorList { if ipPool.Spec.PodAffinity == nil { return nil } diff --git a/pkg/ippoolmanager/ippool_webhook.go b/pkg/ippoolmanager/ippool_webhook.go index 28ea7a2f70..bf462ef047 100644 --- a/pkg/ippoolmanager/ippool_webhook.go +++ b/pkg/ippoolmanager/ippool_webhook.go @@ -20,7 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" ) @@ -41,7 +41,7 @@ func (iw *IPPoolWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { } return ctrl.NewWebhookManagedBy(mgr). - For(&spiderpoolv2beta1.SpiderIPPool{}). + For(&spiderpoolv1.SpiderIPPool{}). WithDefaulter(iw). WithValidator(iw). Complete() @@ -51,7 +51,7 @@ var _ webhook.CustomDefaulter = (*IPPoolWebhook)(nil) // Default implements webhook.CustomDefaulter so a webhook will be registered for the type. func (iw *IPPoolWebhook) Default(ctx context.Context, obj runtime.Object) error { - ipPool := obj.(*spiderpoolv2beta1.SpiderIPPool) + ipPool := obj.(*spiderpoolv1.SpiderIPPool) logger := WebhookLogger.Named("Mutating").With( zap.String("IPPoolName", ipPool.Name), @@ -70,7 +70,7 @@ var _ webhook.CustomValidator = (*IPPoolWebhook)(nil) // ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type. func (iw *IPPoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - ipPool := obj.(*spiderpoolv2beta1.SpiderIPPool) + ipPool := obj.(*spiderpoolv1.SpiderIPPool) logger := WebhookLogger.Named("Validating").With( zap.String("IPPoolName", ipPool.Name), @@ -85,7 +85,7 @@ func (iw *IPPoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) // Refer to https://github.com/spidernet-io/spiderpool/issues/3321 switch { case strings.Contains(aggregatedErr.Error(), string(metav1.StatusReasonAlreadyExists)): - return nil, apierrors.NewAlreadyExists(spiderpoolv2beta1.Resource(constant.KindSpiderIPPool), ipPool.Name) + return nil, apierrors.NewAlreadyExists(spiderpoolv1.Resource(constant.KindSpiderIPPool), ipPool.Name) default: return nil, apierrors.NewInvalid( schema.GroupKind{Group: constant.SpiderpoolAPIGroup, Kind: constant.KindSpiderIPPool}, @@ -100,8 +100,8 @@ func (iw *IPPoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) // ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type. func (iw *IPPoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - oldIPPool := oldObj.(*spiderpoolv2beta1.SpiderIPPool) - newIPPool := newObj.(*spiderpoolv2beta1.SpiderIPPool) + oldIPPool := oldObj.(*spiderpoolv1.SpiderIPPool) + newIPPool := newObj.(*spiderpoolv1.SpiderIPPool) logger := WebhookLogger.Named("Validating").With( zap.String("IPPoolName", newIPPool.Name), diff --git a/pkg/ippoolmanager/ippool_webhook_test.go b/pkg/ippoolmanager/ippool_webhook_test.go index 07766f5ed3..40d841bdd4 100644 --- a/pkg/ippoolmanager/ippool_webhook_test.go +++ b/pkg/ippoolmanager/ippool_webhook_test.go @@ -27,7 +27,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" "github.com/spidernet-io/spiderpool/pkg/ippoolmanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/utils/convert" @@ -53,9 +53,9 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { var count uint64 var subnetName string - var subnetT *spiderpoolv2beta1.SpiderSubnet + var subnetT *spiderpoolv1.SpiderSubnet var ipPoolName, existIPPoolName string - var ipPoolT, existIPPoolT *spiderpoolv2beta1.SpiderIPPool + var ipPoolT, existIPPoolT *spiderpoolv1.SpiderIPPool BeforeEach(func() { ippoolmanager.WebhookLogger = logutils.Logger.Named("IPPool-Webhook") @@ -67,7 +67,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { atomic.AddUint64(&count, 1) subnetName = fmt.Sprintf("subnet-%v", count) - subnetT = &spiderpoolv2beta1.SpiderSubnet{ + subnetT = &spiderpoolv1.SpiderSubnet{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderSubnet, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -76,11 +76,11 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { Name: subnetName, Labels: map[string]string{}, }, - Spec: spiderpoolv2beta1.SubnetSpec{}, + Spec: spiderpoolv1.SubnetSpec{}, } ipPoolName = fmt.Sprintf("ippool-%v", count) - ipPoolT = &spiderpoolv2beta1.SpiderIPPool{ + ipPoolT = &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -88,11 +88,11 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: ipPoolName, }, - Spec: spiderpoolv2beta1.IPPoolSpec{}, + Spec: spiderpoolv1.IPPoolSpec{}, } existIPPoolName = fmt.Sprintf("z-exist-ippool-%v", count) - existIPPoolT = &spiderpoolv2beta1.SpiderIPPool{ + existIPPoolT = &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -101,7 +101,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { Name: existIPPoolName, Labels: map[string]string{}, }, - Spec: spiderpoolv2beta1.IPPoolSpec{}, + Spec: spiderpoolv1.IPPoolSpec{}, } }) @@ -542,7 +542,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { ) subnetT.Spec.Gateway = ptr.To("172.18.50.0") - subnetT.Spec.Routes = []spiderpoolv2beta1.Route{ + subnetT.Spec.Routes = []spiderpoolv1.Route{ { Dst: "0.0.0.0/0", Gw: "172.18.50.0", @@ -974,7 +974,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { }..., ) ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "0.0.0.0/0", Gw: "172.18.40.1", }, @@ -995,11 +995,11 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { }..., ) ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.1", }, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.2", }, @@ -1020,7 +1020,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { }..., ) ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: constant.InvalidCIDR, Gw: "172.18.40.1", }, @@ -1041,7 +1041,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { }..., ) ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: constant.InvalidIP, }, @@ -1062,7 +1062,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { }..., ) ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.41.1", }, @@ -1190,7 +1190,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { }) Context("auto-created IPPool", func() { - var autoPool *spiderpoolv2beta1.SpiderIPPool + var autoPool *spiderpoolv1.SpiderIPPool BeforeEach(func() { autoPool = ipPoolT.DeepCopy() autoPool.Spec.IPs = append(autoPool.Spec.IPs, "172.18.40.1") @@ -1316,7 +1316,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { ipPoolT.Spec.ExcludeIPs = append(ipPoolT.Spec.ExcludeIPs, "172.18.40.10") ipPoolT.Spec.Gateway = ptr.To("172.18.40.1") ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.40", }, @@ -1357,7 +1357,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { ipPoolT.Spec.ExcludeIPs = append(ipPoolT.Spec.ExcludeIPs, "abcd:1234::a") ipPoolT.Spec.Gateway = ptr.To("abcd:1234::1") ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "fd00:40::/120", Gw: "abcd:1234::28", }, @@ -1698,7 +1698,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { newIPPoolT := ipPoolT.DeepCopy() newIPPoolT.Spec.Routes = append(newIPPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "0.0.0.0/0", Gw: "172.18.40.1", }, @@ -1719,7 +1719,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { }..., ) ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.1", }, @@ -1727,7 +1727,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { newIPPoolT := ipPoolT.DeepCopy() newIPPoolT.Spec.Routes = append(newIPPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.2", }, @@ -1750,7 +1750,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { newIPPoolT := ipPoolT.DeepCopy() newIPPoolT.Spec.Routes = append(newIPPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: constant.InvalidCIDR, Gw: "172.18.40.1", }, @@ -1773,7 +1773,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { newIPPoolT := ipPoolT.DeepCopy() newIPPoolT.Spec.Routes = append(newIPPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: constant.InvalidIP, }, @@ -1796,7 +1796,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { newIPPoolT := ipPoolT.DeepCopy() newIPPoolT.Spec.Routes = append(newIPPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.41.1", }, @@ -1820,8 +1820,8 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { ) data, err := convert.MarshalIPPoolAllocatedIPs( - spiderpoolv2beta1.PoolIPAllocations{ - "172.18.40.10": spiderpoolv2beta1.PoolIPAllocation{ + spiderpoolv1.PoolIPAllocations{ + "172.18.40.10": spiderpoolv1.PoolIPAllocation{ NamespacedName: "default/pod", PodUID: string(uuid.NewUUID()), }, @@ -1950,7 +1950,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { err := controllerutil.SetControllerReference(subnetT, autoPool, scheme) Expect(err).NotTo(HaveOccurred()) - poolIPPreAllocations := spiderpoolv2beta1.PoolIPPreAllocations{autoPool.Name: spiderpoolv2beta1.PoolIPPreAllocation{ + poolIPPreAllocations := spiderpoolv1.PoolIPPreAllocations{autoPool.Name: spiderpoolv1.PoolIPPreAllocation{ IPs: []string{"172.18.40.1"}, Application: ptr.To(applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{ APIVersion: appsv1.SchemeGroupVersion.String(), @@ -1993,7 +1993,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { err := controllerutil.SetControllerReference(subnetT, autoPool, scheme) Expect(err).NotTo(HaveOccurred()) - poolIPPreAllocations := spiderpoolv2beta1.PoolIPPreAllocations{autoPool.Name: spiderpoolv2beta1.PoolIPPreAllocation{ + poolIPPreAllocations := spiderpoolv1.PoolIPPreAllocations{autoPool.Name: spiderpoolv1.PoolIPPreAllocation{ IPs: []string{"172.18.40.1"}, Application: ptr.To(applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{ APIVersion: appsv1.SchemeGroupVersion.String(), @@ -2096,7 +2096,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { newIPPoolT.Spec.ExcludeIPs = append(newIPPoolT.Spec.ExcludeIPs, "172.18.40.10") newIPPoolT.Spec.Gateway = ptr.To("172.18.40.1") newIPPoolT.Spec.Routes = append(newIPPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.40", }, @@ -2134,7 +2134,7 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() { newIPPoolT.Spec.ExcludeIPs = append(newIPPoolT.Spec.ExcludeIPs, "abcd:1234::a") newIPPoolT.Spec.Gateway = ptr.To("abcd:1234::1") newIPPoolT.Spec.Routes = append(newIPPoolT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "fd00:40::/120", Gw: "abcd:1234::28", }, diff --git a/pkg/ippoolmanager/utils.go b/pkg/ippoolmanager/utils.go index 28e118673b..ae0253d8a9 100644 --- a/pkg/ippoolmanager/utils.go +++ b/pkg/ippoolmanager/utils.go @@ -11,11 +11,11 @@ import ( "k8s.io/apimachinery/pkg/labels" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" ) -func IsAutoCreatedIPPool(pool *spiderpoolv2beta1.SpiderIPPool) bool { +func IsAutoCreatedIPPool(pool *spiderpoolv1.SpiderIPPool) bool { // only the auto-created IPPool owns the annotation "ipam.spidernet.io/owner-application" poolLabels := pool.GetLabels() _, ok := poolLabels[constant.LabelIPPoolOwnerApplicationName] @@ -70,7 +70,7 @@ func IsMatchAutoPoolAffinity(podAffinity *metav1.LabelSelector, podTopController // ByPoolPriority implements sort.Interface var _ sort.Interface = &ByPoolPriority{} -type ByPoolPriority []*spiderpoolv2beta1.SpiderIPPool +type ByPoolPriority []*spiderpoolv1.SpiderIPPool func (b ByPoolPriority) Len() int { return len(b) } @@ -126,7 +126,7 @@ func (b ByPoolPriority) Less(i, j int) bool { // findAllocatedIPFromRecords try to find pod NIC previous allocated IP from the IPPool.Status.AllocatedIPs // this function serves for the issue: https://github.com/spidernet-io/spiderpool/issues/2517 -func findAllocatedIPFromRecords(allocatedRecords spiderpoolv2beta1.PoolIPAllocations, namespacedName, podUID string) (previousIP string, hasFound bool) { +func findAllocatedIPFromRecords(allocatedRecords spiderpoolv1.PoolIPAllocations, namespacedName, podUID string) (previousIP string, hasFound bool) { for tmpIP, poolIPAllocation := range allocatedRecords { if poolIPAllocation.NamespacedName == namespacedName && poolIPAllocation.PodUID == podUID { diff --git a/pkg/ippoolmanager/utils_test.go b/pkg/ippoolmanager/utils_test.go index b5e374d468..9f39ce7f6a 100644 --- a/pkg/ippoolmanager/utils_test.go +++ b/pkg/ippoolmanager/utils_test.go @@ -14,14 +14,14 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" ) var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() { Context("IsAutoCreatedIPPool", Labels{"unittest", "IsAutoCreatedIPPool"}, func() { It("normal IPPool", func() { - var pool spiderpoolv2beta1.SpiderIPPool + var pool spiderpoolv1.SpiderIPPool label := map[string]string{constant.LabelIPPoolOwnerApplicationName: "test-name"} pool.SetLabels(label) @@ -31,7 +31,7 @@ var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() { }) It("auto-created IPPool", func() { - var pool spiderpoolv2beta1.SpiderIPPool + var pool spiderpoolv1.SpiderIPPool isAutoCreatedIPPool := IsAutoCreatedIPPool(&pool) Expect(isAutoCreatedIPPool).To(BeFalse()) @@ -78,10 +78,10 @@ var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() { }) Context("Test IPAM pool candidates order selections", func() { - poolTemplate := &spiderpoolv2beta1.SpiderIPPool{} + poolTemplate := &spiderpoolv1.SpiderIPPool{} Context("IPPool with PodAffinity", func() { - var pool1, pool2 *spiderpoolv2beta1.SpiderIPPool + var pool1, pool2 *spiderpoolv1.SpiderIPPool BeforeEach(func() { pool1 = poolTemplate.DeepCopy() pool1.SetName("pool1") @@ -109,7 +109,7 @@ var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() { }) Context("IPPool with NodeAffinity", func() { - var pool1, pool2 *spiderpoolv2beta1.SpiderIPPool + var pool1, pool2 *spiderpoolv1.SpiderIPPool BeforeEach(func() { pool1 = poolTemplate.DeepCopy() pool1.SetName("pool1") @@ -137,7 +137,7 @@ var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() { }) Context("IPPool with NamespaceAffinity", func() { - var pool1, pool2 *spiderpoolv2beta1.SpiderIPPool + var pool1, pool2 *spiderpoolv1.SpiderIPPool BeforeEach(func() { pool1 = poolTemplate.DeepCopy() pool1.SetName("pool1") @@ -165,7 +165,7 @@ var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() { }) Context("IPPool with MultusName", func() { - var pool1, pool2 *spiderpoolv2beta1.SpiderIPPool + var pool1, pool2 *spiderpoolv1.SpiderIPPool BeforeEach(func() { pool1 = poolTemplate.DeepCopy() pool1.SetName("pool1") @@ -293,15 +293,15 @@ var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() { }) Context("Test findAllocatedIPFromRecords", func() { - var allocatedRecords spiderpoolv2beta1.PoolIPAllocations + var allocatedRecords spiderpoolv1.PoolIPAllocations var ip, namespacedName, podUID string BeforeEach(func() { ip = "172.18.40.40" namespacedName = "default/testPod" podUID = string(uuid.NewUUID()) - allocatedRecords = spiderpoolv2beta1.PoolIPAllocations{ - ip: spiderpoolv2beta1.PoolIPAllocation{ + allocatedRecords = spiderpoolv1.PoolIPAllocations{ + ip: spiderpoolv1.PoolIPAllocation{ NamespacedName: namespacedName, PodUID: podUID, }, diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/doc.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/doc.go new file mode 100644 index 0000000000..2227d9a76e --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/doc.go @@ -0,0 +1,6 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Package v2beta1 is the v2beta1 version of the API. +// +groupName=spiderpool.spidernet.io +package v2beta1 diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/groupversion_info.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/groupversion_info.go new file mode 100644 index 0000000000..8d467fde07 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/groupversion_info.go @@ -0,0 +1,26 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// +kubebuilder:object:generate=true +// +groupName=spiderpool.spidernet.io + +// Package v1 contains API Schema definitions for the spiderpool v1 API group +package v2beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" + + "github.com/spidernet-io/spiderpool/pkg/constant" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: constant.SpiderpoolAPIGroup, Version: constant.SpiderpoolAPIVersion} + + // 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/pkg/k8s/apis/spiderpool.spidernet.io/v1/rbac.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/rbac.go new file mode 100644 index 0000000000..e086256096 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/rbac.go @@ -0,0 +1,24 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// +kubebuilder:rbac:groups=spiderpool.spidernet.io,resources=spiderippools,verbs=get;list;watch;create;update;patch;delete;deletecollection +// +kubebuilder:rbac:groups=spiderpool.spidernet.io,resources=spidersubnets;spiderendpoints;spiderreservedips;spidermultusconfigs;spiderclaimparameters,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=spiderpool.spidernet.io,resources=spidercoordinators,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=spiderpool.spidernet.io,resources=spidersubnets/status;spiderippools/status;spidercoordinators/status,verbs=get;update;patch +// +kubebuilder:rbac:groups="",resources=events,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups="coordination.k8s.io",resources=leases,verbs=create;get;update +// +kubebuilder:rbac:groups="apps",resources=statefulsets;deployments;replicasets;daemonsets,verbs=get;list;watch;update +// +kubebuilder:rbac:groups="resource.k8s.io",resources=resourceclaims;resourceclaims/status;podschedulingcontexts/status;resourceclaimtemplates;resourceclasses;podschedulingcontexts,verbs=get;list;patch;watch;update +// +kubebuilder:rbac:groups="networking.k8s.io",resources=servicecidrs,verbs=get;list;watch +// +kubebuilder:rbac:groups="batch",resources=jobs;cronjobs,verbs=get;list;watch;update;delete +// +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch +// +kubebuilder:rbac:groups="",resources=namespaces;endpoints;pods;pods/status;configmaps,verbs=get;list;watch;update;patch;delete;deletecollection +// +kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=kubevirt.io,resources=virtualmachines;virtualmachineinstances,verbs=get;list +// +kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=mutatingwebhookconfigurations;validatingwebhookconfigurations,verbs=get;list;watch;delete;update +// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=apps.kruise.io,resources=clonesets;statefulsets,verbs=get;list;watch +// +kubebuilder:rbac:groups=crd.projectcalico.org,resources=ippools,verbs=get;list;watch +// +kubebuilder:rbac:groups=cilium.io,resources=ciliumpodippools,verbs=get;list;watch + +package v2beta1 diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/register.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/register.go new file mode 100644 index 0000000000..be93634ade --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/register.go @@ -0,0 +1,16 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +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/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidercoordinator_types.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidercoordinator_types.go new file mode 100644 index 0000000000..a8665cad4a --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidercoordinator_types.go @@ -0,0 +1,129 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// CoordinationSpec defines the desired state of SpiderCoordinator. +type CoordinatorSpec struct { + + // Mode mode specifies the mode in which the coordinator runs, + // and the configurable values include auto (default), underlay, + // overlay, disabled. + // +kubebuilder:validation:Enum=auto;underlay;overlay;disabled + // +kubebuilder:validation:Optional + // +kubebuilder:default=auto + Mode *string `json:"mode,omitempty"` + + // CoordinatorSpec is used by SpiderCoordinator and SpiderMultusConfig + // in spidermultusconfig CRD , podCIDRType should not be required, which + // could be merged from SpiderCoordinator CR + // but in SpiderCoordinator CRD, podCIDRType should be required + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Enum=auto;cluster;calico;cilium;none + PodCIDRType *string `json:"podCIDRType,omitempty"` + + // HijackCIDR configure static routing tables in the pod that target these + // subnets to ensure that when the pod accesses these subnets, packets + // are forwarded through the host network stack, such as nodelocaldns(169.254.0.0/16) + // +kubebuilder:validation:Optional + HijackCIDR []string `json:"hijackCIDR,omitempty"` + + // PodMACPrefix the fixed MAC address prefix, the length is two bytes. + // the lowest bit of the first byte must be 0, which indicates the + // unicast MAC address. example: 0a:1b + // +kubebuilder:validation:Optional + PodMACPrefix *string `json:"podMACPrefix,omitempty"` + + // TunePodRoutes specifies whether to tune pod routes of multiple NICs on pods. + // +kubebuilder:validation:Optional + // +kubebuilder:default=true + TunePodRoutes *bool `json:"tunePodRoutes,omitempty"` + + // PodDefaultRouteNIC PodDefaultRouteNIC is used to configure the NIC where + // the pod's default route resides. the default value is empty, which means + // the default route will remain at eth0. + // +kubebuilder:validation:Optional + PodDefaultRouteNIC *string `json:"podDefaultRouteNIC,omitempty"` + + // HostRuleTable specifies the table number of the routing table used + // to configure the communication between the pod and the local node. + // +kubebuilder:validation:Optional + // +kubebuilder:default=500 + HostRuleTable *int `json:"hostRuleTable,omitempty"` + + // PodRPFilter is used for coordiantor to help set the rp_filter parameters of the pod. + // Configurable values: /0/1/2. negative number means leave it as it is. + // the default value is 0. + // +kubebuilder:validation:Optional + // +kubebuilder:default=0 + PodRPFilter *int `json:"podRPFilter,omitempty"` + + // TxQueueLen to set the tx_queue_len of the pod. requirement is a positive integer + // the default value is 0, which means leaving it as it is. + // +kubebuilder:validation:Optional + // +kubebuilder:default=0 + TxQueueLen *int `json:"txQueueLen,omitempty"` + + // DetectIPConflict to detect the ip conflict for the pod + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + DetectIPConflict *bool `json:"detectIPConflict,omitempty"` + + // DetectGateway to detect the gateway for the pod + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + DetectGateway *bool `json:"detectGateway,omitempty"` + + // VethLinkAddress configure a ipv4 link-local address + // for veth0 device. empty means disable. default is empty. + // Format is like 169.254.100.1 + VethLinkAddress *string `json:"vethLinkAddress,omitempty"` +} + +// CoordinationStatus defines the observed state of SpiderCoordinator. +type CoordinatorStatus struct { + // +kubebuilder:validation:Requred + Phase string `json:"phase"` + + // +kubebuilder: validation:Optional + Reason string `json:"reason,omitempty"` + + // +kubebuilder:validation:Optional + OverlayPodCIDR []string `json:"overlayPodCIDR"` + + // +kubebuilder:validation:Optional + ServiceCIDR []string `json:"serviceCIDR"` +} + +// +kubebuilder:resource:categories={spiderpool},path="spidercoordinators",scope="Cluster",shortName={scc},singular="spidercoordinator" +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +genclient +// +genclient:nonNamespaced + +// SpiderCoordinator is the Schema for the spidercoordinators API. +type SpiderCoordinator struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec CoordinatorSpec `json:"spec,omitempty"` + Status CoordinatorStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// SpiderCoordinatorList contains a list of SpiderCoordinator. +type SpiderCoordinatorList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SpiderCoordinator `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SpiderCoordinator{}, &SpiderCoordinatorList{}) +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderendpoint_types.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderendpoint_types.go new file mode 100644 index 0000000000..b46ff852a7 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderendpoint_types.go @@ -0,0 +1,98 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// WorkloadEndpointStatus defines the observed state of SpiderEndpoint. +type WorkloadEndpointStatus struct { + // +kubebuilder:validation:Required + Current PodIPAllocation `json:"current"` + + // +kubebuilder:validation:Required + OwnerControllerType string `json:"ownerControllerType"` + + // +kubebuilder:validation:Required + OwnerControllerName string `json:"ownerControllerName"` +} + +type PodIPAllocation struct { + // +kubebuilder:validation:Required + UID string `json:"uid"` + + // +kubebuilder:validation:Required + Node string `json:"node"` + + // +kubebuilder:validation:Required + IPs []IPAllocationDetail `json:"ips"` +} + +type IPAllocationDetail struct { + // +kubebuilder:validation:Required + NIC string `json:"interface"` + + // +kubebuilder:validation:Optional + IPv4 *string `json:"ipv4,omitempty"` + + // +kubebuilder:validation:Optional + IPv6 *string `json:"ipv6,omitempty"` + + // +kubebuilder:validation:Optional + IPv4Pool *string `json:"ipv4Pool,omitempty"` + + // +kubebuilder:validation:Optional + IPv6Pool *string `json:"ipv6Pool,omitempty"` + + // DEPRECATED: Vlan is deprecated. + // +kubebuilder:default=0 + // +kubebuilder:validation:Maximum=4094 + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Optional + Vlan *int64 `json:"vlan,omitempty"` + + // +kubebuilder:validation:Optional + IPv4Gateway *string `json:"ipv4Gateway,omitempty"` + + // +kubebuilder:validation:Optional + IPv6Gateway *string `json:"ipv6Gateway,omitempty"` + + // +kubebuilder:validation:Optional + CleanGateway *bool `json:"cleanGateway,omitempty"` + + // +kubebuilder:validation:Optional + Routes []Route `json:"routes,omitempty"` +} + +// +kubebuilder:resource:categories={spiderpool},path="spiderendpoints",scope="Namespaced",shortName={se},singular="spiderendpoint" +// +kubebuilder:printcolumn:JSONPath=".status.current.ips[0].interface",description="interface",name="INTERFACE",type=string +// +kubebuilder:printcolumn:JSONPath=".status.current.ips[0].ipv4Pool",description="ipv4Pool",name="IPV4POOL",type=string +// +kubebuilder:printcolumn:JSONPath=".status.current.ips[0].ipv4",description="ipv4",name="IPV4",type=string +// +kubebuilder:printcolumn:JSONPath=".status.current.ips[0].ipv6Pool",description="ipv6Pool",name="IPV6POOL",type=string +// +kubebuilder:printcolumn:JSONPath=".status.current.ips[0].ipv6",description="ipv6",name="IPV6",type=string +// +kubebuilder:printcolumn:JSONPath=".status.current.node",description="node",name="NODE",type=string +// +kubebuilder:object:root=true + +// Spiderndpoint is the Schema for the spiderendpoints API. +type SpiderEndpoint struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Status WorkloadEndpointStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// SpiderEndpointList contains a list of SpiderEndpoint. +type SpiderEndpointList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SpiderEndpoint `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SpiderEndpoint{}, &SpiderEndpointList{}) +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderippool_types.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderippool_types.go new file mode 100644 index 0000000000..108de1ad93 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderippool_types.go @@ -0,0 +1,124 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// IPPoolSpec defines the desired state of SpiderIPPool. +type IPPoolSpec struct { + // +kubebuilder:validation:Enum=4;6 + // +kubebuilder:validation:Optional + IPVersion *int64 `json:"ipVersion,omitempty"` + + // +kubebuilder:validation:Required + Subnet string `json:"subnet"` + + // +kubebuilder:validation:Optional + IPs []string `json:"ips,omitempty"` + + // +kubebuilder:validation:Optional + ExcludeIPs []string `json:"excludeIPs,omitempty"` + + // +kubebuilder:validation:Optional + Gateway *string `json:"gateway,omitempty"` + + // +kubebuilder:validation:Optional + Routes []Route `json:"routes,omitempty"` + + // +kubebuilder:validation:Optional + PodAffinity *metav1.LabelSelector `json:"podAffinity,omitempty"` + + // +kubebuilder:validation:Optional + NamespaceAffinity *metav1.LabelSelector `json:"namespaceAffinity,omitempty"` + + // +kubebuilder:validation:Optional + NamespaceName []string `json:"namespaceName,omitempty"` + + // +kubebuilder:validation:Optional + NodeAffinity *metav1.LabelSelector `json:"nodeAffinity,omitempty"` + + // +kubebuilder:validation:Optional + NodeName []string `json:"nodeName,omitempty"` + + // +kubebuilder:validation:Optional + MultusName []string `json:"multusName,omitempty"` + + // +kubebuilder:default=false + // +kubebuilder:validation:Optional + Default *bool `json:"default,omitempty"` + + // +kubebuilder:default=false + // +kubebuilder:validation:Optional + Disable *bool `json:"disable,omitempty"` +} + +type Route struct { + // +kubebuilder:validation:Required + Dst string `json:"dst"` + + // +kubebuilder:validation:Required + Gw string `json:"gw"` +} + +// IPPoolStatus defines the observed state of SpiderIPPool. +type IPPoolStatus struct { + // +kubebuilder:validation:Optional + AllocatedIPs *string `json:"allocatedIPs,omitempty"` + + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Optional + TotalIPCount *int64 `json:"totalIPCount,omitempty"` + + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Optional + AllocatedIPCount *int64 `json:"allocatedIPCount,omitempty"` +} + +// PoolIPAllocations is a map of IP allocation details indexed by IP address. +type PoolIPAllocations map[string]PoolIPAllocation + +type PoolIPAllocation struct { + NamespacedName string `json:"pod"` + PodUID string `json:"podUid"` +} + +// +kubebuilder:resource:categories={spiderpool},path="spiderippools",scope="Cluster",shortName={sp},singular="spiderippool" +// +kubebuilder:printcolumn:JSONPath=".spec.ipVersion",description="ipVersion",name="VERSION",type=string +// +kubebuilder:printcolumn:JSONPath=".spec.subnet",description="subnet",name="SUBNET",type=string +// +kubebuilder:printcolumn:JSONPath=".status.allocatedIPCount",description="allocatedIPCount",name="ALLOCATED-IP-COUNT",type=integer +// +kubebuilder:printcolumn:JSONPath=".status.totalIPCount",description="totalIPCount",name="TOTAL-IP-COUNT",type=integer +// +kubebuilder:printcolumn:JSONPath=".spec.default",description="default",name="DEFAULT",type=boolean +// +kubebuilder:printcolumn:JSONPath=".spec.disable",description="disable",name="DISABLE",type=boolean,priority=10 +// +kubebuilder:printcolumn:JSONPath=".spec.nodeName",description="nodeName",name="NodeName",type=string,priority=10 +// +kubebuilder:printcolumn:JSONPath=".spec.multusName",description="multusName",name="MultusName",type=string,priority=10 +// +kubebuilder:printcolumn:JSONPath=`.spec.podAffinity.matchLabels['ipam\.spidernet\.io/app\-namespace']`,description="AppNamespace",name="APP-NAMESPACE",type=string,priority=10 +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +genclient +// +genclient:nonNamespaced + +// SpiderIPPool is the Schema for the spiderippools API. +type SpiderIPPool struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPPoolSpec `json:"spec,omitempty"` + Status IPPoolStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// SpiderIPPoolList contains a list of SpiderIPPool. +type SpiderIPPoolList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SpiderIPPool `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SpiderIPPool{}, &SpiderIPPoolList{}) +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidermultus_types.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidermultus_types.go new file mode 100644 index 0000000000..f6655eace5 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidermultus_types.go @@ -0,0 +1,260 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +kubebuilder:resource:categories={spiderpool},path="spidermultusconfigs",scope="Namespaced",shortName={smc},singular="spidermultusconfig" +// +kubebuilder:object:root=true +// +genclient +// +genclient:noStatus +type SpiderMultusConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the specification of the MultusCNIConfig + Spec MultusCNIConfigSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true +type SpiderMultusConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SpiderMultusConfig `json:"items"` +} + +// MultusCNIConfigSpec defines the desired state of SpiderMultusConfig. +type MultusCNIConfigSpec struct { + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Enum=macvlan;ipvlan;sriov;ovs;ib-sriov;ipoib;custom + // +kubebuilder:default=custom + CniType *string `json:"cniType,omitempty"` + + // +kubebuilder:validation:Optional + MacvlanConfig *SpiderMacvlanCniConfig `json:"macvlan,omitempty"` + + // +kubebuilder:validation:Optional + IPVlanConfig *SpiderIPvlanCniConfig `json:"ipvlan,omitempty"` + + // +kubebuilder:validation:Optional + SriovConfig *SpiderSRIOVCniConfig `json:"sriov,omitempty"` + + // +kubebuilder:validation:Optional + OvsConfig *SpiderOvsCniConfig `json:"ovs,omitempty"` + + // +kubebuilder:validation:Optional + IbSriovConfig *SpiderIBSriovCniConfig `json:"ibsriov,omitempty"` + + // +kubebuilder:validation:Optional + IpoibConfig *SpiderIpoibCniConfig `json:"ipoib,omitempty"` + + // if CniType was set to custom, we'll mutate this field to be false + // +kubebuilder:default=true + // +kubebuilder:validation:Optional + EnableCoordinator *bool `json:"enableCoordinator,omitempty"` + + // +kubebuilder:default=false + // +kubebuilder:validation:Optional + DisableIPAM *bool `json:"disableIPAM,omitempty"` + + // +kubebuilder:validation:Optional + CoordinatorConfig *CoordinatorSpec `json:"coordinator,omitempty"` + + // ChainCNIJsonData is used to configure the configuration of chain CNI. + // format in json. + // +kubebuilder:validation:Optional + ChainCNIJsonData []string `json:"chainCNIJsonData"` + + // OtherCniTypeConfig only used for CniType custom, valid json format, can be empty + // +kubebuilder:validation:Optional + CustomCNIConfig *string `json:"customCNI,omitempty"` +} + +type SpiderMacvlanCniConfig struct { + // +kubebuilder:validation:Required + // The master interface(s) for the CNI configuration. At least one master interface must be specified. + // If multiple master interfaces are specified, the spiderpool will create a bond device with the bondConfig + // by the ifacer plugin. + Master []string `json:"master"` + + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=4094 + // The VLAN ID for the CNI configuration, optional and must be within the specified range: [0.4096). + VlanID *int32 `json:"vlanID,omitempty"` + + // +kubebuilder:validation:Optional + // Optional bond configuration for the CNI. It must not be nil if the multiple master interfaces are specified. + Bond *BondConfig `json:"bond,omitempty"` + + // +kubebuilder:validation:Optional + // The RDMA resource name of the nic. the RDMA resource is often reported to kubelet by the + // k8s-rdma-shared-dev-plugin. when it is not empty and spiderpool podResourceInject feature + // is enabled, spiderpool can automatically inject it into the container's resources via webhook. + RdmaResourceName string `json:"rdmaResourceName"` + + // +kubebuilder:validation:Optional + SpiderpoolConfigPools *SpiderpoolPools `json:"ippools,omitempty"` +} + +type SpiderIPvlanCniConfig struct { + // +kubebuilder:validation:Required + // The master interface(s) for the CNI configuration. At least one master interface must be specified. + // If multiple master interfaces are specified, the spiderpool will create a bond device with the bondConfig + // by the ifacer plugin. + Master []string `json:"master"` + + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=4094 + // The VLAN ID for the CNI configuration, optional and must be within the specified range: [0.4096). + VlanID *int32 `json:"vlanID,omitempty"` + + // +kubebuilder:validation:Optional + // Optional bond configuration for the CNI. It must not be nil if the multiple master interfaces are specified. + Bond *BondConfig `json:"bond,omitempty"` + + // +kubebuilder:validation:Optional + // The RDMA resource name of the nic. the RDMA resource is often reported to kubelet by the + // k8s-rdma-shared-dev-plugin. when it is not empty and spiderpool podResourceInject feature + // is enabled, spiderpool can automatically inject it into the container's resources via webhook. + RdmaResourceName string `json:"rdmaResourceName"` + + // +kubebuilder:validation:Optional + SpiderpoolConfigPools *SpiderpoolPools `json:"ippools,omitempty"` +} + +type SpiderSRIOVCniConfig struct { + // +kubebuilder:validation:Required + // The SR-IOV RDMA resource name of the SpiderMultusConfig. the SR-IOV RDMA resource is often + // reported to kubelet by the sriov-device-plugin. + ResourceName string `json:"resourceName"` + + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=4094 + // The VLAN ID for the CNI configuration, optional and must be within the specified range: [0.4096). + VlanID *int32 `json:"vlanID,omitempty"` + + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + MinTxRateMbps *int `json:"minTxRateMbps,omitempty"` + + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + // Mbps, 0 = disable rate limiting + MaxTxRateMbps *int `json:"maxTxRateMbps,omitempty"` // Mbps, 0 = disable rate limiting + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // +kubebuilder:validation:Optional + // rdmaIsolation enable RDMA CNI plugin is intended to be run as a chained CNI plugin. + // it ensures isolation of RDMA traffic from other workloads in the system by moving + // the associated RDMA interfaces of the provided network interface to the container's + // network namespace path. + RdmaIsolation bool `json:"rdmaIsolation"` + + // +kubebuilder:validation:Optional + SpiderpoolConfigPools *SpiderpoolPools `json:"ippools,omitempty"` +} + +type SpiderIBSriovCniConfig struct { + // +kubebuilder:validation:Required + // The SR-IOV RDMA resource name of the SpiderMultusConfig. the SR-IOV RDMA resource is often + // reported to kubelet by the sriov-device-plugin. + ResourceName string `json:"resourceName"` + + // +kubebuilder:validation:Optional + // infiniBand pkey for VF, this field is used by ib-kubernetes to add pkey with + // guid to InfiniBand subnet manager client e.g. Mellanox UFM, OpenSM + Pkey *string `json:"pkey,omitempty"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=enable + // +kubebuilder:validation:Enum=auto;enable;disable + // Enforces link state for the VF. Allowed values: auto, enable, disable. + LinkState *string `json:"linkState,omitempty"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=true + // +kubebuilder:validation:Optional + // rdmaIsolation enablw RDMA CNI plugin is intended to be run as a chained CNI plugin. + // it ensures isolation of RDMA traffic from other workloads in the system by moving + // the associated RDMA interfaces of the provided network interface to the container's + // network namespace path. + RdmaIsolation *bool `json:"rdmaIsolation,omitempty"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Enforces ib-sriov-cni to work with ib-kubernetes. + IbKubernetesEnabled *bool `json:"ibKubernetesEnabled,omitempty"` + + // +kubebuilder:validation:Optional + SpiderpoolConfigPools *SpiderpoolPools `json:"ippools,omitempty"` +} + +type SpiderIpoibCniConfig struct { + // +kubebuilder:validation:Required + // name of the host interface to create the link from. + Master string `json:"master,omitempty"` + + // +kubebuilder:validation:Optional + SpiderpoolConfigPools *SpiderpoolPools `json:"ippools,omitempty"` +} + +type SpiderOvsCniConfig struct { + // +kubebuilder:validation:Required + BrName string `json:"bridge"` + // +kubebuilder:validation:Optional + VlanTag *int32 `json:"vlan,omitempty"` + // +kubebuilder:validation:Optional + Trunk []*Trunk `json:"trunk,omitempty"` + // +kubebuilder:validation:Optional + // PCI address of a VF in valid sysfs format + DeviceID string `json:"deviceID"` + // +kubebuilder:validation:Optional + SpiderpoolConfigPools *SpiderpoolPools `json:"ippools,omitempty"` +} + +type Trunk struct { + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=4094 + MinID *uint `json:"minID,omitempty"` + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=4094 + MaxID *uint `json:"maxID,omitempty"` + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=4094 + ID *uint `json:"id,omitempty"` +} + +type BondConfig struct { + // +kubebuilder:validation:Required + Name string `json:"name"` + + // +kubebuilder:validation:Required + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=6 + Mode int32 `json:"mode"` + + // +kubebuilder:validation:Optional + Options *string `json:"options,omitempty"` +} + +// SpiderpoolPools could specify the IPAM spiderpool CNI configuration default IPv4&IPv6 pools. +type SpiderpoolPools struct { + // +kubebuilder:validation:Optional + IPv4IPPool []string `json:"ipv4,omitempty"` + + // +kubebuilder:validation:Optional + IPv6IPPool []string `json:"ipv6,omitempty"` +} + +func init() { + SchemeBuilder.Register(&SpiderMultusConfig{}, &SpiderMultusConfigList{}) +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderreservedip_types.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderreservedip_types.go new file mode 100644 index 0000000000..4993cf8ee8 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spiderreservedip_types.go @@ -0,0 +1,44 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ReservedIPSpec defines the desired state of SpiderReservedIP. +type ReservedIPSpec struct { + // +kubebuilder:validation:Enum=4;6 + // +kubebuilder:validation:Optional + IPVersion *int64 `json:"ipVersion,omitempty"` + + // +kubebuilder:validation:Optional + IPs []string `json:"ips,omitempty"` +} + +// +kubebuilder:resource:categories={spiderpool},path="spiderreservedips",scope="Cluster",shortName={sr},singular="spiderreservedip" +// +kubebuilder:printcolumn:JSONPath=".spec.ipVersion",description="ipVersion",name="VERSION",type=string +// +kubebuilder:object:root=true + +// SpiderReservedIP is the Schema for the spiderreservedips API. +type SpiderReservedIP struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ReservedIPSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// SpiderReservedIPList contains a list of SpiderReservedIP. +type SpiderReservedIPList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SpiderReservedIP `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SpiderReservedIP{}, &SpiderReservedIPList{}) +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidersubnet_types.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidersubnet_types.go new file mode 100644 index 0000000000..02c9275de2 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/spidersubnet_types.go @@ -0,0 +1,85 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// SubnetSpec defines the desired state of SpiderSubnet. +type SubnetSpec struct { + // +kubebuilder:validation:Enum=4;6 + // +kubebuilder:validation:Optional + IPVersion *int64 `json:"ipVersion,omitempty"` + + // +kubebuilder:validation:Required + Subnet string `json:"subnet"` + + // +kubebuilder:validation:Optional + IPs []string `json:"ips,omitempty"` + + // +kubebuilder:validation:Optional + ExcludeIPs []string `json:"excludeIPs,omitempty"` + + // +kubebuilder:validation:Optional + Gateway *string `json:"gateway,omitempty"` + + // +kubebuilder:validation:Optional + Routes []Route `json:"routes,omitempty"` +} + +// SubnetStatus defines the observed state of SpiderSubnet. +type SubnetStatus struct { + // +kubebuilder:validation:Optional + ControlledIPPools *string `json:"controlledIPPools,omitempty"` + + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Optional + TotalIPCount *int64 `json:"totalIPCount,omitempty"` + + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Optional + AllocatedIPCount *int64 `json:"allocatedIPCount,omitempty"` +} + +// PoolIPPreAllocations is a map of pool IP pre-allocation details indexed by pool name. +type PoolIPPreAllocations map[string]PoolIPPreAllocation + +type PoolIPPreAllocation struct { + IPs []string `json:"ips"` + Application *string `json:"application,omitempty"` +} + +// +kubebuilder:resource:categories={spiderpool},path="spidersubnets",scope="Cluster",shortName={ss},singular="spidersubnet" +// +kubebuilder:printcolumn:JSONPath=".spec.ipVersion",description="ipVersion",name="VERSION",type=string +// +kubebuilder:printcolumn:JSONPath=".spec.subnet",description="subnet",name="SUBNET",type=string +// +kubebuilder:printcolumn:JSONPath=".status.allocatedIPCount",description="allocatedIPCount",name="ALLOCATED-IP-COUNT",type=integer +// +kubebuilder:printcolumn:JSONPath=".status.totalIPCount",description="totalIPCount",name="TOTAL-IP-COUNT",type=integer +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +genclient +// +genclient:nonNamespaced + +// SpiderSubnet is the Schema for the spidersubnets API. +type SpiderSubnet struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SubnetSpec `json:"spec,omitempty"` + Status SubnetStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// SpiderSubnetList contains a list of SpiderSubnet. +type SpiderSubnetList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SpiderSubnet `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SpiderSubnet{}, &SpiderSubnetList{}) +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/types_string.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/types_string.go new file mode 100644 index 0000000000..b088ecf56c --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/types_string.go @@ -0,0 +1,215 @@ +// Copyright 2019 The Kubernetes Authors +// SPDX-License-Identifier: Apache-2.0 + +package v2beta1 + +import ( + "fmt" + "strings" + + stringutil "github.com/spidernet-io/spiderpool/pkg/utils/string" +) + +// String serves for SpiderIPPool +func (in *SpiderIPPool) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&SpiderIPPool{`, + `ObjectMeta:` + strings.Replace(fmt.Sprintf("%v", in.ObjectMeta), `&`, ``, 1) + `,`, + `Spec:` + strings.Replace(strings.Replace(in.Spec.String(), "IPPoolSpec", "IPPoolSpec", 1), `&`, ``, 1) + `,`, + `Status:` + strings.Replace(strings.Replace(in.Status.String(), "IPPoolStatus", "IPPoolStatus", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderIPPool Spec IPPoolSpec +func (in *IPPoolSpec) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&IPPoolSpec{`, + `IPVersion:` + stringutil.ValueToStringGenerated(in.IPVersion) + `,`, + `Subnet:` + fmt.Sprintf("%v", in.Subnet) + `,`, + `IPs:` + fmt.Sprintf("%v", in.IPs) + `,`, + `ExcludeIPs:` + fmt.Sprintf("%v", in.ExcludeIPs) + `,`, + `Gateway:` + stringutil.ValueToStringGenerated(in.Gateway) + `,`, + `Routes:` + fmt.Sprintf("%+v", in.Routes) + `,`, + `PodAffinity:` + fmt.Sprintf("%v", in.PodAffinity.String()) + `,`, + `NamespaceAffinity:` + fmt.Sprintf("%v", in.NamespaceAffinity.String()) + `,`, + `NamespaceName:` + fmt.Sprintf("%v", in.NamespaceName) + `,`, + `NodeAffinity:` + fmt.Sprintf("%v", in.NodeAffinity.String()) + `,`, + `NodeName:` + fmt.Sprintf("%v", in.NodeName) + `,`, + `MultusName:` + fmt.Sprintf("%v", in.MultusName) + `,`, + `Default:` + stringutil.ValueToStringGenerated(in.Default) + `,`, + `Disable:` + stringutil.ValueToStringGenerated(in.Disable) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderIPPool Status IPPoolStatus +func (in *IPPoolStatus) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&IPPoolStatus{`, + `AllocatedIPs:` + stringutil.ValueToStringGenerated(in.AllocatedIPs) + `,`, + `TotalIPCount:` + stringutil.ValueToStringGenerated(in.TotalIPCount) + `,`, + `AllocatedIPCount:` + stringutil.ValueToStringGenerated(in.AllocatedIPCount) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderEndpoint +func (in *SpiderEndpoint) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&SpiderEndpoint{`, + `ObjectMeta:` + strings.Replace(fmt.Sprintf("%v", in.ObjectMeta), `&`, ``, 1) + `,`, + `Status:` + in.Status.String() + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderEndpoint Status WorkloadEndpointStatus +func (in *WorkloadEndpointStatus) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&WorkloadEndpointStatus{`, + `Current:` + fmt.Sprintf("%v", in.Current.String()) + `,`, + `OwnerControllerType:` + fmt.Sprintf("%v", in.OwnerControllerType) + `,`, + `OwnerControllerName:` + fmt.Sprintf("%v", in.OwnerControllerName) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderEndpoint Status PodIPAllocation +func (in *PodIPAllocation) String() string { + if in == nil { + return "nil" + } + + repeatedStringForIPs := "[]IPs{" + for _, f := range in.IPs { + repeatedStringForIPs += strings.Replace(strings.Replace(f.String(), "IPs", "IPs", 1), `&`, ``, 1) + "," + } + repeatedStringForIPs += "}" + + s := strings.Join([]string{`&PodIPAllocation{`, + `UID:` + fmt.Sprintf("%+v", in.UID) + `,`, + `Node:` + fmt.Sprintf("%+v", in.Node) + `,`, + `IPs:` + repeatedStringForIPs + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderEndpoint Status +func (in *IPAllocationDetail) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&IPAllocationDetail{`, + `NIC:` + fmt.Sprintf("%v", in.NIC) + `,`, + `IPv4:` + stringutil.ValueToStringGenerated(in.IPv4) + `,`, + `IPv6:` + stringutil.ValueToStringGenerated(in.IPv6) + `,`, + `IPv4Pool:` + stringutil.ValueToStringGenerated(in.IPv4Pool) + `,`, + `IPv6Pool:` + stringutil.ValueToStringGenerated(in.IPv6Pool) + `,`, + `Vlan:` + stringutil.ValueToStringGenerated(in.Vlan) + `,`, + `IPv4Gateway:` + stringutil.ValueToStringGenerated(in.IPv4Gateway) + `,`, + `IPv6Gateway:` + stringutil.ValueToStringGenerated(in.IPv6Gateway) + `,`, + `CleanGateway:` + stringutil.ValueToStringGenerated(in.CleanGateway) + `,`, + `Routes:` + fmt.Sprintf("%+v", in.Routes) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderReservedIP +func (in *SpiderReservedIP) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&SpiderReservedIP{`, + `ObjectMeta:` + strings.Replace(fmt.Sprintf("%v", in.ObjectMeta), `&`, ``, 1) + `,`, + `Spec:` + strings.Replace(strings.Replace(in.Spec.String(), "ReservedIPSpec", "ReservedIPSpec", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderReservedIP Spec +func (in *ReservedIPSpec) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&ReservedIPSpec{`, + `IPVersion:` + stringutil.ValueToStringGenerated(in.IPVersion) + `,`, + `IPs:` + fmt.Sprintf("%v", in.IPs) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderSubnet +func (in *SpiderSubnet) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&SpiderSubnet{`, + `ObjectMeta:` + strings.Replace(fmt.Sprintf("%v", in.ObjectMeta), `&`, ``, 1) + `,`, + `Spec:` + strings.Replace(strings.Replace(in.Spec.String(), "SubnetSpec", "SubnetSpec", 1), `&`, ``, 1) + `,`, + `Status:` + strings.Replace(strings.Replace(in.Status.String(), "SubnetStatus", "SubnetStatus", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderSubnet Spec +func (in *SubnetSpec) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`&SubnetSpec{`, + `IPVersion:` + stringutil.ValueToStringGenerated(in.IPVersion) + `,`, + `Subnet:` + fmt.Sprintf("%v", in.Subnet) + `,`, + `IPs:` + fmt.Sprintf("%v", in.IPs) + `,`, + `ExcludeIPs:` + fmt.Sprintf("%v", in.ExcludeIPs) + `,`, + `Gateway:` + stringutil.ValueToStringGenerated(in.Gateway) + `,`, + `Routes:` + fmt.Sprintf("%+v", in.Routes) + `,`, + `}`, + }, "") + return s +} + +// String serves for SpiderSubnet Status +func (in *SubnetStatus) String() string { + if in == nil { + return "nil" + } + + s := strings.Join([]string{`SubnetStatus{`, + `ControlledIPPools:` + stringutil.ValueToStringGenerated(in.ControlledIPPools) + `,`, + `TotalIPCount:` + stringutil.ValueToStringGenerated(in.TotalIPCount) + `,`, + `AllocatedIPCount:` + stringutil.ValueToStringGenerated(in.AllocatedIPCount) + `,`, + `}`, + }, "") + return s +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v1/zz_generated.deepcopy.go b/pkg/k8s/apis/spiderpool.spidernet.io/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..6bb17093f9 --- /dev/null +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v1/zz_generated.deepcopy.go @@ -0,0 +1,1216 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by controller-gen. DO NOT EDIT. + +package v2beta1 + +import ( + "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BondConfig) DeepCopyInto(out *BondConfig) { + *out = *in + if in.Options != nil { + in, out := &in.Options, &out.Options + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BondConfig. +func (in *BondConfig) DeepCopy() *BondConfig { + if in == nil { + return nil + } + out := new(BondConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CoordinatorSpec) DeepCopyInto(out *CoordinatorSpec) { + *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(string) + **out = **in + } + if in.PodCIDRType != nil { + in, out := &in.PodCIDRType, &out.PodCIDRType + *out = new(string) + **out = **in + } + if in.HijackCIDR != nil { + in, out := &in.HijackCIDR, &out.HijackCIDR + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.PodMACPrefix != nil { + in, out := &in.PodMACPrefix, &out.PodMACPrefix + *out = new(string) + **out = **in + } + if in.TunePodRoutes != nil { + in, out := &in.TunePodRoutes, &out.TunePodRoutes + *out = new(bool) + **out = **in + } + if in.PodDefaultRouteNIC != nil { + in, out := &in.PodDefaultRouteNIC, &out.PodDefaultRouteNIC + *out = new(string) + **out = **in + } + if in.HostRuleTable != nil { + in, out := &in.HostRuleTable, &out.HostRuleTable + *out = new(int) + **out = **in + } + if in.PodRPFilter != nil { + in, out := &in.PodRPFilter, &out.PodRPFilter + *out = new(int) + **out = **in + } + if in.TxQueueLen != nil { + in, out := &in.TxQueueLen, &out.TxQueueLen + *out = new(int) + **out = **in + } + if in.DetectIPConflict != nil { + in, out := &in.DetectIPConflict, &out.DetectIPConflict + *out = new(bool) + **out = **in + } + if in.DetectGateway != nil { + in, out := &in.DetectGateway, &out.DetectGateway + *out = new(bool) + **out = **in + } + if in.VethLinkAddress != nil { + in, out := &in.VethLinkAddress, &out.VethLinkAddress + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoordinatorSpec. +func (in *CoordinatorSpec) DeepCopy() *CoordinatorSpec { + if in == nil { + return nil + } + out := new(CoordinatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CoordinatorStatus) DeepCopyInto(out *CoordinatorStatus) { + *out = *in + if in.OverlayPodCIDR != nil { + in, out := &in.OverlayPodCIDR, &out.OverlayPodCIDR + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ServiceCIDR != nil { + in, out := &in.ServiceCIDR, &out.ServiceCIDR + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoordinatorStatus. +func (in *CoordinatorStatus) DeepCopy() *CoordinatorStatus { + if in == nil { + return nil + } + out := new(CoordinatorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAllocationDetail) DeepCopyInto(out *IPAllocationDetail) { + *out = *in + if in.IPv4 != nil { + in, out := &in.IPv4, &out.IPv4 + *out = new(string) + **out = **in + } + if in.IPv6 != nil { + in, out := &in.IPv6, &out.IPv6 + *out = new(string) + **out = **in + } + if in.IPv4Pool != nil { + in, out := &in.IPv4Pool, &out.IPv4Pool + *out = new(string) + **out = **in + } + if in.IPv6Pool != nil { + in, out := &in.IPv6Pool, &out.IPv6Pool + *out = new(string) + **out = **in + } + if in.Vlan != nil { + in, out := &in.Vlan, &out.Vlan + *out = new(int64) + **out = **in + } + if in.IPv4Gateway != nil { + in, out := &in.IPv4Gateway, &out.IPv4Gateway + *out = new(string) + **out = **in + } + if in.IPv6Gateway != nil { + in, out := &in.IPv6Gateway, &out.IPv6Gateway + *out = new(string) + **out = **in + } + if in.CleanGateway != nil { + in, out := &in.CleanGateway, &out.CleanGateway + *out = new(bool) + **out = **in + } + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]Route, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAllocationDetail. +func (in *IPAllocationDetail) DeepCopy() *IPAllocationDetail { + if in == nil { + return nil + } + out := new(IPAllocationDetail) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolSpec) DeepCopyInto(out *IPPoolSpec) { + *out = *in + if in.IPVersion != nil { + in, out := &in.IPVersion, &out.IPVersion + *out = new(int64) + **out = **in + } + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExcludeIPs != nil { + in, out := &in.ExcludeIPs, &out.ExcludeIPs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(string) + **out = **in + } + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]Route, len(*in)) + copy(*out, *in) + } + if in.PodAffinity != nil { + in, out := &in.PodAffinity, &out.PodAffinity + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.NamespaceAffinity != nil { + in, out := &in.NamespaceAffinity, &out.NamespaceAffinity + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.NamespaceName != nil { + in, out := &in.NamespaceName, &out.NamespaceName + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.NodeAffinity != nil { + in, out := &in.NodeAffinity, &out.NodeAffinity + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.NodeName != nil { + in, out := &in.NodeName, &out.NodeName + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.MultusName != nil { + in, out := &in.MultusName, &out.MultusName + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Default != nil { + in, out := &in.Default, &out.Default + *out = new(bool) + **out = **in + } + if in.Disable != nil { + in, out := &in.Disable, &out.Disable + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolSpec. +func (in *IPPoolSpec) DeepCopy() *IPPoolSpec { + if in == nil { + return nil + } + out := new(IPPoolSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolStatus) DeepCopyInto(out *IPPoolStatus) { + *out = *in + if in.AllocatedIPs != nil { + in, out := &in.AllocatedIPs, &out.AllocatedIPs + *out = new(string) + **out = **in + } + if in.TotalIPCount != nil { + in, out := &in.TotalIPCount, &out.TotalIPCount + *out = new(int64) + **out = **in + } + if in.AllocatedIPCount != nil { + in, out := &in.AllocatedIPCount, &out.AllocatedIPCount + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolStatus. +func (in *IPPoolStatus) DeepCopy() *IPPoolStatus { + if in == nil { + return nil + } + out := new(IPPoolStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MultusCNIConfigSpec) DeepCopyInto(out *MultusCNIConfigSpec) { + *out = *in + if in.CniType != nil { + in, out := &in.CniType, &out.CniType + *out = new(string) + **out = **in + } + if in.MacvlanConfig != nil { + in, out := &in.MacvlanConfig, &out.MacvlanConfig + *out = new(SpiderMacvlanCniConfig) + (*in).DeepCopyInto(*out) + } + if in.IPVlanConfig != nil { + in, out := &in.IPVlanConfig, &out.IPVlanConfig + *out = new(SpiderIPvlanCniConfig) + (*in).DeepCopyInto(*out) + } + if in.SriovConfig != nil { + in, out := &in.SriovConfig, &out.SriovConfig + *out = new(SpiderSRIOVCniConfig) + (*in).DeepCopyInto(*out) + } + if in.OvsConfig != nil { + in, out := &in.OvsConfig, &out.OvsConfig + *out = new(SpiderOvsCniConfig) + (*in).DeepCopyInto(*out) + } + if in.IbSriovConfig != nil { + in, out := &in.IbSriovConfig, &out.IbSriovConfig + *out = new(SpiderIBSriovCniConfig) + (*in).DeepCopyInto(*out) + } + if in.IpoibConfig != nil { + in, out := &in.IpoibConfig, &out.IpoibConfig + *out = new(SpiderIpoibCniConfig) + (*in).DeepCopyInto(*out) + } + if in.EnableCoordinator != nil { + in, out := &in.EnableCoordinator, &out.EnableCoordinator + *out = new(bool) + **out = **in + } + if in.DisableIPAM != nil { + in, out := &in.DisableIPAM, &out.DisableIPAM + *out = new(bool) + **out = **in + } + if in.CoordinatorConfig != nil { + in, out := &in.CoordinatorConfig, &out.CoordinatorConfig + *out = new(CoordinatorSpec) + (*in).DeepCopyInto(*out) + } + if in.ChainCNIJsonData != nil { + in, out := &in.ChainCNIJsonData, &out.ChainCNIJsonData + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.CustomCNIConfig != nil { + in, out := &in.CustomCNIConfig, &out.CustomCNIConfig + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultusCNIConfigSpec. +func (in *MultusCNIConfigSpec) DeepCopy() *MultusCNIConfigSpec { + if in == nil { + return nil + } + out := new(MultusCNIConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodIPAllocation) DeepCopyInto(out *PodIPAllocation) { + *out = *in + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]IPAllocationDetail, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodIPAllocation. +func (in *PodIPAllocation) DeepCopy() *PodIPAllocation { + if in == nil { + return nil + } + out := new(PodIPAllocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PoolIPAllocation) DeepCopyInto(out *PoolIPAllocation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PoolIPAllocation. +func (in *PoolIPAllocation) DeepCopy() *PoolIPAllocation { + if in == nil { + return nil + } + out := new(PoolIPAllocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in PoolIPAllocations) DeepCopyInto(out *PoolIPAllocations) { + { + in := &in + *out = make(PoolIPAllocations, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PoolIPAllocations. +func (in PoolIPAllocations) DeepCopy() PoolIPAllocations { + if in == nil { + return nil + } + out := new(PoolIPAllocations) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PoolIPPreAllocation) DeepCopyInto(out *PoolIPPreAllocation) { + *out = *in + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Application != nil { + in, out := &in.Application, &out.Application + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PoolIPPreAllocation. +func (in *PoolIPPreAllocation) DeepCopy() *PoolIPPreAllocation { + if in == nil { + return nil + } + out := new(PoolIPPreAllocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in PoolIPPreAllocations) DeepCopyInto(out *PoolIPPreAllocations) { + { + in := &in + *out = make(PoolIPPreAllocations, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PoolIPPreAllocations. +func (in PoolIPPreAllocations) DeepCopy() PoolIPPreAllocations { + if in == nil { + return nil + } + out := new(PoolIPPreAllocations) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ReservedIPSpec) DeepCopyInto(out *ReservedIPSpec) { + *out = *in + if in.IPVersion != nil { + in, out := &in.IPVersion, &out.IPVersion + *out = new(int64) + **out = **in + } + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReservedIPSpec. +func (in *ReservedIPSpec) DeepCopy() *ReservedIPSpec { + if in == nil { + return nil + } + out := new(ReservedIPSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Route) DeepCopyInto(out *Route) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpiderCoordinator) DeepCopyInto(out *SpiderCoordinator) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderCoordinator. +func (in *SpiderCoordinator) DeepCopy() *SpiderCoordinator { + if in == nil { + return nil + } + out := new(SpiderCoordinator) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderCoordinator) 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 *SpiderCoordinatorList) DeepCopyInto(out *SpiderCoordinatorList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SpiderCoordinator, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderCoordinatorList. +func (in *SpiderCoordinatorList) DeepCopy() *SpiderCoordinatorList { + if in == nil { + return nil + } + out := new(SpiderCoordinatorList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderCoordinatorList) 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 *SpiderEndpoint) DeepCopyInto(out *SpiderEndpoint) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderEndpoint. +func (in *SpiderEndpoint) DeepCopy() *SpiderEndpoint { + if in == nil { + return nil + } + out := new(SpiderEndpoint) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderEndpoint) 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 *SpiderEndpointList) DeepCopyInto(out *SpiderEndpointList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SpiderEndpoint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderEndpointList. +func (in *SpiderEndpointList) DeepCopy() *SpiderEndpointList { + if in == nil { + return nil + } + out := new(SpiderEndpointList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderEndpointList) 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 *SpiderIBSriovCniConfig) DeepCopyInto(out *SpiderIBSriovCniConfig) { + *out = *in + if in.Pkey != nil { + in, out := &in.Pkey, &out.Pkey + *out = new(string) + **out = **in + } + if in.LinkState != nil { + in, out := &in.LinkState, &out.LinkState + *out = new(string) + **out = **in + } + if in.RdmaIsolation != nil { + in, out := &in.RdmaIsolation, &out.RdmaIsolation + *out = new(bool) + **out = **in + } + if in.IbKubernetesEnabled != nil { + in, out := &in.IbKubernetesEnabled, &out.IbKubernetesEnabled + *out = new(bool) + **out = **in + } + if in.SpiderpoolConfigPools != nil { + in, out := &in.SpiderpoolConfigPools, &out.SpiderpoolConfigPools + *out = new(SpiderpoolPools) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderIBSriovCniConfig. +func (in *SpiderIBSriovCniConfig) DeepCopy() *SpiderIBSriovCniConfig { + if in == nil { + return nil + } + out := new(SpiderIBSriovCniConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpiderIPPool) DeepCopyInto(out *SpiderIPPool) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderIPPool. +func (in *SpiderIPPool) DeepCopy() *SpiderIPPool { + if in == nil { + return nil + } + out := new(SpiderIPPool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderIPPool) 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 *SpiderIPPoolList) DeepCopyInto(out *SpiderIPPoolList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SpiderIPPool, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderIPPoolList. +func (in *SpiderIPPoolList) DeepCopy() *SpiderIPPoolList { + if in == nil { + return nil + } + out := new(SpiderIPPoolList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderIPPoolList) 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 *SpiderIPvlanCniConfig) DeepCopyInto(out *SpiderIPvlanCniConfig) { + *out = *in + if in.Master != nil { + in, out := &in.Master, &out.Master + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.VlanID != nil { + in, out := &in.VlanID, &out.VlanID + *out = new(int32) + **out = **in + } + if in.Bond != nil { + in, out := &in.Bond, &out.Bond + *out = new(BondConfig) + (*in).DeepCopyInto(*out) + } + if in.SpiderpoolConfigPools != nil { + in, out := &in.SpiderpoolConfigPools, &out.SpiderpoolConfigPools + *out = new(SpiderpoolPools) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderIPvlanCniConfig. +func (in *SpiderIPvlanCniConfig) DeepCopy() *SpiderIPvlanCniConfig { + if in == nil { + return nil + } + out := new(SpiderIPvlanCniConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpiderIpoibCniConfig) DeepCopyInto(out *SpiderIpoibCniConfig) { + *out = *in + if in.SpiderpoolConfigPools != nil { + in, out := &in.SpiderpoolConfigPools, &out.SpiderpoolConfigPools + *out = new(SpiderpoolPools) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderIpoibCniConfig. +func (in *SpiderIpoibCniConfig) DeepCopy() *SpiderIpoibCniConfig { + if in == nil { + return nil + } + out := new(SpiderIpoibCniConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpiderMacvlanCniConfig) DeepCopyInto(out *SpiderMacvlanCniConfig) { + *out = *in + if in.Master != nil { + in, out := &in.Master, &out.Master + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.VlanID != nil { + in, out := &in.VlanID, &out.VlanID + *out = new(int32) + **out = **in + } + if in.Bond != nil { + in, out := &in.Bond, &out.Bond + *out = new(BondConfig) + (*in).DeepCopyInto(*out) + } + if in.SpiderpoolConfigPools != nil { + in, out := &in.SpiderpoolConfigPools, &out.SpiderpoolConfigPools + *out = new(SpiderpoolPools) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderMacvlanCniConfig. +func (in *SpiderMacvlanCniConfig) DeepCopy() *SpiderMacvlanCniConfig { + if in == nil { + return nil + } + out := new(SpiderMacvlanCniConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpiderMultusConfig) DeepCopyInto(out *SpiderMultusConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderMultusConfig. +func (in *SpiderMultusConfig) DeepCopy() *SpiderMultusConfig { + if in == nil { + return nil + } + out := new(SpiderMultusConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderMultusConfig) 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 *SpiderMultusConfigList) DeepCopyInto(out *SpiderMultusConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SpiderMultusConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderMultusConfigList. +func (in *SpiderMultusConfigList) DeepCopy() *SpiderMultusConfigList { + if in == nil { + return nil + } + out := new(SpiderMultusConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderMultusConfigList) 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 *SpiderOvsCniConfig) DeepCopyInto(out *SpiderOvsCniConfig) { + *out = *in + if in.VlanTag != nil { + in, out := &in.VlanTag, &out.VlanTag + *out = new(int32) + **out = **in + } + if in.Trunk != nil { + in, out := &in.Trunk, &out.Trunk + *out = make([]*Trunk, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Trunk) + (*in).DeepCopyInto(*out) + } + } + } + if in.SpiderpoolConfigPools != nil { + in, out := &in.SpiderpoolConfigPools, &out.SpiderpoolConfigPools + *out = new(SpiderpoolPools) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderOvsCniConfig. +func (in *SpiderOvsCniConfig) DeepCopy() *SpiderOvsCniConfig { + if in == nil { + return nil + } + out := new(SpiderOvsCniConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpiderReservedIP) DeepCopyInto(out *SpiderReservedIP) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderReservedIP. +func (in *SpiderReservedIP) DeepCopy() *SpiderReservedIP { + if in == nil { + return nil + } + out := new(SpiderReservedIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderReservedIP) 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 *SpiderReservedIPList) DeepCopyInto(out *SpiderReservedIPList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SpiderReservedIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderReservedIPList. +func (in *SpiderReservedIPList) DeepCopy() *SpiderReservedIPList { + if in == nil { + return nil + } + out := new(SpiderReservedIPList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderReservedIPList) 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 *SpiderSRIOVCniConfig) DeepCopyInto(out *SpiderSRIOVCniConfig) { + *out = *in + if in.VlanID != nil { + in, out := &in.VlanID, &out.VlanID + *out = new(int32) + **out = **in + } + if in.MinTxRateMbps != nil { + in, out := &in.MinTxRateMbps, &out.MinTxRateMbps + *out = new(int) + **out = **in + } + if in.MaxTxRateMbps != nil { + in, out := &in.MaxTxRateMbps, &out.MaxTxRateMbps + *out = new(int) + **out = **in + } + if in.SpiderpoolConfigPools != nil { + in, out := &in.SpiderpoolConfigPools, &out.SpiderpoolConfigPools + *out = new(SpiderpoolPools) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderSRIOVCniConfig. +func (in *SpiderSRIOVCniConfig) DeepCopy() *SpiderSRIOVCniConfig { + if in == nil { + return nil + } + out := new(SpiderSRIOVCniConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpiderSubnet) DeepCopyInto(out *SpiderSubnet) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderSubnet. +func (in *SpiderSubnet) DeepCopy() *SpiderSubnet { + if in == nil { + return nil + } + out := new(SpiderSubnet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderSubnet) 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 *SpiderSubnetList) DeepCopyInto(out *SpiderSubnetList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SpiderSubnet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderSubnetList. +func (in *SpiderSubnetList) DeepCopy() *SpiderSubnetList { + if in == nil { + return nil + } + out := new(SpiderSubnetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpiderSubnetList) 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 *SpiderpoolPools) DeepCopyInto(out *SpiderpoolPools) { + *out = *in + if in.IPv4IPPool != nil { + in, out := &in.IPv4IPPool, &out.IPv4IPPool + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.IPv6IPPool != nil { + in, out := &in.IPv6IPPool, &out.IPv6IPPool + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpiderpoolPools. +func (in *SpiderpoolPools) DeepCopy() *SpiderpoolPools { + if in == nil { + return nil + } + out := new(SpiderpoolPools) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubnetSpec) DeepCopyInto(out *SubnetSpec) { + *out = *in + if in.IPVersion != nil { + in, out := &in.IPVersion, &out.IPVersion + *out = new(int64) + **out = **in + } + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExcludeIPs != nil { + in, out := &in.ExcludeIPs, &out.ExcludeIPs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(string) + **out = **in + } + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]Route, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubnetSpec. +func (in *SubnetSpec) DeepCopy() *SubnetSpec { + if in == nil { + return nil + } + out := new(SubnetSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubnetStatus) DeepCopyInto(out *SubnetStatus) { + *out = *in + if in.ControlledIPPools != nil { + in, out := &in.ControlledIPPools, &out.ControlledIPPools + *out = new(string) + **out = **in + } + if in.TotalIPCount != nil { + in, out := &in.TotalIPCount, &out.TotalIPCount + *out = new(int64) + **out = **in + } + if in.AllocatedIPCount != nil { + in, out := &in.AllocatedIPCount, &out.AllocatedIPCount + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubnetStatus. +func (in *SubnetStatus) DeepCopy() *SubnetStatus { + if in == nil { + return nil + } + out := new(SubnetStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Trunk) DeepCopyInto(out *Trunk) { + *out = *in + if in.MinID != nil { + in, out := &in.MinID, &out.MinID + *out = new(uint) + **out = **in + } + if in.MaxID != nil { + in, out := &in.MaxID, &out.MaxID + *out = new(uint) + **out = **in + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(uint) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Trunk. +func (in *Trunk) DeepCopy() *Trunk { + if in == nil { + return nil + } + out := new(Trunk) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkloadEndpointStatus) DeepCopyInto(out *WorkloadEndpointStatus) { + *out = *in + in.Current.DeepCopyInto(&out.Current) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadEndpointStatus. +func (in *WorkloadEndpointStatus) DeepCopy() *WorkloadEndpointStatus { + if in == nil { + return nil + } + out := new(WorkloadEndpointStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1/spidermultus_types.go b/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1/spidermultus_types.go index 1512dc82ec..4a95ac4dee 100644 --- a/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1/spidermultus_types.go +++ b/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1/spidermultus_types.go @@ -74,25 +74,25 @@ type MultusCNIConfigSpec struct { type SpiderMacvlanCniConfig struct { // +kubebuilder:validation:Required + // The master interface(s) for the CNI configuration. At least one master interface must be specified. + // If multiple master interfaces are specified, the spiderpool will create a bond device with the bondConfig + // by the ifacer plugin. Master []string `json:"master"` // +kubebuilder:validation:Optional // +kubebuilder:validation:Minimum=0 // +kubebuilder:validation:Maximum=4094 + // The VLAN ID for the CNI configuration, optional and must be within the specified range: [0.4096). VlanID *int32 `json:"vlanID,omitempty"` // +kubebuilder:validation:Optional + // Optional bond configuration for the CNI. It must not be nil if the multiple master interfaces are specified. Bond *BondConfig `json:"bond,omitempty"` - // +kubebuilder:default=false - // +kubebuilder:validation:Optional - // enable share rdma for macvlan - EnableRdma bool `json:"enableRdma"` - // +kubebuilder:validation:Optional - // Resource name of the rdma device-plugin, If it's empty and enableRdma is true, - // the value will be auto set by operator. and the user can also set this value - // manually. + // The RDMA resource name of the nic. the RDMA resource is often reported to kubelet by the + // k8s-rdma-shared-dev-plugin. when it is not empty and spiderpool podResourceInject feature + // is enabled, spiderpool can automatically inject it into the container's resources via webhook. RdmaResourceName string `json:"rdmaResourceName"` // +kubebuilder:validation:Optional @@ -101,25 +101,25 @@ type SpiderMacvlanCniConfig struct { type SpiderIPvlanCniConfig struct { // +kubebuilder:validation:Required + // The master interface(s) for the CNI configuration. At least one master interface must be specified. + // If multiple master interfaces are specified, the spiderpool will create a bond device with the bondConfig + // by the ifacer plugin. Master []string `json:"master"` // +kubebuilder:validation:Optional // +kubebuilder:validation:Minimum=0 // +kubebuilder:validation:Maximum=4094 + // The VLAN ID for the CNI configuration, optional and must be within the specified range: [0.4096). VlanID *int32 `json:"vlanID,omitempty"` // +kubebuilder:validation:Optional + // Optional bond configuration for the CNI. It must not be nil if the multiple master interfaces are specified. Bond *BondConfig `json:"bond,omitempty"` - // +kubebuilder:default=false // +kubebuilder:validation:Optional - // enable share rdma for ipvlan - EnableRdma bool `json:"enableRdma"` - - // +kubebuilder:validation:Optional - // Resource name of the rdma device-plugin, If it's empty and enableRdma is true, - // the value will be auto set by operator. and the user can also set this value - // manually. + // The RDMA resource name of the nic. the RDMA resource is often reported to kubelet by the + // k8s-rdma-shared-dev-plugin. when it is not empty and spiderpool podResourceInject feature + // is enabled, spiderpool can automatically inject it into the container's resources via webhook. RdmaResourceName string `json:"rdmaResourceName"` // +kubebuilder:validation:Optional @@ -128,47 +128,73 @@ type SpiderIPvlanCniConfig struct { type SpiderSRIOVCniConfig struct { // +kubebuilder:validation:Required + // The SR-IOV RDMA resource name of the SpiderMultusConfig. the SR-IOV RDMA resource is often + // reported to kubelet by the sriov-device-plugin. ResourceName string `json:"resourceName"` // +kubebuilder:validation:Optional // +kubebuilder:validation:Minimum=0 // +kubebuilder:validation:Maximum=4094 + // The VLAN ID for the CNI configuration, optional and must be within the specified range: [0.4096). VlanID *int32 `json:"vlanID,omitempty"` // +kubebuilder:validation:Optional // +kubebuilder:validation:Minimum=0 - MinTxRateMbps *int `json:"minTxRateMbps,omitempty"` // Mbps, 0 = disable rate limiting + MinTxRateMbps *int `json:"minTxRateMbps,omitempty"` // +kubebuilder:validation:Optional // +kubebuilder:validation:Minimum=0 + // Mbps, 0 = disable rate limiting MaxTxRateMbps *int `json:"maxTxRateMbps,omitempty"` // Mbps, 0 = disable rate limiting // +kubebuilder:default=false // +kubebuilder:validation:Optional + // +kubebuilder:deprecated:reason="This field is deprecated and will be removed in future versions." + // DEPRECATED, use RdmaIsolation flled instead. EnableRdma bool `json:"enableRdma"` + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // +kubebuilder:validation:Optional + // rdmaIsolation enable RDMA CNI plugin is intended to be run as a chained CNI plugin. + // it ensures isolation of RDMA traffic from other workloads in the system by moving + // the associated RDMA interfaces of the provided network interface to the container's + // network namespace path. + RdmaIsolation bool `json:"rdmaIsolation"` + // +kubebuilder:validation:Optional SpiderpoolConfigPools *SpiderpoolPools `json:"ippools,omitempty"` } type SpiderIBSriovCniConfig struct { // +kubebuilder:validation:Required + // The SR-IOV RDMA resource name of the SpiderMultusConfig. the SR-IOV RDMA resource is often + // reported to kubelet by the sriov-device-plugin. ResourceName string `json:"resourceName"` // +kubebuilder:validation:Optional + // infiniBand pkey for VF, this field is used by ib-kubernetes to add pkey with + // guid to InfiniBand subnet manager client e.g. Mellanox UFM, OpenSM Pkey *string `json:"pkey,omitempty"` // +kubebuilder:validation:Optional // +kubebuilder:default=enable // +kubebuilder:validation:Enum=auto;enable;disable + // Enforces link state for the VF. Allowed values: auto, enable, disable. LinkState *string `json:"linkState,omitempty"` // +kubebuilder:validation:Optional // +kubebuilder:default=true + // +kubebuilder:validation:Optional + // rdmaIsolation enablw RDMA CNI plugin is intended to be run as a chained CNI plugin. + // it ensures isolation of RDMA traffic from other workloads in the system by moving + // the associated RDMA interfaces of the provided network interface to the container's + // network namespace path. RdmaIsolation *bool `json:"rdmaIsolation,omitempty"` // +kubebuilder:validation:Optional // +kubebuilder:default=false + // Enforces ib-sriov-cni to work with ib-kubernetes. IbKubernetesEnabled *bool `json:"ibKubernetesEnabled,omitempty"` // +kubebuilder:validation:Optional @@ -177,6 +203,7 @@ type SpiderIBSriovCniConfig struct { type SpiderIpoibCniConfig struct { // +kubebuilder:validation:Required + // name of the host interface to create the link from. Master string `json:"master,omitempty"` // +kubebuilder:validation:Optional diff --git a/pkg/k8s/client/clientset/versioned/clientset.go b/pkg/k8s/client/clientset/versioned/clientset.go index 06a71c391f..f2b24f962b 100644 --- a/pkg/k8s/client/clientset/versioned/clientset.go +++ b/pkg/k8s/client/clientset/versioned/clientset.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1" spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v2beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" @@ -17,15 +18,22 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface + SpiderpoolV1() spiderpoolv1.SpiderpoolV1Interface SpiderpoolV2beta1() spiderpoolv2beta1.SpiderpoolV2beta1Interface } // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient + spiderpoolV1 *spiderpoolv1.SpiderpoolV1Client spiderpoolV2beta1 *spiderpoolv2beta1.SpiderpoolV2beta1Client } +// SpiderpoolV1 retrieves the SpiderpoolV1Client +func (c *Clientset) SpiderpoolV1() spiderpoolv1.SpiderpoolV1Interface { + return c.spiderpoolV1 +} + // SpiderpoolV2beta1 retrieves the SpiderpoolV2beta1Client func (c *Clientset) SpiderpoolV2beta1() spiderpoolv2beta1.SpiderpoolV2beta1Interface { return c.spiderpoolV2beta1 @@ -75,6 +83,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error + cs.spiderpoolV1, err = spiderpoolv1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.spiderpoolV2beta1, err = spiderpoolv2beta1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -100,6 +112,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset + cs.spiderpoolV1 = spiderpoolv1.New(c) cs.spiderpoolV2beta1 = spiderpoolv2beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/pkg/k8s/client/clientset/versioned/fake/clientset_generated.go b/pkg/k8s/client/clientset/versioned/fake/clientset_generated.go index d04ca1d2ce..437825215b 100644 --- a/pkg/k8s/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/k8s/client/clientset/versioned/fake/clientset_generated.go @@ -7,6 +7,8 @@ package fake import ( clientset "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1" + fakespiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake" spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v2beta1" fakespiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v2beta1/fake" "k8s.io/apimachinery/pkg/runtime" @@ -66,6 +68,11 @@ var ( _ testing.FakeClient = &Clientset{} ) +// SpiderpoolV1 retrieves the SpiderpoolV1Client +func (c *Clientset) SpiderpoolV1() spiderpoolv1.SpiderpoolV1Interface { + return &fakespiderpoolv1.FakeSpiderpoolV1{Fake: &c.Fake} +} + // SpiderpoolV2beta1 retrieves the SpiderpoolV2beta1Client func (c *Clientset) SpiderpoolV2beta1() spiderpoolv2beta1.SpiderpoolV2beta1Interface { return &fakespiderpoolv2beta1.FakeSpiderpoolV2beta1{Fake: &c.Fake} diff --git a/pkg/k8s/client/clientset/versioned/fake/register.go b/pkg/k8s/client/clientset/versioned/fake/register.go index 8fee34d5bd..c1ce558b7e 100644 --- a/pkg/k8s/client/clientset/versioned/fake/register.go +++ b/pkg/k8s/client/clientset/versioned/fake/register.go @@ -6,6 +6,7 @@ package fake import ( + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -18,6 +19,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + spiderpoolv1.AddToScheme, spiderpoolv2beta1.AddToScheme, } diff --git a/pkg/k8s/client/clientset/versioned/scheme/register.go b/pkg/k8s/client/clientset/versioned/scheme/register.go index 03fa279097..e452680065 100644 --- a/pkg/k8s/client/clientset/versioned/scheme/register.go +++ b/pkg/k8s/client/clientset/versioned/scheme/register.go @@ -6,6 +6,7 @@ package scheme import ( + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -18,6 +19,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + spiderpoolv1.AddToScheme, spiderpoolv2beta1.AddToScheme, } diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/doc.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/doc.go new file mode 100644 index 0000000000..65cbad4553 --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/doc.go @@ -0,0 +1,7 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/doc.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/doc.go new file mode 100644 index 0000000000..c962f5b29f --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/doc.go @@ -0,0 +1,7 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidercoordinator.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidercoordinator.go new file mode 100644 index 0000000000..174483a72d --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidercoordinator.go @@ -0,0 +1,119 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeSpiderCoordinators implements SpiderCoordinatorInterface +type FakeSpiderCoordinators struct { + Fake *FakeSpiderpoolV1 +} + +var spidercoordinatorsResource = v1.SchemeGroupVersion.WithResource("spidercoordinators") + +var spidercoordinatorsKind = v1.SchemeGroupVersion.WithKind("SpiderCoordinator") + +// Get takes name of the spiderCoordinator, and returns the corresponding spiderCoordinator object, and an error if there is any. +func (c *FakeSpiderCoordinators) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderCoordinator, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(spidercoordinatorsResource, name), &v1.SpiderCoordinator{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderCoordinator), err +} + +// List takes label and field selectors, and returns the list of SpiderCoordinators that match those selectors. +func (c *FakeSpiderCoordinators) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderCoordinatorList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(spidercoordinatorsResource, spidercoordinatorsKind, opts), &v1.SpiderCoordinatorList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1.SpiderCoordinatorList{ListMeta: obj.(*v1.SpiderCoordinatorList).ListMeta} + for _, item := range obj.(*v1.SpiderCoordinatorList).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 spiderCoordinators. +func (c *FakeSpiderCoordinators) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(spidercoordinatorsResource, opts)) +} + +// Create takes the representation of a spiderCoordinator and creates it. Returns the server's representation of the spiderCoordinator, and an error, if there is any. +func (c *FakeSpiderCoordinators) Create(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.CreateOptions) (result *v1.SpiderCoordinator, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(spidercoordinatorsResource, spiderCoordinator), &v1.SpiderCoordinator{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderCoordinator), err +} + +// Update takes the representation of a spiderCoordinator and updates it. Returns the server's representation of the spiderCoordinator, and an error, if there is any. +func (c *FakeSpiderCoordinators) Update(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.UpdateOptions) (result *v1.SpiderCoordinator, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(spidercoordinatorsResource, spiderCoordinator), &v1.SpiderCoordinator{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderCoordinator), 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 *FakeSpiderCoordinators) UpdateStatus(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.UpdateOptions) (*v1.SpiderCoordinator, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(spidercoordinatorsResource, "status", spiderCoordinator), &v1.SpiderCoordinator{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderCoordinator), err +} + +// Delete takes name of the spiderCoordinator and deletes it. Returns an error if one occurs. +func (c *FakeSpiderCoordinators) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(spidercoordinatorsResource, name, opts), &v1.SpiderCoordinator{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSpiderCoordinators) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(spidercoordinatorsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1.SpiderCoordinatorList{}) + return err +} + +// Patch applies the patch and returns the patched spiderCoordinator. +func (c *FakeSpiderCoordinators) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderCoordinator, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(spidercoordinatorsResource, name, pt, data, subresources...), &v1.SpiderCoordinator{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderCoordinator), err +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderippool.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderippool.go new file mode 100644 index 0000000000..ddc61a53d2 --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderippool.go @@ -0,0 +1,119 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeSpiderIPPools implements SpiderIPPoolInterface +type FakeSpiderIPPools struct { + Fake *FakeSpiderpoolV1 +} + +var spiderippoolsResource = v1.SchemeGroupVersion.WithResource("spiderippools") + +var spiderippoolsKind = v1.SchemeGroupVersion.WithKind("SpiderIPPool") + +// Get takes name of the spiderIPPool, and returns the corresponding spiderIPPool object, and an error if there is any. +func (c *FakeSpiderIPPools) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderIPPool, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(spiderippoolsResource, name), &v1.SpiderIPPool{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderIPPool), err +} + +// List takes label and field selectors, and returns the list of SpiderIPPools that match those selectors. +func (c *FakeSpiderIPPools) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderIPPoolList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(spiderippoolsResource, spiderippoolsKind, opts), &v1.SpiderIPPoolList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1.SpiderIPPoolList{ListMeta: obj.(*v1.SpiderIPPoolList).ListMeta} + for _, item := range obj.(*v1.SpiderIPPoolList).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 spiderIPPools. +func (c *FakeSpiderIPPools) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(spiderippoolsResource, opts)) +} + +// Create takes the representation of a spiderIPPool and creates it. Returns the server's representation of the spiderIPPool, and an error, if there is any. +func (c *FakeSpiderIPPools) Create(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.CreateOptions) (result *v1.SpiderIPPool, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(spiderippoolsResource, spiderIPPool), &v1.SpiderIPPool{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderIPPool), err +} + +// Update takes the representation of a spiderIPPool and updates it. Returns the server's representation of the spiderIPPool, and an error, if there is any. +func (c *FakeSpiderIPPools) Update(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.UpdateOptions) (result *v1.SpiderIPPool, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(spiderippoolsResource, spiderIPPool), &v1.SpiderIPPool{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderIPPool), 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 *FakeSpiderIPPools) UpdateStatus(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.UpdateOptions) (*v1.SpiderIPPool, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(spiderippoolsResource, "status", spiderIPPool), &v1.SpiderIPPool{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderIPPool), err +} + +// Delete takes name of the spiderIPPool and deletes it. Returns an error if one occurs. +func (c *FakeSpiderIPPools) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(spiderippoolsResource, name, opts), &v1.SpiderIPPool{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSpiderIPPools) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(spiderippoolsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1.SpiderIPPoolList{}) + return err +} + +// Patch applies the patch and returns the patched spiderIPPool. +func (c *FakeSpiderIPPools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderIPPool, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(spiderippoolsResource, name, pt, data, subresources...), &v1.SpiderIPPool{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderIPPool), err +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidermultusconfig.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidermultusconfig.go new file mode 100644 index 0000000000..c153a9d17c --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidermultusconfig.go @@ -0,0 +1,116 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeSpiderMultusConfigs implements SpiderMultusConfigInterface +type FakeSpiderMultusConfigs struct { + Fake *FakeSpiderpoolV1 + ns string +} + +var spidermultusconfigsResource = v1.SchemeGroupVersion.WithResource("spidermultusconfigs") + +var spidermultusconfigsKind = v1.SchemeGroupVersion.WithKind("SpiderMultusConfig") + +// Get takes name of the spiderMultusConfig, and returns the corresponding spiderMultusConfig object, and an error if there is any. +func (c *FakeSpiderMultusConfigs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderMultusConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(spidermultusconfigsResource, c.ns, name), &v1.SpiderMultusConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderMultusConfig), err +} + +// List takes label and field selectors, and returns the list of SpiderMultusConfigs that match those selectors. +func (c *FakeSpiderMultusConfigs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderMultusConfigList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(spidermultusconfigsResource, spidermultusconfigsKind, c.ns, opts), &v1.SpiderMultusConfigList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1.SpiderMultusConfigList{ListMeta: obj.(*v1.SpiderMultusConfigList).ListMeta} + for _, item := range obj.(*v1.SpiderMultusConfigList).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 spiderMultusConfigs. +func (c *FakeSpiderMultusConfigs) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(spidermultusconfigsResource, c.ns, opts)) + +} + +// Create takes the representation of a spiderMultusConfig and creates it. Returns the server's representation of the spiderMultusConfig, and an error, if there is any. +func (c *FakeSpiderMultusConfigs) Create(ctx context.Context, spiderMultusConfig *v1.SpiderMultusConfig, opts metav1.CreateOptions) (result *v1.SpiderMultusConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(spidermultusconfigsResource, c.ns, spiderMultusConfig), &v1.SpiderMultusConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderMultusConfig), err +} + +// Update takes the representation of a spiderMultusConfig and updates it. Returns the server's representation of the spiderMultusConfig, and an error, if there is any. +func (c *FakeSpiderMultusConfigs) Update(ctx context.Context, spiderMultusConfig *v1.SpiderMultusConfig, opts metav1.UpdateOptions) (result *v1.SpiderMultusConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(spidermultusconfigsResource, c.ns, spiderMultusConfig), &v1.SpiderMultusConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderMultusConfig), err +} + +// Delete takes name of the spiderMultusConfig and deletes it. Returns an error if one occurs. +func (c *FakeSpiderMultusConfigs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(spidermultusconfigsResource, c.ns, name, opts), &v1.SpiderMultusConfig{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSpiderMultusConfigs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := testing.NewDeleteCollectionAction(spidermultusconfigsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1.SpiderMultusConfigList{}) + return err +} + +// Patch applies the patch and returns the patched spiderMultusConfig. +func (c *FakeSpiderMultusConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderMultusConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(spidermultusconfigsResource, c.ns, name, pt, data, subresources...), &v1.SpiderMultusConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderMultusConfig), err +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderpool.spidernet.io_client.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderpool.spidernet.io_client.go new file mode 100644 index 0000000000..afbf290254 --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spiderpool.spidernet.io_client.go @@ -0,0 +1,39 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeSpiderpoolV1 struct { + *testing.Fake +} + +func (c *FakeSpiderpoolV1) SpiderCoordinators() v1.SpiderCoordinatorInterface { + return &FakeSpiderCoordinators{c} +} + +func (c *FakeSpiderpoolV1) SpiderIPPools() v1.SpiderIPPoolInterface { + return &FakeSpiderIPPools{c} +} + +func (c *FakeSpiderpoolV1) SpiderMultusConfigs(namespace string) v1.SpiderMultusConfigInterface { + return &FakeSpiderMultusConfigs{c, namespace} +} + +func (c *FakeSpiderpoolV1) SpiderSubnets() v1.SpiderSubnetInterface { + return &FakeSpiderSubnets{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSpiderpoolV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidersubnet.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidersubnet.go new file mode 100644 index 0000000000..b252ef32eb --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/fake/fake_spidersubnet.go @@ -0,0 +1,119 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeSpiderSubnets implements SpiderSubnetInterface +type FakeSpiderSubnets struct { + Fake *FakeSpiderpoolV1 +} + +var spidersubnetsResource = v1.SchemeGroupVersion.WithResource("spidersubnets") + +var spidersubnetsKind = v1.SchemeGroupVersion.WithKind("SpiderSubnet") + +// Get takes name of the spiderSubnet, and returns the corresponding spiderSubnet object, and an error if there is any. +func (c *FakeSpiderSubnets) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderSubnet, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(spidersubnetsResource, name), &v1.SpiderSubnet{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderSubnet), err +} + +// List takes label and field selectors, and returns the list of SpiderSubnets that match those selectors. +func (c *FakeSpiderSubnets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderSubnetList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(spidersubnetsResource, spidersubnetsKind, opts), &v1.SpiderSubnetList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1.SpiderSubnetList{ListMeta: obj.(*v1.SpiderSubnetList).ListMeta} + for _, item := range obj.(*v1.SpiderSubnetList).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 spiderSubnets. +func (c *FakeSpiderSubnets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(spidersubnetsResource, opts)) +} + +// Create takes the representation of a spiderSubnet and creates it. Returns the server's representation of the spiderSubnet, and an error, if there is any. +func (c *FakeSpiderSubnets) Create(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.CreateOptions) (result *v1.SpiderSubnet, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(spidersubnetsResource, spiderSubnet), &v1.SpiderSubnet{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderSubnet), err +} + +// Update takes the representation of a spiderSubnet and updates it. Returns the server's representation of the spiderSubnet, and an error, if there is any. +func (c *FakeSpiderSubnets) Update(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.UpdateOptions) (result *v1.SpiderSubnet, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(spidersubnetsResource, spiderSubnet), &v1.SpiderSubnet{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderSubnet), 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 *FakeSpiderSubnets) UpdateStatus(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.UpdateOptions) (*v1.SpiderSubnet, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(spidersubnetsResource, "status", spiderSubnet), &v1.SpiderSubnet{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderSubnet), err +} + +// Delete takes name of the spiderSubnet and deletes it. Returns an error if one occurs. +func (c *FakeSpiderSubnets) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(spidersubnetsResource, name, opts), &v1.SpiderSubnet{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSpiderSubnets) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(spidersubnetsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1.SpiderSubnetList{}) + return err +} + +// Patch applies the patch and returns the patched spiderSubnet. +func (c *FakeSpiderSubnets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderSubnet, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(spidersubnetsResource, name, pt, data, subresources...), &v1.SpiderSubnet{}) + if obj == nil { + return nil, err + } + return obj.(*v1.SpiderSubnet), err +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/generated_expansion.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/generated_expansion.go new file mode 100644 index 0000000000..d746301f81 --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/generated_expansion.go @@ -0,0 +1,14 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +type SpiderCoordinatorExpansion interface{} + +type SpiderIPPoolExpansion interface{} + +type SpiderMultusConfigExpansion interface{} + +type SpiderSubnetExpansion interface{} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidercoordinator.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidercoordinator.go new file mode 100644 index 0000000000..c84da9dd98 --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidercoordinator.go @@ -0,0 +1,171 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + scheme "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/scheme" + metav1 "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" +) + +// SpiderCoordinatorsGetter has a method to return a SpiderCoordinatorInterface. +// A group's client should implement this interface. +type SpiderCoordinatorsGetter interface { + SpiderCoordinators() SpiderCoordinatorInterface +} + +// SpiderCoordinatorInterface has methods to work with SpiderCoordinator resources. +type SpiderCoordinatorInterface interface { + Create(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.CreateOptions) (*v1.SpiderCoordinator, error) + Update(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.UpdateOptions) (*v1.SpiderCoordinator, error) + UpdateStatus(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.UpdateOptions) (*v1.SpiderCoordinator, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.SpiderCoordinator, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.SpiderCoordinatorList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderCoordinator, err error) + SpiderCoordinatorExpansion +} + +// spiderCoordinators implements SpiderCoordinatorInterface +type spiderCoordinators struct { + client rest.Interface +} + +// newSpiderCoordinators returns a SpiderCoordinators +func newSpiderCoordinators(c *SpiderpoolV1Client) *spiderCoordinators { + return &spiderCoordinators{ + client: c.RESTClient(), + } +} + +// Get takes name of the spiderCoordinator, and returns the corresponding spiderCoordinator object, and an error if there is any. +func (c *spiderCoordinators) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderCoordinator, err error) { + result = &v1.SpiderCoordinator{} + err = c.client.Get(). + Resource("spidercoordinators"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SpiderCoordinators that match those selectors. +func (c *spiderCoordinators) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderCoordinatorList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SpiderCoordinatorList{} + err = c.client.Get(). + Resource("spidercoordinators"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested spiderCoordinators. +func (c *spiderCoordinators) Watch(ctx context.Context, opts metav1.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("spidercoordinators"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a spiderCoordinator and creates it. Returns the server's representation of the spiderCoordinator, and an error, if there is any. +func (c *spiderCoordinators) Create(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.CreateOptions) (result *v1.SpiderCoordinator, err error) { + result = &v1.SpiderCoordinator{} + err = c.client.Post(). + Resource("spidercoordinators"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderCoordinator). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a spiderCoordinator and updates it. Returns the server's representation of the spiderCoordinator, and an error, if there is any. +func (c *spiderCoordinators) Update(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.UpdateOptions) (result *v1.SpiderCoordinator, err error) { + result = &v1.SpiderCoordinator{} + err = c.client.Put(). + Resource("spidercoordinators"). + Name(spiderCoordinator.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderCoordinator). + 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 *spiderCoordinators) UpdateStatus(ctx context.Context, spiderCoordinator *v1.SpiderCoordinator, opts metav1.UpdateOptions) (result *v1.SpiderCoordinator, err error) { + result = &v1.SpiderCoordinator{} + err = c.client.Put(). + Resource("spidercoordinators"). + Name(spiderCoordinator.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderCoordinator). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the spiderCoordinator and deletes it. Returns an error if one occurs. +func (c *spiderCoordinators) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("spidercoordinators"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *spiderCoordinators) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("spidercoordinators"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched spiderCoordinator. +func (c *spiderCoordinators) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderCoordinator, err error) { + result = &v1.SpiderCoordinator{} + err = c.client.Patch(pt). + Resource("spidercoordinators"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderippool.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderippool.go new file mode 100644 index 0000000000..a0cabb6689 --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderippool.go @@ -0,0 +1,171 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + scheme "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/scheme" + metav1 "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" +) + +// SpiderIPPoolsGetter has a method to return a SpiderIPPoolInterface. +// A group's client should implement this interface. +type SpiderIPPoolsGetter interface { + SpiderIPPools() SpiderIPPoolInterface +} + +// SpiderIPPoolInterface has methods to work with SpiderIPPool resources. +type SpiderIPPoolInterface interface { + Create(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.CreateOptions) (*v1.SpiderIPPool, error) + Update(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.UpdateOptions) (*v1.SpiderIPPool, error) + UpdateStatus(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.UpdateOptions) (*v1.SpiderIPPool, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.SpiderIPPool, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.SpiderIPPoolList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderIPPool, err error) + SpiderIPPoolExpansion +} + +// spiderIPPools implements SpiderIPPoolInterface +type spiderIPPools struct { + client rest.Interface +} + +// newSpiderIPPools returns a SpiderIPPools +func newSpiderIPPools(c *SpiderpoolV1Client) *spiderIPPools { + return &spiderIPPools{ + client: c.RESTClient(), + } +} + +// Get takes name of the spiderIPPool, and returns the corresponding spiderIPPool object, and an error if there is any. +func (c *spiderIPPools) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderIPPool, err error) { + result = &v1.SpiderIPPool{} + err = c.client.Get(). + Resource("spiderippools"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SpiderIPPools that match those selectors. +func (c *spiderIPPools) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderIPPoolList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SpiderIPPoolList{} + err = c.client.Get(). + Resource("spiderippools"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested spiderIPPools. +func (c *spiderIPPools) Watch(ctx context.Context, opts metav1.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("spiderippools"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a spiderIPPool and creates it. Returns the server's representation of the spiderIPPool, and an error, if there is any. +func (c *spiderIPPools) Create(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.CreateOptions) (result *v1.SpiderIPPool, err error) { + result = &v1.SpiderIPPool{} + err = c.client.Post(). + Resource("spiderippools"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderIPPool). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a spiderIPPool and updates it. Returns the server's representation of the spiderIPPool, and an error, if there is any. +func (c *spiderIPPools) Update(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.UpdateOptions) (result *v1.SpiderIPPool, err error) { + result = &v1.SpiderIPPool{} + err = c.client.Put(). + Resource("spiderippools"). + Name(spiderIPPool.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderIPPool). + 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 *spiderIPPools) UpdateStatus(ctx context.Context, spiderIPPool *v1.SpiderIPPool, opts metav1.UpdateOptions) (result *v1.SpiderIPPool, err error) { + result = &v1.SpiderIPPool{} + err = c.client.Put(). + Resource("spiderippools"). + Name(spiderIPPool.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderIPPool). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the spiderIPPool and deletes it. Returns an error if one occurs. +func (c *spiderIPPools) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("spiderippools"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *spiderIPPools) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("spiderippools"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched spiderIPPool. +func (c *spiderIPPools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderIPPool, err error) { + result = &v1.SpiderIPPool{} + err = c.client.Patch(pt). + Resource("spiderippools"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidermultusconfig.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidermultusconfig.go new file mode 100644 index 0000000000..bb0dbe91dd --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidermultusconfig.go @@ -0,0 +1,165 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + scheme "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/scheme" + metav1 "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" +) + +// SpiderMultusConfigsGetter has a method to return a SpiderMultusConfigInterface. +// A group's client should implement this interface. +type SpiderMultusConfigsGetter interface { + SpiderMultusConfigs(namespace string) SpiderMultusConfigInterface +} + +// SpiderMultusConfigInterface has methods to work with SpiderMultusConfig resources. +type SpiderMultusConfigInterface interface { + Create(ctx context.Context, spiderMultusConfig *v1.SpiderMultusConfig, opts metav1.CreateOptions) (*v1.SpiderMultusConfig, error) + Update(ctx context.Context, spiderMultusConfig *v1.SpiderMultusConfig, opts metav1.UpdateOptions) (*v1.SpiderMultusConfig, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.SpiderMultusConfig, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.SpiderMultusConfigList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderMultusConfig, err error) + SpiderMultusConfigExpansion +} + +// spiderMultusConfigs implements SpiderMultusConfigInterface +type spiderMultusConfigs struct { + client rest.Interface + ns string +} + +// newSpiderMultusConfigs returns a SpiderMultusConfigs +func newSpiderMultusConfigs(c *SpiderpoolV1Client, namespace string) *spiderMultusConfigs { + return &spiderMultusConfigs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the spiderMultusConfig, and returns the corresponding spiderMultusConfig object, and an error if there is any. +func (c *spiderMultusConfigs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderMultusConfig, err error) { + result = &v1.SpiderMultusConfig{} + err = c.client.Get(). + Namespace(c.ns). + Resource("spidermultusconfigs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SpiderMultusConfigs that match those selectors. +func (c *spiderMultusConfigs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderMultusConfigList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SpiderMultusConfigList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("spidermultusconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested spiderMultusConfigs. +func (c *spiderMultusConfigs) Watch(ctx context.Context, opts metav1.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(). + Namespace(c.ns). + Resource("spidermultusconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a spiderMultusConfig and creates it. Returns the server's representation of the spiderMultusConfig, and an error, if there is any. +func (c *spiderMultusConfigs) Create(ctx context.Context, spiderMultusConfig *v1.SpiderMultusConfig, opts metav1.CreateOptions) (result *v1.SpiderMultusConfig, err error) { + result = &v1.SpiderMultusConfig{} + err = c.client.Post(). + Namespace(c.ns). + Resource("spidermultusconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderMultusConfig). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a spiderMultusConfig and updates it. Returns the server's representation of the spiderMultusConfig, and an error, if there is any. +func (c *spiderMultusConfigs) Update(ctx context.Context, spiderMultusConfig *v1.SpiderMultusConfig, opts metav1.UpdateOptions) (result *v1.SpiderMultusConfig, err error) { + result = &v1.SpiderMultusConfig{} + err = c.client.Put(). + Namespace(c.ns). + Resource("spidermultusconfigs"). + Name(spiderMultusConfig.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderMultusConfig). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the spiderMultusConfig and deletes it. Returns an error if one occurs. +func (c *spiderMultusConfigs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("spidermultusconfigs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *spiderMultusConfigs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("spidermultusconfigs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched spiderMultusConfig. +func (c *spiderMultusConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderMultusConfig, err error) { + result = &v1.SpiderMultusConfig{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("spidermultusconfigs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderpool.spidernet.io_client.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderpool.spidernet.io_client.go new file mode 100644 index 0000000000..b580534b78 --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spiderpool.spidernet.io_client.go @@ -0,0 +1,109 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "net/http" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type SpiderpoolV1Interface interface { + RESTClient() rest.Interface + SpiderCoordinatorsGetter + SpiderIPPoolsGetter + SpiderMultusConfigsGetter + SpiderSubnetsGetter +} + +// SpiderpoolV1Client is used to interact with features provided by the spiderpool.spidernet.io group. +type SpiderpoolV1Client struct { + restClient rest.Interface +} + +func (c *SpiderpoolV1Client) SpiderCoordinators() SpiderCoordinatorInterface { + return newSpiderCoordinators(c) +} + +func (c *SpiderpoolV1Client) SpiderIPPools() SpiderIPPoolInterface { + return newSpiderIPPools(c) +} + +func (c *SpiderpoolV1Client) SpiderMultusConfigs(namespace string) SpiderMultusConfigInterface { + return newSpiderMultusConfigs(c, namespace) +} + +func (c *SpiderpoolV1Client) SpiderSubnets() SpiderSubnetInterface { + return newSpiderSubnets(c) +} + +// NewForConfig creates a new SpiderpoolV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*SpiderpoolV1Client, 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 SpiderpoolV1Client 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) (*SpiderpoolV1Client, 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 &SpiderpoolV1Client{client}, nil +} + +// NewForConfigOrDie creates a new SpiderpoolV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SpiderpoolV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SpiderpoolV1Client for the given RESTClient. +func New(c rest.Interface) *SpiderpoolV1Client { + return &SpiderpoolV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.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 *SpiderpoolV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidersubnet.go b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidersubnet.go new file mode 100644 index 0000000000..f9a1ea8f5e --- /dev/null +++ b/pkg/k8s/client/clientset/versioned/typed/spiderpool.spidernet.io/v1/spidersubnet.go @@ -0,0 +1,171 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + scheme "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/scheme" + metav1 "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" +) + +// SpiderSubnetsGetter has a method to return a SpiderSubnetInterface. +// A group's client should implement this interface. +type SpiderSubnetsGetter interface { + SpiderSubnets() SpiderSubnetInterface +} + +// SpiderSubnetInterface has methods to work with SpiderSubnet resources. +type SpiderSubnetInterface interface { + Create(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.CreateOptions) (*v1.SpiderSubnet, error) + Update(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.UpdateOptions) (*v1.SpiderSubnet, error) + UpdateStatus(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.UpdateOptions) (*v1.SpiderSubnet, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.SpiderSubnet, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.SpiderSubnetList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderSubnet, err error) + SpiderSubnetExpansion +} + +// spiderSubnets implements SpiderSubnetInterface +type spiderSubnets struct { + client rest.Interface +} + +// newSpiderSubnets returns a SpiderSubnets +func newSpiderSubnets(c *SpiderpoolV1Client) *spiderSubnets { + return &spiderSubnets{ + client: c.RESTClient(), + } +} + +// Get takes name of the spiderSubnet, and returns the corresponding spiderSubnet object, and an error if there is any. +func (c *spiderSubnets) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SpiderSubnet, err error) { + result = &v1.SpiderSubnet{} + err = c.client.Get(). + Resource("spidersubnets"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SpiderSubnets that match those selectors. +func (c *spiderSubnets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SpiderSubnetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SpiderSubnetList{} + err = c.client.Get(). + Resource("spidersubnets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested spiderSubnets. +func (c *spiderSubnets) Watch(ctx context.Context, opts metav1.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("spidersubnets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a spiderSubnet and creates it. Returns the server's representation of the spiderSubnet, and an error, if there is any. +func (c *spiderSubnets) Create(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.CreateOptions) (result *v1.SpiderSubnet, err error) { + result = &v1.SpiderSubnet{} + err = c.client.Post(). + Resource("spidersubnets"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderSubnet). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a spiderSubnet and updates it. Returns the server's representation of the spiderSubnet, and an error, if there is any. +func (c *spiderSubnets) Update(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.UpdateOptions) (result *v1.SpiderSubnet, err error) { + result = &v1.SpiderSubnet{} + err = c.client.Put(). + Resource("spidersubnets"). + Name(spiderSubnet.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderSubnet). + 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 *spiderSubnets) UpdateStatus(ctx context.Context, spiderSubnet *v1.SpiderSubnet, opts metav1.UpdateOptions) (result *v1.SpiderSubnet, err error) { + result = &v1.SpiderSubnet{} + err = c.client.Put(). + Resource("spidersubnets"). + Name(spiderSubnet.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(spiderSubnet). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the spiderSubnet and deletes it. Returns an error if one occurs. +func (c *spiderSubnets) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("spidersubnets"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *spiderSubnets) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("spidersubnets"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched spiderSubnet. +func (c *spiderSubnets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SpiderSubnet, err error) { + result = &v1.SpiderSubnet{} + err = c.client.Patch(pt). + Resource("spidersubnets"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/k8s/client/informers/externalversions/generic.go b/pkg/k8s/client/informers/externalversions/generic.go index 015301fcb1..86875f5e63 100644 --- a/pkg/k8s/client/informers/externalversions/generic.go +++ b/pkg/k8s/client/informers/externalversions/generic.go @@ -8,6 +8,7 @@ package externalversions import ( "fmt" + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" v2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" @@ -39,7 +40,17 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=spiderpool.spidernet.io, Version=v2beta1 + // Group=spiderpool.spidernet.io, Version=v1 + case v1.SchemeGroupVersion.WithResource("spidercoordinators"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Spiderpool().V1().SpiderCoordinators().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("spiderippools"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Spiderpool().V1().SpiderIPPools().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("spidermultusconfigs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Spiderpool().V1().SpiderMultusConfigs().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("spidersubnets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Spiderpool().V1().SpiderSubnets().Informer()}, nil + + // Group=spiderpool.spidernet.io, Version=v2beta1 case v2beta1.SchemeGroupVersion.WithResource("spiderclaimparameters"): return &genericInformer{resource: resource.GroupResource(), informer: f.Spiderpool().V2beta1().SpiderClaimParameters().Informer()}, nil case v2beta1.SchemeGroupVersion.WithResource("spidercoordinators"): diff --git a/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/interface.go b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/interface.go index 0279dd4130..83a568c9d8 100644 --- a/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/interface.go +++ b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/interface.go @@ -7,11 +7,14 @@ package spiderpool import ( internalinterfaces "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/internalinterfaces" + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1" v2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v2beta1" ) // Interface provides access to each of this group's versions. type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface // V2beta1 provides access to shared informers for resources in V2beta1. V2beta1() v2beta1.Interface } @@ -27,6 +30,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} + // V2beta1 returns a new v2beta1.Interface. func (g *group) V2beta1() v2beta1.Interface { return v2beta1.New(g.factory, g.namespace, g.tweakListOptions) diff --git a/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/interface.go b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/interface.go new file mode 100644 index 0000000000..bb5b7205c2 --- /dev/null +++ b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/interface.go @@ -0,0 +1,53 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // SpiderCoordinators returns a SpiderCoordinatorInformer. + SpiderCoordinators() SpiderCoordinatorInformer + // SpiderIPPools returns a SpiderIPPoolInformer. + SpiderIPPools() SpiderIPPoolInformer + // SpiderMultusConfigs returns a SpiderMultusConfigInformer. + SpiderMultusConfigs() SpiderMultusConfigInformer + // SpiderSubnets returns a SpiderSubnetInformer. + SpiderSubnets() SpiderSubnetInformer +} + +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} +} + +// SpiderCoordinators returns a SpiderCoordinatorInformer. +func (v *version) SpiderCoordinators() SpiderCoordinatorInformer { + return &spiderCoordinatorInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// SpiderIPPools returns a SpiderIPPoolInformer. +func (v *version) SpiderIPPools() SpiderIPPoolInformer { + return &spiderIPPoolInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// SpiderMultusConfigs returns a SpiderMultusConfigInformer. +func (v *version) SpiderMultusConfigs() SpiderMultusConfigInformer { + return &spiderMultusConfigInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// SpiderSubnets returns a SpiderSubnetInformer. +func (v *version) SpiderSubnets() SpiderSubnetInformer { + return &spiderSubnetInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidercoordinator.go b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidercoordinator.go new file mode 100644 index 0000000000..d479c88229 --- /dev/null +++ b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidercoordinator.go @@ -0,0 +1,76 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + time "time" + + spiderpoolspidernetiov1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + versioned "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" + internalinterfaces "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/internalinterfaces" + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v1" + metav1 "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" +) + +// SpiderCoordinatorInformer provides access to a shared informer and lister for +// SpiderCoordinators. +type SpiderCoordinatorInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.SpiderCoordinatorLister +} + +type spiderCoordinatorInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewSpiderCoordinatorInformer constructs a new informer for SpiderCoordinator 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 NewSpiderCoordinatorInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSpiderCoordinatorInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredSpiderCoordinatorInformer constructs a new informer for SpiderCoordinator 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 NewFilteredSpiderCoordinatorInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderCoordinators().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderCoordinators().Watch(context.TODO(), options) + }, + }, + &spiderpoolspidernetiov1.SpiderCoordinator{}, + resyncPeriod, + indexers, + ) +} + +func (f *spiderCoordinatorInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSpiderCoordinatorInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *spiderCoordinatorInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&spiderpoolspidernetiov1.SpiderCoordinator{}, f.defaultInformer) +} + +func (f *spiderCoordinatorInformer) Lister() v1.SpiderCoordinatorLister { + return v1.NewSpiderCoordinatorLister(f.Informer().GetIndexer()) +} diff --git a/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spiderippool.go b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spiderippool.go new file mode 100644 index 0000000000..fd6aa76290 --- /dev/null +++ b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spiderippool.go @@ -0,0 +1,76 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + time "time" + + spiderpoolspidernetiov1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + versioned "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" + internalinterfaces "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/internalinterfaces" + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v1" + metav1 "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" +) + +// SpiderIPPoolInformer provides access to a shared informer and lister for +// SpiderIPPools. +type SpiderIPPoolInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.SpiderIPPoolLister +} + +type spiderIPPoolInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewSpiderIPPoolInformer constructs a new informer for SpiderIPPool 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 NewSpiderIPPoolInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSpiderIPPoolInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredSpiderIPPoolInformer constructs a new informer for SpiderIPPool 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 NewFilteredSpiderIPPoolInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderIPPools().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderIPPools().Watch(context.TODO(), options) + }, + }, + &spiderpoolspidernetiov1.SpiderIPPool{}, + resyncPeriod, + indexers, + ) +} + +func (f *spiderIPPoolInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSpiderIPPoolInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *spiderIPPoolInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&spiderpoolspidernetiov1.SpiderIPPool{}, f.defaultInformer) +} + +func (f *spiderIPPoolInformer) Lister() v1.SpiderIPPoolLister { + return v1.NewSpiderIPPoolLister(f.Informer().GetIndexer()) +} diff --git a/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidermultusconfig.go b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidermultusconfig.go new file mode 100644 index 0000000000..bababf9983 --- /dev/null +++ b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidermultusconfig.go @@ -0,0 +1,77 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + time "time" + + spiderpoolspidernetiov1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + versioned "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" + internalinterfaces "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/internalinterfaces" + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v1" + metav1 "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" +) + +// SpiderMultusConfigInformer provides access to a shared informer and lister for +// SpiderMultusConfigs. +type SpiderMultusConfigInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.SpiderMultusConfigLister +} + +type spiderMultusConfigInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSpiderMultusConfigInformer constructs a new informer for SpiderMultusConfig 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 NewSpiderMultusConfigInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSpiderMultusConfigInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredSpiderMultusConfigInformer constructs a new informer for SpiderMultusConfig 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 NewFilteredSpiderMultusConfigInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderMultusConfigs(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderMultusConfigs(namespace).Watch(context.TODO(), options) + }, + }, + &spiderpoolspidernetiov1.SpiderMultusConfig{}, + resyncPeriod, + indexers, + ) +} + +func (f *spiderMultusConfigInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSpiderMultusConfigInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *spiderMultusConfigInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&spiderpoolspidernetiov1.SpiderMultusConfig{}, f.defaultInformer) +} + +func (f *spiderMultusConfigInformer) Lister() v1.SpiderMultusConfigLister { + return v1.NewSpiderMultusConfigLister(f.Informer().GetIndexer()) +} diff --git a/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidersubnet.go b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidersubnet.go new file mode 100644 index 0000000000..12ad65d4f1 --- /dev/null +++ b/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1/spidersubnet.go @@ -0,0 +1,76 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + time "time" + + spiderpoolspidernetiov1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + versioned "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" + internalinterfaces "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/internalinterfaces" + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v1" + metav1 "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" +) + +// SpiderSubnetInformer provides access to a shared informer and lister for +// SpiderSubnets. +type SpiderSubnetInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.SpiderSubnetLister +} + +type spiderSubnetInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewSpiderSubnetInformer constructs a new informer for SpiderSubnet 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 NewSpiderSubnetInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSpiderSubnetInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredSpiderSubnetInformer constructs a new informer for SpiderSubnet 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 NewFilteredSpiderSubnetInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderSubnets().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SpiderpoolV1().SpiderSubnets().Watch(context.TODO(), options) + }, + }, + &spiderpoolspidernetiov1.SpiderSubnet{}, + resyncPeriod, + indexers, + ) +} + +func (f *spiderSubnetInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSpiderSubnetInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *spiderSubnetInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&spiderpoolspidernetiov1.SpiderSubnet{}, f.defaultInformer) +} + +func (f *spiderSubnetInformer) Lister() v1.SpiderSubnetLister { + return v1.NewSpiderSubnetLister(f.Informer().GetIndexer()) +} diff --git a/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/expansion_generated.go b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/expansion_generated.go new file mode 100644 index 0000000000..37ef44a015 --- /dev/null +++ b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/expansion_generated.go @@ -0,0 +1,26 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +// SpiderCoordinatorListerExpansion allows custom methods to be added to +// SpiderCoordinatorLister. +type SpiderCoordinatorListerExpansion interface{} + +// SpiderIPPoolListerExpansion allows custom methods to be added to +// SpiderIPPoolLister. +type SpiderIPPoolListerExpansion interface{} + +// SpiderMultusConfigListerExpansion allows custom methods to be added to +// SpiderMultusConfigLister. +type SpiderMultusConfigListerExpansion interface{} + +// SpiderMultusConfigNamespaceListerExpansion allows custom methods to be added to +// SpiderMultusConfigNamespaceLister. +type SpiderMultusConfigNamespaceListerExpansion interface{} + +// SpiderSubnetListerExpansion allows custom methods to be added to +// SpiderSubnetLister. +type SpiderSubnetListerExpansion interface{} diff --git a/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidercoordinator.go b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidercoordinator.go new file mode 100644 index 0000000000..059e38a08c --- /dev/null +++ b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidercoordinator.go @@ -0,0 +1,55 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SpiderCoordinatorLister helps list SpiderCoordinators. +// All objects returned here must be treated as read-only. +type SpiderCoordinatorLister interface { + // List lists all SpiderCoordinators in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.SpiderCoordinator, err error) + // Get retrieves the SpiderCoordinator from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.SpiderCoordinator, error) + SpiderCoordinatorListerExpansion +} + +// spiderCoordinatorLister implements the SpiderCoordinatorLister interface. +type spiderCoordinatorLister struct { + indexer cache.Indexer +} + +// NewSpiderCoordinatorLister returns a new SpiderCoordinatorLister. +func NewSpiderCoordinatorLister(indexer cache.Indexer) SpiderCoordinatorLister { + return &spiderCoordinatorLister{indexer: indexer} +} + +// List lists all SpiderCoordinators in the indexer. +func (s *spiderCoordinatorLister) List(selector labels.Selector) (ret []*v1.SpiderCoordinator, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.SpiderCoordinator)) + }) + return ret, err +} + +// Get retrieves the SpiderCoordinator from the index for a given name. +func (s *spiderCoordinatorLister) Get(name string) (*v1.SpiderCoordinator, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("spidercoordinator"), name) + } + return obj.(*v1.SpiderCoordinator), nil +} diff --git a/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spiderippool.go b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spiderippool.go new file mode 100644 index 0000000000..8b6605e850 --- /dev/null +++ b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spiderippool.go @@ -0,0 +1,55 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SpiderIPPoolLister helps list SpiderIPPools. +// All objects returned here must be treated as read-only. +type SpiderIPPoolLister interface { + // List lists all SpiderIPPools in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.SpiderIPPool, err error) + // Get retrieves the SpiderIPPool from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.SpiderIPPool, error) + SpiderIPPoolListerExpansion +} + +// spiderIPPoolLister implements the SpiderIPPoolLister interface. +type spiderIPPoolLister struct { + indexer cache.Indexer +} + +// NewSpiderIPPoolLister returns a new SpiderIPPoolLister. +func NewSpiderIPPoolLister(indexer cache.Indexer) SpiderIPPoolLister { + return &spiderIPPoolLister{indexer: indexer} +} + +// List lists all SpiderIPPools in the indexer. +func (s *spiderIPPoolLister) List(selector labels.Selector) (ret []*v1.SpiderIPPool, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.SpiderIPPool)) + }) + return ret, err +} + +// Get retrieves the SpiderIPPool from the index for a given name. +func (s *spiderIPPoolLister) Get(name string) (*v1.SpiderIPPool, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("spiderippool"), name) + } + return obj.(*v1.SpiderIPPool), nil +} diff --git a/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidermultusconfig.go b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidermultusconfig.go new file mode 100644 index 0000000000..9fb6d2ccb1 --- /dev/null +++ b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidermultusconfig.go @@ -0,0 +1,86 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SpiderMultusConfigLister helps list SpiderMultusConfigs. +// All objects returned here must be treated as read-only. +type SpiderMultusConfigLister interface { + // List lists all SpiderMultusConfigs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.SpiderMultusConfig, err error) + // SpiderMultusConfigs returns an object that can list and get SpiderMultusConfigs. + SpiderMultusConfigs(namespace string) SpiderMultusConfigNamespaceLister + SpiderMultusConfigListerExpansion +} + +// spiderMultusConfigLister implements the SpiderMultusConfigLister interface. +type spiderMultusConfigLister struct { + indexer cache.Indexer +} + +// NewSpiderMultusConfigLister returns a new SpiderMultusConfigLister. +func NewSpiderMultusConfigLister(indexer cache.Indexer) SpiderMultusConfigLister { + return &spiderMultusConfigLister{indexer: indexer} +} + +// List lists all SpiderMultusConfigs in the indexer. +func (s *spiderMultusConfigLister) List(selector labels.Selector) (ret []*v1.SpiderMultusConfig, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.SpiderMultusConfig)) + }) + return ret, err +} + +// SpiderMultusConfigs returns an object that can list and get SpiderMultusConfigs. +func (s *spiderMultusConfigLister) SpiderMultusConfigs(namespace string) SpiderMultusConfigNamespaceLister { + return spiderMultusConfigNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// SpiderMultusConfigNamespaceLister helps list and get SpiderMultusConfigs. +// All objects returned here must be treated as read-only. +type SpiderMultusConfigNamespaceLister interface { + // List lists all SpiderMultusConfigs in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.SpiderMultusConfig, err error) + // Get retrieves the SpiderMultusConfig from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.SpiderMultusConfig, error) + SpiderMultusConfigNamespaceListerExpansion +} + +// spiderMultusConfigNamespaceLister implements the SpiderMultusConfigNamespaceLister +// interface. +type spiderMultusConfigNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all SpiderMultusConfigs in the indexer for a given namespace. +func (s spiderMultusConfigNamespaceLister) List(selector labels.Selector) (ret []*v1.SpiderMultusConfig, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.SpiderMultusConfig)) + }) + return ret, err +} + +// Get retrieves the SpiderMultusConfig from the indexer for a given namespace and name. +func (s spiderMultusConfigNamespaceLister) Get(name string) (*v1.SpiderMultusConfig, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("spidermultusconfig"), name) + } + return obj.(*v1.SpiderMultusConfig), nil +} diff --git a/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidersubnet.go b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidersubnet.go new file mode 100644 index 0000000000..95152aefc4 --- /dev/null +++ b/pkg/k8s/client/listers/spiderpool.spidernet.io/v1/spidersubnet.go @@ -0,0 +1,55 @@ +// Copyright 2022 Authors of spidernet-io +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SpiderSubnetLister helps list SpiderSubnets. +// All objects returned here must be treated as read-only. +type SpiderSubnetLister interface { + // List lists all SpiderSubnets in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.SpiderSubnet, err error) + // Get retrieves the SpiderSubnet from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.SpiderSubnet, error) + SpiderSubnetListerExpansion +} + +// spiderSubnetLister implements the SpiderSubnetLister interface. +type spiderSubnetLister struct { + indexer cache.Indexer +} + +// NewSpiderSubnetLister returns a new SpiderSubnetLister. +func NewSpiderSubnetLister(indexer cache.Indexer) SpiderSubnetLister { + return &spiderSubnetLister{indexer: indexer} +} + +// List lists all SpiderSubnets in the indexer. +func (s *spiderSubnetLister) List(selector labels.Selector) (ret []*v1.SpiderSubnet, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.SpiderSubnet)) + }) + return ret, err +} + +// Get retrieves the SpiderSubnet from the index for a given name. +func (s *spiderSubnetLister) Get(name string) (*v1.SpiderSubnet, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("spidersubnet"), name) + } + return obj.(*v1.SpiderSubnet), nil +} diff --git a/pkg/manager/spidercliamparameter/spidercliamparameter_webhook.go b/pkg/manager/spidercliamparameter/spidercliamparameter_webhook.go deleted file mode 100644 index 01dc4fcefa..0000000000 --- a/pkg/manager/spidercliamparameter/spidercliamparameter_webhook.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2022 Authors of spidernet-io -// SPDX-License-Identifier: Apache-2.0 - -package spidercliamparameter - -import ( - "context" - "fmt" - - "go.uber.org/zap" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - - "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" - "github.com/spidernet-io/spiderpool/pkg/logutils" -) - -var logger *zap.Logger - -type SpiderClaimParameterManager interface { - admission.CustomDefaulter - admission.CustomValidator -} - -type spiderClaimParameterWebhook struct { - Client client.Client - APIReader client.Reader -} - -func New(client client.Client, apiReader client.Reader, mgr ctrl.Manager) error { - if logger == nil { - logger = logutils.Logger.Named("SpiderClaimParameter-Webhook") - } - - scpm := &spiderClaimParameterWebhook{ - Client: client, - APIReader: apiReader, - } - - return ctrl.NewWebhookManagedBy(mgr). - For(&spiderpoolv2beta1.SpiderClaimParameter{}). - WithDefaulter(scpm). - WithValidator(scpm). - Complete() -} - -var _ webhook.CustomValidator = &spiderClaimParameterWebhook{} - -// Default implements admission.CustomDefaulter. -func (*spiderClaimParameterWebhook) Default(ctx context.Context, obj runtime.Object) error { - return nil -} - -func (scpm *spiderClaimParameterWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - scp := obj.(*spiderpoolv2beta1.SpiderClaimParameter) - - log := logger.Named("Validating").With( - zap.String("SpiderClaimParameter", fmt.Sprintf("%s/%s", scp.Namespace, scp.Name)), - zap.String("Operation", "CREATE"), - ) - log.Sugar().Debugf("Request SpiderClaimParameter: %+v", *scp) - - err := scpm.validate(scp) - if err != nil { - log.Error(err.Error()) - return nil, apierrors.NewInvalid( - spiderpoolv2beta1.SchemeGroupVersion.WithKind(constant.KindSpiderClaimParameter).GroupKind(), - scp.Name, - field.ErrorList{err}, - ) - } - - return nil, nil -} - -func (scpm *spiderClaimParameterWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - new := newObj.(*spiderpoolv2beta1.SpiderClaimParameter) - - log := logger.Named("Validating").With( - zap.String("SpiderClaimParameter", fmt.Sprintf("%s/%s", new.Namespace, new.Name)), - zap.String("Operation", "UPDATE"), - ) - log.Sugar().Debugf("Request new SpiderClaimParameter: %+v", *new) - - err := scpm.validate(new) - if err != nil { - log.Error(err.Error()) - return nil, apierrors.NewInvalid( - spiderpoolv2beta1.SchemeGroupVersion.WithKind(constant.KindSpiderClaimParameter).GroupKind(), - new.Name, - field.ErrorList{err}, - ) - } - - return nil, nil -} - -// ValidateDelete will implement something just like kubernetes Foreground cascade deletion to delete the MultusConfig corresponding net-attach-def firstly -// Since the MultusConf doesn't have Finalizer, you could delete it as soon as possible and we can't filter it to delete the net-attach-def at first. -func (scpm *spiderClaimParameterWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - return nil, nil -} - -// check the existence of SpiderMultusConfig in the StaticNics -func (scpm *spiderClaimParameterWebhook) validate(scp *spiderpoolv2beta1.SpiderClaimParameter) *field.Error { - if scp == nil { - return field.Required(nil, "SpiderClaimParameter is nil") - } - - validateFunc := func(subPath string, nic *spiderpoolv2beta1.MultusConfig) *field.Error { - if nic.MultusName == "" { - return field.Invalid(field.NewPath("Spec").Child(fmt.Sprintf("%s.MultusName", subPath)), nic, "value should not be empty") - } - - var smc spiderpoolv2beta1.SpiderMultusConfig - if err := scpm.APIReader.Get(context.TODO(), client.ObjectKey{Name: nic.MultusName, Namespace: nic.Namespace}, &smc); err != nil { - return field.Invalid(field.NewPath("Spec").Child(subPath), nic, fmt.Sprintf("error get spidermultusconfig %v: %v", nic, err)) - } - return nil - } - - if scp.Spec.DefaultNic != nil { - if err := validateFunc("DefaultNic", scp.Spec.DefaultNic); err != nil { - return err - } - } - - for idx, nic := range scp.Spec.SecondaryNics { - if err := validateFunc(fmt.Sprintf("SecondaryNics[%d]", idx), &nic); err != nil { - return err - } - } - - return nil -} diff --git a/pkg/multuscniconfig/multusconfig_informer.go b/pkg/multuscniconfig/multusconfig_informer.go index 1abab30b15..688e78c8eb 100644 --- a/pkg/multuscniconfig/multusconfig_informer.go +++ b/pkg/multuscniconfig/multusconfig_informer.go @@ -28,11 +28,11 @@ import ( spiderpoolcmd "github.com/spidernet-io/spiderpool/cmd/spiderpool/cmd" "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/election" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" crdclientset "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions" - informers "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v2beta1" - listers "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v2beta1" + informers "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1" + listers "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" ) @@ -104,7 +104,7 @@ func (mcc *MultusConfigController) SetupInformer(ctx context.Context, client crd informerLogger.Info("create MultusConfig informer") factory := externalversions.NewSharedInformerFactory(client, mcc.ResyncPeriod) - err := mcc.addEventHandlers(factory.Spiderpool().V2beta1().SpiderMultusConfigs()) + err := mcc.addEventHandlers(factory.Spiderpool().V1().SpiderMultusConfigs()) if nil != err { informerLogger.Error(err.Error()) continue @@ -251,7 +251,7 @@ func (mcc *MultusConfigController) processNextWorkItem() bool { return true } -func (mcc *MultusConfigController) syncHandler(ctx context.Context, multusConfig *spiderpoolv2beta1.SpiderMultusConfig) error { +func (mcc *MultusConfigController) syncHandler(ctx context.Context, multusConfig *spiderpoolv1.SpiderMultusConfig) error { if multusConfig.DeletionTimestamp != nil { informerLogger.Sugar().Debugf("MultusConfig %s/%s is terminating, no need to sync", multusConfig.Namespace, multusConfig.Name) return nil @@ -338,7 +338,7 @@ func (mcc *MultusConfigController) syncHandler(ctx context.Context, multusConfig return nil } -func generateNetAttachDef(netAttachName string, multusConf *spiderpoolv2beta1.SpiderMultusConfig) (*netv1.NetworkAttachmentDefinition, error) { +func generateNetAttachDef(netAttachName string, multusConf *spiderpoolv1.SpiderMultusConfig) (*netv1.NetworkAttachmentDefinition, error) { multusConfSpec := multusConf.Spec.DeepCopy() anno := multusConf.Annotations @@ -418,7 +418,7 @@ func generateNetAttachDef(netAttachName string, multusConf *spiderpoolv2beta1.Sp // SRIOV special annotation anno[constant.ResourceNameAnnot] = multusConfSpec.SriovConfig.ResourceName - if multusConfSpec.SriovConfig.EnableRdma { + if multusConfSpec.SriovConfig.RdmaIsolation { rdmaconf := RdmaNetConf{ Type: "rdma", } @@ -495,7 +495,7 @@ func generateNetAttachDef(netAttachName string, multusConf *spiderpoolv2beta1.Sp return netAttachDef, nil } -func generateMacvlanCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.MultusCNIConfigSpec) interface{} { +func generateMacvlanCNIConf(disableIPAM bool, multusConfSpec spiderpoolv1.MultusCNIConfigSpec) interface{} { var masterName string // choose interface basement name @@ -532,7 +532,7 @@ func generateMacvlanCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.M return netConf } -func generateIPvlanCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.MultusCNIConfigSpec) interface{} { +func generateIPvlanCNIConf(disableIPAM bool, multusConfSpec spiderpoolv1.MultusCNIConfigSpec) interface{} { var masterName string // choose interface basement name @@ -567,7 +567,7 @@ func generateIPvlanCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.Mu return netConf } -func generateSriovCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.MultusCNIConfigSpec) interface{} { +func generateSriovCNIConf(disableIPAM bool, multusConfSpec spiderpoolv1.MultusCNIConfigSpec) interface{} { netConf := SRIOVNetConf{ Type: constant.SriovCNI, } @@ -598,7 +598,7 @@ func generateSriovCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.Mul return netConf } -func generateIBSriovCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.MultusCNIConfigSpec) interface{} { +func generateIBSriovCNIConf(disableIPAM bool, multusConfSpec spiderpoolv1.MultusCNIConfigSpec) interface{} { netConf := IBSRIOVNetConf{ Type: constant.IBSriovCNI, } @@ -637,7 +637,7 @@ func generateIBSriovCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.M return netConf } -func generateIpoibCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.MultusCNIConfigSpec) interface{} { +func generateIpoibCNIConf(disableIPAM bool, multusConfSpec spiderpoolv1.MultusCNIConfigSpec) interface{} { netConf := IPoIBNetConf{ Type: constant.IPoIBCNI, Master: multusConfSpec.IpoibConfig.Master, @@ -658,7 +658,7 @@ func generateIpoibCNIConf(disableIPAM bool, multusConfSpec spiderpoolv2beta1.Mul } -func generateOvsCNIConf(disableIPAM bool, multusConfSpec *spiderpoolv2beta1.MultusCNIConfigSpec) interface{} { +func generateOvsCNIConf(disableIPAM bool, multusConfSpec *spiderpoolv1.MultusCNIConfigSpec) interface{} { netConf := OvsNetConf{ Type: constant.OvsCNI, } @@ -688,7 +688,7 @@ func generateOvsCNIConf(disableIPAM bool, multusConfSpec *spiderpoolv2beta1.Mult return netConf } -func generateIfacer(master []string, vlanID int32, bond *spiderpoolv2beta1.BondConfig) interface{} { +func generateIfacer(master []string, vlanID int32, bond *spiderpoolv1.BondConfig) interface{} { netConf := IfacerNetConf{ Type: constant.Ifacer, Interfaces: master, @@ -702,7 +702,7 @@ func generateIfacer(master []string, vlanID int32, bond *spiderpoolv2beta1.BondC return netConf } -func generateCoordinatorCNIConf(coordinatorSpec *spiderpoolv2beta1.CoordinatorSpec) interface{} { +func generateCoordinatorCNIConf(coordinatorSpec *spiderpoolv1.CoordinatorSpec) interface{} { coordinatorNetConf := CoordinatorConfig{ Type: constant.Coordinator, } diff --git a/pkg/multuscniconfig/multusconfig_mutate.go b/pkg/multuscniconfig/multusconfig_mutate.go index 5967060773..61e66fb905 100644 --- a/pkg/multuscniconfig/multusconfig_mutate.go +++ b/pkg/multuscniconfig/multusconfig_mutate.go @@ -7,12 +7,12 @@ import ( coordinator_cmd "github.com/spidernet-io/spiderpool/cmd/coordinator/cmd" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "k8s.io/utils/ptr" ) -func mutateSpiderMultusConfig(ctx context.Context, smc *spiderpoolv2beta1.SpiderMultusConfig) { +func mutateSpiderMultusConfig(ctx context.Context, smc *spiderpoolv1.SpiderMultusConfig) { logger := logutils.FromContext(ctx) logger.Info("Start to mutate SpiderMultusConfig") @@ -64,7 +64,7 @@ func mutateSpiderMultusConfig(ctx context.Context, smc *spiderpoolv2beta1.Spider smc.Labels[constant.AnnoPodResourceInject] = value } -func setMacvlanDefaultConfig(macvlanConfig *spiderpoolv2beta1.SpiderMacvlanCniConfig) { +func setMacvlanDefaultConfig(macvlanConfig *spiderpoolv1.SpiderMacvlanCniConfig) { if macvlanConfig == nil { return } @@ -78,21 +78,21 @@ func setMacvlanDefaultConfig(macvlanConfig *spiderpoolv2beta1.SpiderMacvlanCniCo } if macvlanConfig.SpiderpoolConfigPools == nil { - macvlanConfig.SpiderpoolConfigPools = &spiderpoolv2beta1.SpiderpoolPools{ + macvlanConfig.SpiderpoolConfigPools = &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{}, IPv6IPPool: []string{}, } } } -func setBondDefaultConfig(bond *spiderpoolv2beta1.BondConfig) *spiderpoolv2beta1.BondConfig { +func setBondDefaultConfig(bond *spiderpoolv1.BondConfig) *spiderpoolv1.BondConfig { if bond.Options == nil { bond.Options = ptr.To("") } return bond } -func setIPVlanDefaultConfig(ipvlanConfig *spiderpoolv2beta1.SpiderIPvlanCniConfig) { +func setIPVlanDefaultConfig(ipvlanConfig *spiderpoolv1.SpiderIPvlanCniConfig) { if ipvlanConfig == nil { return } @@ -106,14 +106,14 @@ func setIPVlanDefaultConfig(ipvlanConfig *spiderpoolv2beta1.SpiderIPvlanCniConfi } if ipvlanConfig.SpiderpoolConfigPools == nil { - ipvlanConfig.SpiderpoolConfigPools = &spiderpoolv2beta1.SpiderpoolPools{ + ipvlanConfig.SpiderpoolConfigPools = &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{}, IPv6IPPool: []string{}, } } } -func setSriovDefaultConfig(sriovConfig *spiderpoolv2beta1.SpiderSRIOVCniConfig) { +func setSriovDefaultConfig(sriovConfig *spiderpoolv1.SpiderSRIOVCniConfig) { if sriovConfig == nil { return } @@ -131,14 +131,14 @@ func setSriovDefaultConfig(sriovConfig *spiderpoolv2beta1.SpiderSRIOVCniConfig) } if sriovConfig.SpiderpoolConfigPools == nil { - sriovConfig.SpiderpoolConfigPools = &spiderpoolv2beta1.SpiderpoolPools{ + sriovConfig.SpiderpoolConfigPools = &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{}, IPv6IPPool: []string{}, } } } -func setIBSriovDefaultConfig(ibsriovConfig *spiderpoolv2beta1.SpiderIBSriovCniConfig) { +func setIBSriovDefaultConfig(ibsriovConfig *spiderpoolv1.SpiderIBSriovCniConfig) { if ibsriovConfig == nil { return } @@ -160,26 +160,26 @@ func setIBSriovDefaultConfig(ibsriovConfig *spiderpoolv2beta1.SpiderIBSriovCniCo } if ibsriovConfig.SpiderpoolConfigPools == nil { - ibsriovConfig.SpiderpoolConfigPools = &spiderpoolv2beta1.SpiderpoolPools{ + ibsriovConfig.SpiderpoolConfigPools = &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{}, IPv6IPPool: []string{}, } } } -func setIpoibDefaultConfig(config *spiderpoolv2beta1.SpiderIpoibCniConfig) { +func setIpoibDefaultConfig(config *spiderpoolv1.SpiderIpoibCniConfig) { if config == nil { return } if config.SpiderpoolConfigPools == nil { - config.SpiderpoolConfigPools = &spiderpoolv2beta1.SpiderpoolPools{ + config.SpiderpoolConfigPools = &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{}, IPv6IPPool: []string{}, } } } -func setOvsDefaultConfig(ovsConfig *spiderpoolv2beta1.SpiderOvsCniConfig) { +func setOvsDefaultConfig(ovsConfig *spiderpoolv1.SpiderOvsCniConfig) { if ovsConfig == nil { return } @@ -189,16 +189,16 @@ func setOvsDefaultConfig(ovsConfig *spiderpoolv2beta1.SpiderOvsCniConfig) { } if ovsConfig.SpiderpoolConfigPools == nil { - ovsConfig.SpiderpoolConfigPools = &spiderpoolv2beta1.SpiderpoolPools{ + ovsConfig.SpiderpoolConfigPools = &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{}, IPv6IPPool: []string{}, } } } -func setCoordinatorDefaultConfig(coordinator *spiderpoolv2beta1.CoordinatorSpec) *spiderpoolv2beta1.CoordinatorSpec { +func setCoordinatorDefaultConfig(coordinator *spiderpoolv1.CoordinatorSpec) *spiderpoolv1.CoordinatorSpec { if coordinator == nil { - return &spiderpoolv2beta1.CoordinatorSpec{ + return &spiderpoolv1.CoordinatorSpec{ Mode: ptr.To(string(coordinator_cmd.ModeAuto)), HijackCIDR: []string{}, DetectGateway: ptr.To(false), @@ -206,7 +206,6 @@ func setCoordinatorDefaultConfig(coordinator *spiderpoolv2beta1.CoordinatorSpec) VethLinkAddress: ptr.To(""), PodMACPrefix: ptr.To(""), PodDefaultRouteNIC: ptr.To(""), - HostRPFilter: ptr.To(0), PodRPFilter: ptr.To(0), TunePodRoutes: ptr.To(true), } @@ -248,9 +247,5 @@ func setCoordinatorDefaultConfig(coordinator *spiderpoolv2beta1.CoordinatorSpec) coordinator.PodRPFilter = ptr.To(0) } - if coordinator.HostRPFilter == nil { - coordinator.HostRPFilter = ptr.To(0) - } - return coordinator } diff --git a/pkg/multuscniconfig/multusconfig_validate.go b/pkg/multuscniconfig/multusconfig_validate.go index d72a92e401..72d35bfb6f 100644 --- a/pkg/multuscniconfig/multusconfig_validate.go +++ b/pkg/multuscniconfig/multusconfig_validate.go @@ -19,7 +19,7 @@ import ( "github.com/spidernet-io/spiderpool/cmd/spiderpool/cmd" "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/coordinatormanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) var ( @@ -35,7 +35,7 @@ var ( annotationField = field.NewPath("metadata").Child("annotations") ) -func (mcw *MultusConfigWebhook) validate(ctx context.Context, oldMultusConfig, multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *field.Error { +func (mcw *MultusConfigWebhook) validate(ctx context.Context, oldMultusConfig, multusConfig *spiderpoolv1.SpiderMultusConfig) *field.Error { if oldMultusConfig != nil { err := validateCustomAnnoNameShouldNotBeChangeable(oldMultusConfig, multusConfig) if nil != err { @@ -56,7 +56,7 @@ func (mcw *MultusConfigWebhook) validate(ctx context.Context, oldMultusConfig, m return nil } -func checkExistedConfig(spec *spiderpoolv2beta1.MultusCNIConfigSpec, exclude string) bool { +func checkExistedConfig(spec *spiderpoolv1.MultusCNIConfigSpec, exclude string) bool { if exclude != constant.MacvlanCNI && spec.MacvlanConfig != nil { return true } @@ -82,7 +82,7 @@ func checkExistedConfig(spec *spiderpoolv2beta1.MultusCNIConfigSpec, exclude str return false } -func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *field.Error { +func validateCNIConfig(multusConfig *spiderpoolv1.SpiderMultusConfig) *field.Error { // with Kubernetes OpenAPI validation and Mutating Webhook, multusConfSpec.CniType must not be nil and default to "custom" if multusConfig.Spec.CniType == nil { return field.Invalid(cniTypeField, nil, "CniType must not be nil") @@ -110,7 +110,7 @@ func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *fiel } if injectRdmaResource { - if err := ValidateRdmaResouce(multusConfig.Spec.MacvlanConfig.EnableRdma, multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.MacvlanConfig.RdmaResourceName, multusConfig.Spec.MacvlanConfig.SpiderpoolConfigPools); err != nil { + if err := ValidateRdmaResouce(multusConfig.Spec.MacvlanConfig.RdmaResourceName != "", multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.MacvlanConfig.RdmaResourceName, multusConfig.Spec.MacvlanConfig.SpiderpoolConfigPools); err != nil { return field.Invalid(macvlanConfigField, *multusConfig.Spec.MacvlanConfig, err.Error()) } } @@ -135,7 +135,7 @@ func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *fiel } if injectRdmaResource { - if err := ValidateRdmaResouce(multusConfig.Spec.IPVlanConfig.EnableRdma, multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.IPVlanConfig.RdmaResourceName, multusConfig.Spec.IPVlanConfig.SpiderpoolConfigPools); err != nil { + if err := ValidateRdmaResouce(multusConfig.Spec.IPVlanConfig.RdmaResourceName != "", multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.IPVlanConfig.RdmaResourceName, multusConfig.Spec.IPVlanConfig.SpiderpoolConfigPools); err != nil { return field.Invalid(ipvlanConfigField, *multusConfig.Spec.IPVlanConfig, err.Error()) } } @@ -166,7 +166,7 @@ func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *fiel } if injectRdmaResource { - if err := ValidateRdmaResouce(multusConfig.Spec.SriovConfig.EnableRdma, multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.SriovConfig.ResourceName, multusConfig.Spec.SriovConfig.SpiderpoolConfigPools); err != nil { + if err := ValidateRdmaResouce(multusConfig.Spec.SriovConfig.RdmaIsolation, multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.SriovConfig.ResourceName, multusConfig.Spec.SriovConfig.SpiderpoolConfigPools); err != nil { return field.Invalid(sriovConfigField, *multusConfig.Spec.SriovConfig, err.Error()) } } @@ -185,7 +185,7 @@ func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *fiel } if injectRdmaResource { - if err := ValidateRdmaResouce(true, multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.IbSriovConfig.ResourceName, multusConfig.Spec.IbSriovConfig.SpiderpoolConfigPools); err != nil { + if err := ValidateRdmaResouce(*multusConfig.Spec.IbSriovConfig.RdmaIsolation, multusConfig.Name, multusConfig.Namespace, multusConfig.Spec.IbSriovConfig.ResourceName, multusConfig.Spec.IbSriovConfig.SpiderpoolConfigPools); err != nil { return field.Invalid(ibsriovConfigField, *multusConfig.Spec.IbSriovConfig, err.Error()) } } @@ -283,7 +283,7 @@ func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *fiel return nil } -func validateVlanCNIConfig(master []string, bond *spiderpoolv2beta1.BondConfig) error { +func validateVlanCNIConfig(master []string, bond *spiderpoolv1.BondConfig) error { if len(master) == 0 { return fmt.Errorf("master can't be empty") } else if len(master) >= 2 { @@ -305,7 +305,7 @@ func validateVlanId(vlanId int32) error { return nil } -func (mcw *MultusConfigWebhook) validateAnnotation(ctx context.Context, multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *field.Error { +func (mcw *MultusConfigWebhook) validateAnnotation(ctx context.Context, multusConfig *spiderpoolv1.SpiderMultusConfig) *field.Error { // Helper function to check net-attach-def existence and ownership checkNetAttachDef := func(namespace, name string) *field.Error { netAttachDef := &netv1.NetworkAttachmentDefinition{} @@ -353,7 +353,7 @@ func (mcw *MultusConfigWebhook) validateAnnotation(ctx context.Context, multusCo return nil } -func validateCustomAnnoNameShouldNotBeChangeable(oldMultusConfig, newMultusConfig *spiderpoolv2beta1.SpiderMultusConfig) *field.Error { +func validateCustomAnnoNameShouldNotBeChangeable(oldMultusConfig, newMultusConfig *spiderpoolv1.SpiderMultusConfig) *field.Error { oldCustomMultusName, oldOK := oldMultusConfig.Annotations[constant.AnnoNetAttachConfName] newCustomMultusName, newOK := newMultusConfig.Annotations[constant.AnnoNetAttachConfName] diff --git a/pkg/multuscniconfig/multusconfig_webhook.go b/pkg/multuscniconfig/multusconfig_webhook.go index 809f1cef59..11968de670 100644 --- a/pkg/multuscniconfig/multusconfig_webhook.go +++ b/pkg/multuscniconfig/multusconfig_webhook.go @@ -17,7 +17,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" ) @@ -33,7 +33,7 @@ func (mcw *MultusConfigWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error } return ctrl.NewWebhookManagedBy(mgr). - For(&spiderpoolv2beta1.SpiderMultusConfig{}). + For(&spiderpoolv1.SpiderMultusConfig{}). WithDefaulter(mcw). WithValidator(mcw). Complete() @@ -43,7 +43,7 @@ var _ webhook.CustomDefaulter = (*MultusConfigWebhook)(nil) // Default implements admission.CustomDefaulter. func (*MultusConfigWebhook) Default(ctx context.Context, obj runtime.Object) error { - smc := obj.(*spiderpoolv2beta1.SpiderMultusConfig) + smc := obj.(*spiderpoolv1.SpiderMultusConfig) mutateLogger := logger.Named("Mutating").With( zap.String("SpiderMultusConfig", smc.Name)) @@ -57,7 +57,7 @@ func (*MultusConfigWebhook) Default(ctx context.Context, obj runtime.Object) err var _ webhook.CustomValidator = (*MultusConfigWebhook)(nil) func (mcw *MultusConfigWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - multusConfig := obj.(*spiderpoolv2beta1.SpiderMultusConfig) + multusConfig := obj.(*spiderpoolv1.SpiderMultusConfig) log := logger.Named("Validating").With( zap.String("SpiderMultusConfig", fmt.Sprintf("%s/%s", multusConfig.Namespace, multusConfig.Name)), @@ -68,7 +68,7 @@ func (mcw *MultusConfigWebhook) ValidateCreate(ctx context.Context, obj runtime. err := mcw.validate(logutils.IntoContext(ctx, logger), nil, multusConfig) if nil != err { return nil, apierrors.NewInvalid( - spiderpoolv2beta1.SchemeGroupVersion.WithKind(constant.KindSpiderMultusConfig).GroupKind(), + spiderpoolv1.SchemeGroupVersion.WithKind(constant.KindSpiderMultusConfig).GroupKind(), multusConfig.Name, field.ErrorList{err}, ) @@ -78,8 +78,8 @@ func (mcw *MultusConfigWebhook) ValidateCreate(ctx context.Context, obj runtime. } func (mcw *MultusConfigWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - oldMultusConfig := oldObj.(*spiderpoolv2beta1.SpiderMultusConfig) - newMultusConfig := newObj.(*spiderpoolv2beta1.SpiderMultusConfig) + oldMultusConfig := oldObj.(*spiderpoolv1.SpiderMultusConfig) + newMultusConfig := newObj.(*spiderpoolv1.SpiderMultusConfig) log := logger.Named("Validating").With( zap.String("SpiderMultusConfig", fmt.Sprintf("%s/%s", newMultusConfig.Namespace, newMultusConfig.Name)), @@ -91,7 +91,7 @@ func (mcw *MultusConfigWebhook) ValidateUpdate(ctx context.Context, oldObj, newO err := mcw.validate(logutils.IntoContext(ctx, logger), oldMultusConfig, newMultusConfig) if nil != err { return nil, apierrors.NewInvalid( - spiderpoolv2beta1.SchemeGroupVersion.WithKind(constant.KindSpiderMultusConfig).GroupKind(), + spiderpoolv1.SchemeGroupVersion.WithKind(constant.KindSpiderMultusConfig).GroupKind(), newMultusConfig.Name, field.ErrorList{err}, ) diff --git a/pkg/multuscniconfig/utils.go b/pkg/multuscniconfig/utils.go index ee8fb0151d..8ccf6e7db2 100644 --- a/pkg/multuscniconfig/utils.go +++ b/pkg/multuscniconfig/utils.go @@ -31,8 +31,7 @@ import ( coordinatorcmd "github.com/spidernet-io/spiderpool/cmd/coordinator/cmd" spiderpoolcmd "github.com/spidernet-io/spiderpool/cmd/spiderpool/cmd" "github.com/spidernet-io/spiderpool/pkg/constant" - "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) type MacvlanNetConf struct { @@ -79,19 +78,19 @@ type RdmaNetConf struct { } type OvsNetConf struct { - Vlan *int32 `json:"vlan,omitempty"` - Type string `json:"type"` - BrName string `json:"bridge"` - DeviceID string `json:"deviceID,omitempty"` - IPAM *spiderpoolcmd.IPAMConfig `json:"ipam,omitempty"` - Trunk []*spiderpoolv2beta1.Trunk `json:"trunk,omitempty"` + Vlan *int32 `json:"vlan,omitempty"` + Type string `json:"type"` + BrName string `json:"bridge"` + DeviceID string `json:"deviceID,omitempty"` + IPAM *spiderpoolcmd.IPAMConfig `json:"ipam,omitempty"` + Trunk []*spiderpoolv1.Trunk `json:"trunk,omitempty"` } type IfacerNetConf struct { - VlanID int `json:"vlanID,omitempty"` - Type string `json:"type"` - Interfaces []string `json:"interfaces,omitempty"` - Bond *spiderpoolv2beta1.BondConfig `json:"bond,omitempty"` + VlanID int `json:"vlanID,omitempty"` + Type string `json:"type"` + Interfaces []string `json:"interfaces,omitempty"` + Bond *spiderpoolv1.BondConfig `json:"bond,omitempty"` } type CoordinatorConfig struct { @@ -226,15 +225,15 @@ func ParsePodNetworkObjectName(podnetwork string) (string, string, string, error // resourceName returns the appropriate resource name based on the CNI type and configuration // of the given SpiderMultusConfig. -func ResourceName(smc *spiderpoolv2beta1.SpiderMultusConfig) string { +func ResourceName(smc *spiderpoolv1.SpiderMultusConfig) string { switch *smc.Spec.CniType { case constant.MacvlanCNI: // For Macvlan CNI, return RDMA resource name if RDMA is enabled - if smc.Spec.MacvlanConfig != nil && smc.Spec.MacvlanConfig.EnableRdma { + if smc.Spec.MacvlanConfig != nil { return smc.Spec.MacvlanConfig.RdmaResourceName } case constant.IPVlanCNI: - if smc.Spec.IPVlanConfig != nil && smc.Spec.IPVlanConfig.EnableRdma { + if smc.Spec.IPVlanConfig != nil { return smc.Spec.IPVlanConfig.RdmaResourceName } case constant.SriovCNI: @@ -249,7 +248,7 @@ func ResourceName(smc *spiderpoolv2beta1.SpiderMultusConfig) string { return "" } -func ValidateRdmaResouce(enableRdma bool, name, namespace, rdmaResourceName string, ippools *v2beta1.SpiderpoolPools) error { +func ValidateRdmaResouce(enableRdma bool, name, namespace, rdmaResourceName string, ippools *spiderpoolv1.SpiderpoolPools) error { if !enableRdma { return fmt.Errorf("spidermultusconfig %s/%s not enable RDMA", namespace, name) } diff --git a/pkg/podmanager/utils.go b/pkg/podmanager/utils.go index 5788775dc8..5f8ef6143f 100644 --- a/pkg/podmanager/utils.go +++ b/pkg/podmanager/utils.go @@ -19,7 +19,7 @@ import ( kubevirtv1 "kubevirt.io/api/core/v1" "github.com/spidernet-io/spiderpool/pkg/constant" - "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/multuscniconfig" ) @@ -96,7 +96,7 @@ func podNetworkMutatingWebhook(spiderClient crdclientset.Interface, pod *corev1. return fmt.Errorf("failed to create label selector: %v", err) } - multusConfigs, err := spiderClient.SpiderpoolV2beta1().SpiderMultusConfigs("").List(context.TODO(), metav1.ListOptions{ + multusConfigs, err := spiderClient.SpiderpoolV1().SpiderMultusConfigs("").List(context.TODO(), metav1.ListOptions{ LabelSelector: selector.String(), }) if err != nil { @@ -120,7 +120,7 @@ func podNetworkMutatingWebhook(spiderClient crdclientset.Interface, pod *corev1. // // Returns: // - An error if there's an inconsistency in CNI types, nil otherwise -func InjectPodNetwork(pod *corev1.Pod, multusConfigs v2beta1.SpiderMultusConfigList) error { +func InjectPodNetwork(pod *corev1.Pod, multusConfigs spiderpoolv1.SpiderMultusConfigList) error { resourcesMap := make(map[string]bool, len(multusConfigs.Items)) for _, mc := range multusConfigs.Items { if err := DoValidateRdmaResouce(mc); err != nil { @@ -316,16 +316,19 @@ func RemovePodMutatingWebhook(admissionClient admissionClientv1.Admissionregistr return nil } -func DoValidateRdmaResouce(mc v2beta1.SpiderMultusConfig) error { +func DoValidateRdmaResouce(mc spiderpoolv1.SpiderMultusConfig) error { spec := mc.Spec switch *spec.CniType { case constant.MacvlanCNI: - return multuscniconfig.ValidateRdmaResouce(spec.MacvlanConfig.EnableRdma, mc.Name, mc.Namespace, spec.MacvlanConfig.RdmaResourceName, spec.MacvlanConfig.SpiderpoolConfigPools) + return multuscniconfig.ValidateRdmaResouce(spec.MacvlanConfig.RdmaResourceName != "", mc.Name, mc.Namespace, spec.MacvlanConfig.RdmaResourceName, spec.MacvlanConfig.SpiderpoolConfigPools) case constant.IPVlanCNI: - return multuscniconfig.ValidateRdmaResouce(spec.IPVlanConfig.EnableRdma, mc.Name, mc.Namespace, spec.IPVlanConfig.RdmaResourceName, spec.IPVlanConfig.SpiderpoolConfigPools) + return multuscniconfig.ValidateRdmaResouce(spec.IPVlanConfig.RdmaResourceName != "", mc.Name, mc.Namespace, spec.IPVlanConfig.RdmaResourceName, spec.IPVlanConfig.SpiderpoolConfigPools) case constant.SriovCNI: - return multuscniconfig.ValidateRdmaResouce(spec.SriovConfig.EnableRdma, mc.Name, mc.Namespace, spec.SriovConfig.ResourceName, spec.SriovConfig.SpiderpoolConfigPools) + return multuscniconfig.ValidateRdmaResouce(spec.SriovConfig.RdmaIsolation, mc.Name, mc.Namespace, spec.SriovConfig.ResourceName, spec.SriovConfig.SpiderpoolConfigPools) case constant.IBSriovCNI: + if spec.IbSriovConfig.RdmaIsolation == nil || !*spec.IbSriovConfig.RdmaIsolation { + return fmt.Errorf("spidermultusconfig %s/%s not enable RDMA", mc.Namespace, mc.Name) + } return multuscniconfig.ValidateRdmaResouce(true, mc.Name, mc.Namespace, spec.IbSriovConfig.ResourceName, spec.IbSriovConfig.SpiderpoolConfigPools) case constant.IPoIBCNI: return multuscniconfig.ValidateRdmaResouce(true, mc.Name, mc.Namespace, spec.IpoibConfig.Master, spec.IpoibConfig.SpiderpoolConfigPools) diff --git a/pkg/podmanager/utils_test.go b/pkg/podmanager/utils_test.go index 8b30132ee6..383dc316af 100644 --- a/pkg/podmanager/utils_test.go +++ b/pkg/podmanager/utils_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/spidernet-io/spiderpool/pkg/constant" - "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + v2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -119,7 +119,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma-resource1", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test1"}, @@ -135,7 +134,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma-resource2", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test1"}, @@ -164,7 +162,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma-resource1", }, }, @@ -177,7 +174,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma-resource2", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test1"}, @@ -203,8 +199,7 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: false, - RdmaResourceName: "spidernet.io/rdma-resource1", + RdmaResourceName: "", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test1"}, }, @@ -219,7 +214,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma-resource2", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test1"}, @@ -251,7 +245,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma-resource1", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test1"}, @@ -267,7 +260,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To("macvlan"), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma-resource2", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test1"}, @@ -553,7 +545,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "rdma-resource", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, @@ -570,7 +561,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ - EnableRdma: false, RdmaResourceName: "", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, @@ -589,7 +579,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To(constant.IPVlanCNI), IPVlanConfig: &v2beta1.SpiderIPvlanCniConfig{ - EnableRdma: true, RdmaResourceName: "rdma-resource", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, @@ -606,7 +595,6 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To(constant.IPVlanCNI), IPVlanConfig: &v2beta1.SpiderIPvlanCniConfig{ - EnableRdma: false, RdmaResourceName: "", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, @@ -625,8 +613,8 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To(constant.SriovCNI), SriovConfig: &v2beta1.SpiderSRIOVCniConfig{ - EnableRdma: true, - ResourceName: "rdma-resource", + RdmaIsolation: true, + ResourceName: "rdma-resource", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, }, @@ -642,8 +630,8 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To(constant.SriovCNI), SriovConfig: &v2beta1.SpiderSRIOVCniConfig{ - EnableRdma: false, - ResourceName: "", + RdmaIsolation: false, + ResourceName: "", SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, }, @@ -661,7 +649,8 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { Spec: v2beta1.MultusCNIConfigSpec{ CniType: ptr.To(constant.IBSriovCNI), IbSriovConfig: &v2beta1.SpiderIBSriovCniConfig{ - ResourceName: "rdma-resource", + ResourceName: "rdma-resource", + RdmaIsolation: ptr.To(true), SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, }, @@ -678,6 +667,7 @@ var _ = Describe("PodManager utils", Label("pod_manager_utils_test"), func() { CniType: ptr.To(constant.IBSriovCNI), IbSriovConfig: &v2beta1.SpiderIBSriovCniConfig{ ResourceName: "", + SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, }, diff --git a/pkg/reservedipmanager/mock/reservedip_manager_mock.go b/pkg/reservedipmanager/mock/reservedip_manager_mock.go index 8adfc58ab1..e57d8fce9c 100644 --- a/pkg/reservedipmanager/mock/reservedip_manager_mock.go +++ b/pkg/reservedipmanager/mock/reservedip_manager_mock.go @@ -13,7 +13,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + v2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" types "github.com/spidernet-io/spiderpool/pkg/types" client "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/pkg/reservedipmanager/reservedip_manager.go b/pkg/reservedipmanager/reservedip_manager.go index 54c57251f4..6855bb4919 100644 --- a/pkg/reservedipmanager/reservedip_manager.go +++ b/pkg/reservedipmanager/reservedip_manager.go @@ -14,13 +14,13 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" ) type ReservedIPManager interface { - GetReservedIPByName(ctx context.Context, rIPName string, cached bool) (*spiderpoolv2beta1.SpiderReservedIP, error) - ListReservedIPs(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderReservedIPList, error) + GetReservedIPByName(ctx context.Context, rIPName string, cached bool) (*spiderpoolv1.SpiderReservedIP, error) + ListReservedIPs(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderReservedIPList, error) AssembleReservedIPs(ctx context.Context, version types.IPVersion) ([]net.IP, error) } @@ -43,13 +43,13 @@ func NewReservedIPManager(client client.Client, apiReader client.Reader) (Reserv }, nil } -func (rm *reservedIPManager) GetReservedIPByName(ctx context.Context, rIPName string, cached bool) (*spiderpoolv2beta1.SpiderReservedIP, error) { +func (rm *reservedIPManager) GetReservedIPByName(ctx context.Context, rIPName string, cached bool) (*spiderpoolv1.SpiderReservedIP, error) { reader := rm.apiReader if cached == constant.UseCache { reader = rm.client } - var rIP spiderpoolv2beta1.SpiderReservedIP + var rIP spiderpoolv1.SpiderReservedIP if err := reader.Get(ctx, apitypes.NamespacedName{Name: rIPName}, &rIP); err != nil { return nil, err } @@ -57,13 +57,13 @@ func (rm *reservedIPManager) GetReservedIPByName(ctx context.Context, rIPName st return &rIP, nil } -func (rm *reservedIPManager) ListReservedIPs(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderReservedIPList, error) { +func (rm *reservedIPManager) ListReservedIPs(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderReservedIPList, error) { reader := rm.apiReader if cached == constant.UseCache { reader = rm.client } - var rIPList spiderpoolv2beta1.SpiderReservedIPList + var rIPList spiderpoolv1.SpiderReservedIPList if err := reader.List(ctx, &rIPList, opts...); err != nil { return nil, err } diff --git a/pkg/reservedipmanager/reservedip_manager_suite_test.go b/pkg/reservedipmanager/reservedip_manager_suite_test.go index 743a2333ac..43263988b0 100644 --- a/pkg/reservedipmanager/reservedip_manager_suite_test.go +++ b/pkg/reservedipmanager/reservedip_manager_suite_test.go @@ -17,7 +17,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/reservedipmanager" ) @@ -35,17 +35,17 @@ func TestReservedIPManager(t *testing.T) { var _ = BeforeSuite(func() { scheme = runtime.NewScheme() - err := spiderpoolv2beta1.AddToScheme(scheme) + err := spiderpoolv1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) fakeClient = fake.NewClientBuilder(). WithScheme(scheme). - WithIndex(&spiderpoolv2beta1.SpiderReservedIP{}, metav1.ObjectNameField, func(raw client.Object) []string { - rIP := raw.(*spiderpoolv2beta1.SpiderReservedIP) + WithIndex(&spiderpoolv1.SpiderReservedIP{}, metav1.ObjectNameField, func(raw client.Object) []string { + rIP := raw.(*spiderpoolv1.SpiderReservedIP) return []string{rIP.GetObjectMeta().GetName()} }). - WithIndex(&spiderpoolv2beta1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { - rIP := raw.(*spiderpoolv2beta1.SpiderReservedIP) + WithIndex(&spiderpoolv1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { + rIP := raw.(*spiderpoolv1.SpiderReservedIP) return []string{strconv.FormatInt(*rIP.Spec.IPVersion, 10)} }). Build() @@ -54,12 +54,12 @@ var _ = BeforeSuite(func() { fakeAPIReader = fake.NewClientBuilder(). WithScheme(scheme). WithObjectTracker(tracker). - WithIndex(&spiderpoolv2beta1.SpiderReservedIP{}, metav1.ObjectNameField, func(raw client.Object) []string { - rIP := raw.(*spiderpoolv2beta1.SpiderReservedIP) + WithIndex(&spiderpoolv1.SpiderReservedIP{}, metav1.ObjectNameField, func(raw client.Object) []string { + rIP := raw.(*spiderpoolv1.SpiderReservedIP) return []string{rIP.GetObjectMeta().GetName()} }). - WithIndex(&spiderpoolv2beta1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { - rIP := raw.(*spiderpoolv2beta1.SpiderReservedIP) + WithIndex(&spiderpoolv1.SpiderReservedIP{}, constant.SpecIPVersionField, func(raw client.Object) []string { + rIP := raw.(*spiderpoolv1.SpiderReservedIP) return []string{strconv.FormatInt(*rIP.Spec.IPVersion, 10)} }). Build() diff --git a/pkg/reservedipmanager/reservedip_manager_test.go b/pkg/reservedipmanager/reservedip_manager_test.go index 8a79611eba..f137ba142f 100644 --- a/pkg/reservedipmanager/reservedip_manager_test.go +++ b/pkg/reservedipmanager/reservedip_manager_test.go @@ -20,7 +20,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/reservedipmanager" ) @@ -45,7 +45,7 @@ var _ = Describe("ReservedIPManager", Label("reservedip_manager_test"), func() { var count uint64 var rIPName string var labels map[string]string - var rIPT, terminatingV4RIPT *spiderpoolv2beta1.SpiderReservedIP + var rIPT, terminatingV4RIPT *spiderpoolv1.SpiderReservedIP BeforeEach(func() { ctx = context.TODO() @@ -53,7 +53,7 @@ var _ = Describe("ReservedIPManager", Label("reservedip_manager_test"), func() { atomic.AddUint64(&count, 1) rIPName = fmt.Sprintf("reservedip-%v", count) labels = map[string]string{"foo": fmt.Sprintf("bar-%v", count)} - rIPT = &spiderpoolv2beta1.SpiderReservedIP{ + rIPT = &spiderpoolv1.SpiderReservedIP{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderReservedIP, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -62,10 +62,10 @@ var _ = Describe("ReservedIPManager", Label("reservedip_manager_test"), func() { Name: rIPName, Labels: labels, }, - Spec: spiderpoolv2beta1.ReservedIPSpec{}, + Spec: spiderpoolv1.ReservedIPSpec{}, } - terminatingV4RIPT = &spiderpoolv2beta1.SpiderReservedIP{ + terminatingV4RIPT = &spiderpoolv1.SpiderReservedIP{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderReservedIP, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -75,7 +75,7 @@ var _ = Describe("ReservedIPManager", Label("reservedip_manager_test"), func() { DeletionGracePeriodSeconds: ptr.To(int64(30)), Finalizers: []string{constant.SpiderFinalizer}, }, - Spec: spiderpoolv2beta1.ReservedIPSpec{ + Spec: spiderpoolv1.ReservedIPSpec{ IPVersion: ptr.To(constant.IPv4), IPs: []string{ "172.18.40.40", diff --git a/pkg/reservedipmanager/reservedip_mutate.go b/pkg/reservedipmanager/reservedip_mutate.go index a55c8e98f2..2fb56ac3bf 100644 --- a/pkg/reservedipmanager/reservedip_mutate.go +++ b/pkg/reservedipmanager/reservedip_mutate.go @@ -10,12 +10,12 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/types" ) -func (rw *ReservedIPWebhook) mutateReservedIP(ctx context.Context, rIP *spiderpoolv2beta1.SpiderReservedIP) error { +func (rw *ReservedIPWebhook) mutateReservedIP(ctx context.Context, rIP *spiderpoolv1.SpiderReservedIP) error { logger := logutils.FromContext(ctx) logger.Info("Start to mutate ReservedIP") diff --git a/pkg/reservedipmanager/reservedip_validate.go b/pkg/reservedipmanager/reservedip_validate.go index 7335b12f54..6ba4e5e197 100644 --- a/pkg/reservedipmanager/reservedip_validate.go +++ b/pkg/reservedipmanager/reservedip_validate.go @@ -11,7 +11,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" ) @@ -20,7 +20,7 @@ var ( ipsField *field.Path = field.NewPath("spec").Child("ips") ) -func (rw *ReservedIPWebhook) validateCreateReservedIP(ctx context.Context, rIP *spiderpoolv2beta1.SpiderReservedIP) field.ErrorList { +func (rw *ReservedIPWebhook) validateCreateReservedIP(ctx context.Context, rIP *spiderpoolv1.SpiderReservedIP) field.ErrorList { if err := rw.validateReservedIPIPVersion(rIP.Spec.IPVersion); err != nil { return field.ErrorList{err} } @@ -37,7 +37,7 @@ func (rw *ReservedIPWebhook) validateCreateReservedIP(ctx context.Context, rIP * return errs } -func (rw *ReservedIPWebhook) validateUpdateReservedIP(ctx context.Context, oldRIP, newRIP *spiderpoolv2beta1.SpiderReservedIP) field.ErrorList { +func (rw *ReservedIPWebhook) validateUpdateReservedIP(ctx context.Context, oldRIP, newRIP *spiderpoolv1.SpiderReservedIP) field.ErrorList { if err := validateReservedIPShouldNotBeChanged(oldRIP, newRIP); err != nil { return field.ErrorList{err} } @@ -58,7 +58,7 @@ func (rw *ReservedIPWebhook) validateUpdateReservedIP(ctx context.Context, oldRI return errs } -func validateReservedIPShouldNotBeChanged(oldRIP, newRIP *spiderpoolv2beta1.SpiderReservedIP) *field.Error { +func validateReservedIPShouldNotBeChanged(oldRIP, newRIP *spiderpoolv1.SpiderReservedIP) *field.Error { if newRIP.Spec.IPVersion != nil && oldRIP.Spec.IPVersion != nil && *newRIP.Spec.IPVersion != *oldRIP.Spec.IPVersion { return field.Forbidden( @@ -70,7 +70,7 @@ func validateReservedIPShouldNotBeChanged(oldRIP, newRIP *spiderpoolv2beta1.Spid return nil } -func (rw *ReservedIPWebhook) validateReservedIPSpec(ctx context.Context, rIP *spiderpoolv2beta1.SpiderReservedIP) *field.Error { +func (rw *ReservedIPWebhook) validateReservedIPSpec(ctx context.Context, rIP *spiderpoolv1.SpiderReservedIP) *field.Error { return rw.validateReservedIPs(ctx, *rIP.Spec.IPVersion, rIP.Spec.IPs) } diff --git a/pkg/reservedipmanager/reservedip_webhook.go b/pkg/reservedipmanager/reservedip_webhook.go index 6d7ebd6bce..d5549d0fb4 100644 --- a/pkg/reservedipmanager/reservedip_webhook.go +++ b/pkg/reservedipmanager/reservedip_webhook.go @@ -16,7 +16,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" ) @@ -33,7 +33,7 @@ func (rw *ReservedIPWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { } return ctrl.NewWebhookManagedBy(mgr). - For(&spiderpoolv2beta1.SpiderReservedIP{}). + For(&spiderpoolv1.SpiderReservedIP{}). WithDefaulter(rw). WithValidator(rw). Complete() @@ -43,7 +43,7 @@ var _ webhook.CustomDefaulter = (*ReservedIPWebhook)(nil) // Default implements webhook.CustomDefaulter so a webhook will be registered for the type. func (rw *ReservedIPWebhook) Default(ctx context.Context, obj runtime.Object) error { - rIP := obj.(*spiderpoolv2beta1.SpiderReservedIP) + rIP := obj.(*spiderpoolv1.SpiderReservedIP) logger := WebhookLogger.Named("Mutating").With( zap.String("ReservedIPName", rIP.Name), @@ -62,7 +62,7 @@ var _ webhook.CustomValidator = (*ReservedIPWebhook)(nil) // ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type. func (rw *ReservedIPWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - rIP := obj.(*spiderpoolv2beta1.SpiderReservedIP) + rIP := obj.(*spiderpoolv1.SpiderReservedIP) logger := WebhookLogger.Named("Validating").With( zap.String("ReservedIPNamespace", rIP.Namespace), @@ -85,8 +85,8 @@ func (rw *ReservedIPWebhook) ValidateCreate(ctx context.Context, obj runtime.Obj // ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type. func (rw *ReservedIPWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - oldRIP := oldObj.(*spiderpoolv2beta1.SpiderReservedIP) - newRIP := newObj.(*spiderpoolv2beta1.SpiderReservedIP) + oldRIP := oldObj.(*spiderpoolv1.SpiderReservedIP) + newRIP := newObj.(*spiderpoolv1.SpiderReservedIP) logger := WebhookLogger.Named("Validating").With( zap.String("ReservedIPNamespace", newRIP.Namespace), diff --git a/pkg/reservedipmanager/reservedip_webhook_test.go b/pkg/reservedipmanager/reservedip_webhook_test.go index ed862a14ff..9de871bf23 100644 --- a/pkg/reservedipmanager/reservedip_webhook_test.go +++ b/pkg/reservedipmanager/reservedip_webhook_test.go @@ -19,7 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/reservedipmanager" ) @@ -44,7 +44,7 @@ var _ = Describe("ReservedIPWebhook", Label("reservedip_webhook_test"), func() { var count uint64 var rIPName string - var rIPT *spiderpoolv2beta1.SpiderReservedIP + var rIPT *spiderpoolv1.SpiderReservedIP BeforeEach(func() { reservedipmanager.WebhookLogger = logutils.Logger.Named("ReservedIP-Webhook") @@ -55,7 +55,7 @@ var _ = Describe("ReservedIPWebhook", Label("reservedip_webhook_test"), func() { atomic.AddUint64(&count, 1) rIPName = fmt.Sprintf("reservedip-%v", count) - rIPT = &spiderpoolv2beta1.SpiderReservedIP{ + rIPT = &spiderpoolv1.SpiderReservedIP{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderReservedIP, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -63,7 +63,7 @@ var _ = Describe("ReservedIPWebhook", Label("reservedip_webhook_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: rIPName, }, - Spec: spiderpoolv2beta1.ReservedIPSpec{}, + Spec: spiderpoolv1.ReservedIPSpec{}, } }) diff --git a/pkg/subnetmanager/subnet_informer.go b/pkg/subnetmanager/subnet_informer.go index 388d38bc93..16aaed932f 100644 --- a/pkg/subnetmanager/subnet_informer.go +++ b/pkg/subnetmanager/subnet_informer.go @@ -32,11 +32,11 @@ import ( "github.com/spidernet-io/spiderpool/pkg/election" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" "github.com/spidernet-io/spiderpool/pkg/ippoolmanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" clientset "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned" "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions" - informers "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v2beta1" - listers "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v2beta1" + informers "github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions/spiderpool.spidernet.io/v1" + listers "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/metric" spiderpooltypes "github.com/spidernet-io/spiderpool/pkg/types" @@ -83,7 +83,7 @@ type thirdControllerKey struct { func (sc *SubnetController) SetupInformer(ctx context.Context, client clientset.Interface, leader election.SpiderLeaseElector) error { if client == nil { - return fmt.Errorf("spiderpoolv2beta1 clientset %w", constant.ErrMissingRequiredParam) + return fmt.Errorf("spiderpoolv1 clientset %w", constant.ErrMissingRequiredParam) } if leader == nil { return fmt.Errorf("controller leader %w", constant.ErrMissingRequiredParam) @@ -129,8 +129,8 @@ func (sc *SubnetController) SetupInformer(ctx context.Context, client clientset. InformerLogger.Info("Initialize Subnet informer") informerFactory := externalversions.NewSharedInformerFactory(client, sc.ResyncPeriod) err := sc.addEventHandlers( - informerFactory.Spiderpool().V2beta1().SpiderSubnets(), - informerFactory.Spiderpool().V2beta1().SpiderIPPools(), + informerFactory.Spiderpool().V1().SpiderSubnets(), + informerFactory.Spiderpool().V1().SpiderIPPools(), ) if nil != err { InformerLogger.Error(err.Error()) @@ -170,8 +170,8 @@ func (sc *SubnetController) addEventHandlers(subnetInformer informers.SpiderSubn _, err = ipPoolInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: sc.enqueueSubnetOnIPPoolChange, UpdateFunc: func(old, new interface{}) { - oldIPPool := old.(*spiderpoolv2beta1.SpiderIPPool) - newIPPool := new.(*spiderpoolv2beta1.SpiderIPPool) + oldIPPool := old.(*spiderpoolv1.SpiderIPPool) + newIPPool := new.(*spiderpoolv1.SpiderIPPool) if reflect.DeepEqual(newIPPool.Spec.IPs, oldIPPool.Spec.IPs) && reflect.DeepEqual(newIPPool.Spec.ExcludeIPs, oldIPPool.Spec.ExcludeIPs) { return @@ -188,7 +188,7 @@ func (sc *SubnetController) addEventHandlers(subnetInformer informers.SpiderSubn } func (sc *SubnetController) enqueueSubnetOnAdd(obj interface{}) { - subnet := obj.(*spiderpoolv2beta1.SpiderSubnet) + subnet := obj.(*spiderpoolv1.SpiderSubnet) logger := InformerLogger.With( zap.String("SubnetName", subnet.Name), zap.String("Operation", "ADD"), @@ -204,7 +204,7 @@ func (sc *SubnetController) enqueueSubnetOnAdd(obj interface{}) { } func (sc *SubnetController) enqueueSubnetOnUpdate(oldObj, newObj interface{}) { - newSubnet := newObj.(*spiderpoolv2beta1.SpiderSubnet) + newSubnet := newObj.(*spiderpoolv1.SpiderSubnet) logger := InformerLogger.With( zap.String("SubnetName", newSubnet.Name), zap.String("Operation", "UPDATE"), @@ -221,7 +221,7 @@ func (sc *SubnetController) enqueueSubnetOnUpdate(oldObj, newObj interface{}) { // enqueueSubnetOnIPPoolChange receives the IPPool resources events func (sc *SubnetController) enqueueSubnetOnIPPoolChange(obj interface{}) { - ipPool := obj.(*spiderpoolv2beta1.SpiderIPPool) + ipPool := obj.(*spiderpoolv1.SpiderIPPool) ownerSubnet, ok := ipPool.Labels[constant.LabelIPPoolOwnerSpiderSubnet] if !ok { return @@ -319,7 +319,7 @@ func (sc *SubnetController) processDynamicNextWorkItem(ctx context.Context) bool return fmt.Errorf("expected thirdControllerKey in workQueue but got '%+v'", obj) } - err := sc.Client.DeleteAllOf(ctx, &spiderpoolv2beta1.SpiderIPPool{}, client.MatchingLabels{ + err := sc.Client.DeleteAllOf(ctx, &spiderpoolv1.SpiderIPPool{}, client.MatchingLabels{ constant.LabelIPPoolOwnerApplicationUID: string(key.AppUID), constant.LabelIPPoolReclaimIPPool: constant.True, }) @@ -387,7 +387,7 @@ func (sc *SubnetController) syncHandler(ctx context.Context, subnetName string) } // syncMetadata add "ipam.spidernet.io/subnet-cidr" label for the SpiderSubnet object -func (sc *SubnetController) syncMetadata(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) error { +func (sc *SubnetController) syncMetadata(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) error { cidr, err := spiderpoolip.CIDRToLabelValue(*subnet.Spec.IPVersion, subnet.Spec.Subnet) if err != nil { return fmt.Errorf("failed to parse CIDR %s as a valid label value: %v", subnet.Spec.Subnet, err) @@ -410,7 +410,7 @@ func (sc *SubnetController) syncMetadata(ctx context.Context, subnet *spiderpool } // syncControllerSubnet would set ownerReference and add "ipam.spidernet.io/owner-spider-subnet" label for the previous orphan IPPool -func (sc *SubnetController) syncControllerSubnet(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) error { +func (sc *SubnetController) syncControllerSubnet(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) error { ipPools, err := sc.IPPoolsLister.List(labels.Everything()) if err != nil { return err @@ -449,7 +449,7 @@ func (sc *SubnetController) syncControllerSubnet(ctx context.Context, subnet *sp return nil } -func (sc *SubnetController) syncControlledIPPoolIPs(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) error { +func (sc *SubnetController) syncControlledIPPoolIPs(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) error { logger := logutils.FromContext(ctx) preAllocations, err := convert.UnmarshalSubnetAllocatedIPPools(subnet.Status.ControlledIPPools) @@ -459,7 +459,7 @@ func (sc *SubnetController) syncControlledIPPoolIPs(ctx context.Context, subnet // Merge pre-allocated IP addresses of each IPPool and calculate their count. var tmpCount int - newPreAllocations := spiderpoolv2beta1.PoolIPPreAllocations{} + newPreAllocations := spiderpoolv1.PoolIPPreAllocations{} for poolName, preAllocation := range preAllocations { // Only auto-created IPPools have the field 'Application'. if preAllocation.Application != nil { @@ -531,7 +531,7 @@ func (sc *SubnetController) syncControlledIPPoolIPs(ctx context.Context, subnet tmpCount += len(validIPs) ranges, _ := spiderpoolip.ConvertIPsToIPRanges(*ipPool.Spec.IPVersion, validIPs) - newPreAllocations[ipPool.Name] = spiderpoolv2beta1.PoolIPPreAllocation{IPs: ranges} + newPreAllocations[ipPool.Name] = spiderpoolv1.PoolIPPreAllocation{IPs: ranges} } } @@ -561,7 +561,7 @@ func (sc *SubnetController) syncControlledIPPoolIPs(ctx context.Context, subnet return nil } -func (sc *SubnetController) removeFinalizer(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) error { +func (sc *SubnetController) removeFinalizer(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) error { logger := logutils.FromContext(ctx) if !controllerutil.ContainsFinalizer(subnet, metav1.FinalizerDeleteDependents) { diff --git a/pkg/subnetmanager/subnet_informer_test.go b/pkg/subnetmanager/subnet_informer_test.go index 6dfac88a87..ac9bcbe34c 100644 --- a/pkg/subnetmanager/subnet_informer_test.go +++ b/pkg/subnetmanager/subnet_informer_test.go @@ -26,7 +26,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers" "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" spiderpoolfake "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/fake" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/subnetmanager" @@ -39,9 +39,9 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { var count uint64 var subnetName string - var subnetT *spiderpoolv2beta1.SpiderSubnet + var subnetT *spiderpoolv1.SpiderSubnet var ipPoolName string - var ipPoolT *spiderpoolv2beta1.SpiderIPPool + var ipPoolT *spiderpoolv1.SpiderIPPool var subnetController *subnetmanager.SubnetController var fakeSubnetWatch, fakeIPPoolWatch *watch.FakeWatcher @@ -54,7 +54,7 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { atomic.AddUint64(&count, 1) subnetName = fmt.Sprintf("subnet-%v", count) - subnetT = &spiderpoolv2beta1.SpiderSubnet{ + subnetT = &spiderpoolv1.SpiderSubnet{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderSubnet, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -62,11 +62,11 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: subnetName, }, - Spec: spiderpoolv2beta1.SubnetSpec{}, + Spec: spiderpoolv1.SubnetSpec{}, } ipPoolName = fmt.Sprintf("ippool-%v", count) - ipPoolT = &spiderpoolv2beta1.SpiderIPPool{ + ipPoolT = &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -75,7 +75,7 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { Name: ipPoolName, Labels: map[string]string{}, }, - Spec: spiderpoolv2beta1.IPPoolSpec{}, + Spec: spiderpoolv1.IPPoolSpec{}, } subnetController = &subnetmanager.SubnetController{ @@ -148,7 +148,7 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { fakeSubnetWatch.Add(subnetT) Eventually(func(g Gomega) { - var subnetR spiderpoolv2beta1.SpiderSubnet + var subnetR spiderpoolv1.SpiderSubnet err = fakeClient.Get(ctx, types.NamespacedName{Name: subnetT.Name}, &subnetR) g.Expect(err).NotTo(HaveOccurred()) @@ -180,11 +180,11 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { fakeSubnetWatch.Add(subnetT) Eventually(func(g Gomega) { - var subnetR spiderpoolv2beta1.SpiderSubnet + var subnetR spiderpoolv1.SpiderSubnet err = fakeClient.Get(ctx, types.NamespacedName{Name: subnetT.Name}, &subnetR) g.Expect(err).NotTo(HaveOccurred()) - var ipPoolR spiderpoolv2beta1.SpiderIPPool + var ipPoolR spiderpoolv1.SpiderIPPool err = fakeClient.Get(ctx, types.NamespacedName{Name: ipPoolT.Name}, &ipPoolR) g.Expect(err).NotTo(HaveOccurred()) @@ -219,11 +219,11 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { fakeSubnetWatch.Add(subnetT) Eventually(func(g Gomega) { - var subnetR spiderpoolv2beta1.SpiderSubnet + var subnetR spiderpoolv1.SpiderSubnet err = fakeClient.Get(ctx, types.NamespacedName{Name: subnetT.Name}, &subnetR) g.Expect(err).NotTo(HaveOccurred()) - var ipPoolR spiderpoolv2beta1.SpiderIPPool + var ipPoolR spiderpoolv1.SpiderIPPool err = fakeClient.Get(ctx, types.NamespacedName{Name: ipPoolT.Name}, &ipPoolR) g.Expect(err).NotTo(HaveOccurred()) @@ -261,15 +261,15 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { fakeSubnetWatch.Add(subnetT) Eventually(func(g Gomega) { - var subnetR spiderpoolv2beta1.SpiderSubnet + var subnetR spiderpoolv1.SpiderSubnet err = fakeClient.Get(ctx, types.NamespacedName{Name: subnetT.Name}, &subnetR) g.Expect(err).NotTo(HaveOccurred()) preAllocations, err := convert.UnmarshalSubnetAllocatedIPPools(subnetR.Status.ControlledIPPools) g.Expect(err).NotTo(HaveOccurred()) g.Expect(preAllocations).To(Equal( - spiderpoolv2beta1.PoolIPPreAllocations{ - ipPoolT.Name: spiderpoolv2beta1.PoolIPPreAllocation{ + spiderpoolv1.PoolIPPreAllocations{ + ipPoolT.Name: spiderpoolv1.PoolIPPreAllocation{ IPs: []string{"172.18.40.10"}, }, }, @@ -302,7 +302,7 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { fakeSubnetWatch.Modify(subnetT) Eventually(func(g Gomega) { - var subnetR spiderpoolv2beta1.SpiderSubnet + var subnetR spiderpoolv1.SpiderSubnet err = fakeClient.Get(ctx, types.NamespacedName{Name: subnetT.Name}, &subnetR) g.Expect(apierrors.IsNotFound(err)).To(BeTrue()) }).Should(Succeed()) @@ -310,12 +310,12 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { It("third-party controller exist with auto-created IPPool", func() { subnet := subnetT.DeepCopy() - subnet.Spec = spiderpoolv2beta1.SubnetSpec{ + subnet.Spec = spiderpoolv1.SubnetSpec{ IPVersion: ptr.To(int64(4)), Subnet: "172.16.0.0/16", IPs: []string{"172.16.41.1-172.16.41.200"}, } - subnet.Status = spiderpoolv2beta1.SubnetStatus{ + subnet.Status = spiderpoolv1.SubnetStatus{ ControlledIPPools: ptr.To(`{"auto4-cloneset-demo-eth0-db543":{"ips":["172.16.41.1-172.16.41.2"],"application":"apps.kruise.io_v1alpha1_CloneSet_default_cloneset-demo"}}`), TotalIPCount: ptr.To(int64(200)), AllocatedIPCount: ptr.To(int64(2)), @@ -332,7 +332,7 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { fakeSubnetWatch.Add(subnet) Eventually(func(g Gomega) { - var subnetR spiderpoolv2beta1.SpiderSubnet + var subnetR spiderpoolv1.SpiderSubnet err = fakeClient.Get(ctx, types.NamespacedName{Name: subnet.Name}, &subnetR) g.Expect(err).NotTo(HaveOccurred()) }).Should(Succeed()) @@ -340,12 +340,12 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { It("third-party controller exist with auto-created IPPool", func() { subnet := subnetT.DeepCopy() - subnet.Spec = spiderpoolv2beta1.SubnetSpec{ + subnet.Spec = spiderpoolv1.SubnetSpec{ IPVersion: ptr.To(int64(4)), Subnet: "172.16.0.0/16", IPs: []string{"172.16.41.1-172.16.41.200"}, } - subnet.Status = spiderpoolv2beta1.SubnetStatus{ + subnet.Status = spiderpoolv1.SubnetStatus{ ControlledIPPools: ptr.To(`{"auto4-cloneset-demo-eth0-db543":{"ips":["172.16.41.1-172.16.41.2"],"application":"apps.kruise.io_v1alpha1_CloneSet_default_cloneset-demo"}}`), TotalIPCount: ptr.To(int64(200)), AllocatedIPCount: ptr.To(int64(2)), @@ -362,7 +362,7 @@ var _ = Describe("SubnetController", Label("subnet_controller_test"), func() { fakeSubnetWatch.Add(subnet) Eventually(func(g Gomega) { - var subnetR spiderpoolv2beta1.SpiderSubnet + var subnetR spiderpoolv1.SpiderSubnet err = fakeClient.Get(ctx, types.NamespacedName{Name: subnet.Name}, &subnetR) g.Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/subnetmanager/subnet_manager.go b/pkg/subnetmanager/subnet_manager.go index a1e2e32f9b..c3d64c33ba 100644 --- a/pkg/subnetmanager/subnet_manager.go +++ b/pkg/subnetmanager/subnet_manager.go @@ -22,7 +22,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/event" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" "github.com/spidernet-io/spiderpool/pkg/ippoolmanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/reservedipmanager" "github.com/spidernet-io/spiderpool/pkg/types" @@ -30,9 +30,9 @@ import ( ) type SubnetManager interface { - GetSubnetByName(ctx context.Context, subnetName string, cached bool) (*spiderpoolv2beta1.SpiderSubnet, error) - ListSubnets(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderSubnetList, error) - ReconcileAutoIPPool(ctx context.Context, pool *spiderpoolv2beta1.SpiderIPPool, subnetName string, podController types.PodTopController, autoPoolProperty types.AutoPoolProperty) (*spiderpoolv2beta1.SpiderIPPool, error) + GetSubnetByName(ctx context.Context, subnetName string, cached bool) (*spiderpoolv1.SpiderSubnet, error) + ListSubnets(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderSubnetList, error) + ReconcileAutoIPPool(ctx context.Context, pool *spiderpoolv1.SpiderIPPool, subnetName string, podController types.PodTopController, autoPoolProperty types.AutoPoolProperty) (*spiderpoolv1.SpiderIPPool, error) } type subnetManager struct { @@ -59,13 +59,13 @@ func NewSubnetManager(client client.Client, apiReader client.Reader, rIPManager }, nil } -func (sm *subnetManager) GetSubnetByName(ctx context.Context, subnetName string, cached bool) (*spiderpoolv2beta1.SpiderSubnet, error) { +func (sm *subnetManager) GetSubnetByName(ctx context.Context, subnetName string, cached bool) (*spiderpoolv1.SpiderSubnet, error) { reader := sm.apiReader if cached == constant.UseCache { reader = sm.client } - var subnet spiderpoolv2beta1.SpiderSubnet + var subnet spiderpoolv1.SpiderSubnet if err := reader.Get(ctx, apitypes.NamespacedName{Name: subnetName}, &subnet); err != nil { return nil, err } @@ -73,13 +73,13 @@ func (sm *subnetManager) GetSubnetByName(ctx context.Context, subnetName string, return &subnet, nil } -func (sm *subnetManager) ListSubnets(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderSubnetList, error) { +func (sm *subnetManager) ListSubnets(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderSubnetList, error) { reader := sm.apiReader if cached == constant.UseCache { reader = sm.client } - var subnetList spiderpoolv2beta1.SpiderSubnetList + var subnetList spiderpoolv1.SpiderSubnetList if err := reader.List(ctx, &subnetList, opts...); err != nil { return nil, err } @@ -87,8 +87,8 @@ func (sm *subnetManager) ListSubnets(ctx context.Context, cached bool, opts ...c return &subnetList, nil } -func (sm *subnetManager) ReconcileAutoIPPool(ctx context.Context, pool *spiderpoolv2beta1.SpiderIPPool, subnetName string, - podController types.PodTopController, autoPoolProperty types.AutoPoolProperty) (*spiderpoolv2beta1.SpiderIPPool, error) { +func (sm *subnetManager) ReconcileAutoIPPool(ctx context.Context, pool *spiderpoolv1.SpiderIPPool, subnetName string, + podController types.PodTopController, autoPoolProperty types.AutoPoolProperty) (*spiderpoolv1.SpiderIPPool, error) { if len(subnetName) == 0 { return nil, fmt.Errorf("%w: spider subnet name must be specified", constant.ErrWrongInput) } @@ -138,11 +138,11 @@ func (sm *subnetManager) ReconcileAutoIPPool(ctx context.Context, pool *spiderpo labels[constant.LabelIPPoolReclaimIPPool] = applicationinformers.IsReclaimAutoPoolLabelValue(autoPoolProperty.IsReclaimIPPool) pool.SetLabels(labels) } else { - pool = &spiderpoolv2beta1.SpiderIPPool{ + pool = &spiderpoolv1.SpiderIPPool{ ObjectMeta: metav1.ObjectMeta{ Name: applicationinformers.AutoPoolName(podController.Name, autoPoolProperty.IPVersion, autoPoolProperty.IfName, podController.UID), }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(autoPoolProperty.IPVersion), Subnet: subnet.Spec.Subnet, Gateway: subnet.Spec.Gateway, @@ -215,7 +215,7 @@ func (sm *subnetManager) ReconcileAutoIPPool(ctx context.Context, pool *spiderpo } // preAllocateIPsFromSubnet will calculate the auto-created IPPool required IPs from corresponding SpiderSubnet and return it. -func (sm *subnetManager) preAllocateIPsFromSubnet(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet, pool *spiderpoolv2beta1.SpiderIPPool, ipVersion types.IPVersion, desiredIPNum int, podController types.PodTopController) ([]string, error) { +func (sm *subnetManager) preAllocateIPsFromSubnet(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet, pool *spiderpoolv1.SpiderIPPool, ipVersion types.IPVersion, desiredIPNum int, podController types.PodTopController) ([]string, error) { log := logutils.FromContext(ctx) var beforeAllocatedIPs []net.IP @@ -226,7 +226,7 @@ func (sm *subnetManager) preAllocateIPsFromSubnet(ctx context.Context, subnet *s return nil, fmt.Errorf("%w: failed to parse SpiderSubnet %s Status allocations: %v", constant.ErrWrongInput, subnet.Name, err) } if subnetControlledIPPools == nil { - subnetControlledIPPools = make(spiderpoolv2beta1.PoolIPPreAllocations) + subnetControlledIPPools = make(spiderpoolv1.PoolIPPreAllocations) } subnetPoolAllocation, ok := subnetControlledIPPools[pool.Name] @@ -326,7 +326,7 @@ func (sm *subnetManager) preAllocateIPsFromSubnet(ctx context.Context, subnet *s if nil != err { return nil, fmt.Errorf("%w: failed to convert ips to ipranges: %v", constant.ErrWrongInput, err) } - subnetControlledIPPools[pool.Name] = spiderpoolv2beta1.PoolIPPreAllocation{ + subnetControlledIPPools[pool.Name] = spiderpoolv1.PoolIPPreAllocation{ IPs: poolIPRange, Application: ptr.To(applicationinformers.ApplicationNamespacedName(podController.AppNamespacedName)), } @@ -384,7 +384,7 @@ func (sm *subnetManager) preAllocateIPsFromSubnet(ctx context.Context, subnet *s return nil, fmt.Errorf("%w: failed to convert ips to ipranges: %v", constant.ErrWrongInput, err) } - subnetControlledIPPools[pool.Name] = spiderpoolv2beta1.PoolIPPreAllocation{ + subnetControlledIPPools[pool.Name] = spiderpoolv1.PoolIPPreAllocation{ IPs: allocateIPRange, Application: ptr.To(applicationinformers.ApplicationNamespacedName(podController.AppNamespacedName)), } @@ -406,13 +406,13 @@ func (sm *subnetManager) preAllocateIPsFromSubnet(ctx context.Context, subnet *s return allocateIPRange, nil } -func subnetStatusCount(subnet *spiderpoolv2beta1.SpiderSubnet) (totalCount, allocatedCount int64) { +func subnetStatusCount(subnet *spiderpoolv1.SpiderSubnet) (totalCount, allocatedCount int64) { s, _ := spiderpoolip.NewCIDR(subnet.Spec.Subnet, subnet.Spec.IPs, subnet.Spec.ExcludeIPs) if subnet.Status.ControlledIPPools == nil { return 0, 0 } - var controlledIPPools spiderpoolv2beta1.PoolIPPreAllocations + var controlledIPPools spiderpoolv1.PoolIPPreAllocations err := json.Unmarshal([]byte(*subnet.Status.ControlledIPPools), &controlledIPPools) if nil != err { return 0, 0 diff --git a/pkg/subnetmanager/subnet_manager_suite_test.go b/pkg/subnetmanager/subnet_manager_suite_test.go index 050f3da3da..6f433a9e55 100644 --- a/pkg/subnetmanager/subnet_manager_suite_test.go +++ b/pkg/subnetmanager/subnet_manager_suite_test.go @@ -22,7 +22,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" electionmock "github.com/spidernet-io/spiderpool/pkg/election/mock" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/metric" reservedipmanagermock "github.com/spidernet-io/spiderpool/pkg/reservedipmanager/mock" "github.com/spidernet-io/spiderpool/pkg/subnetmanager" @@ -50,18 +50,18 @@ func TestSubnetManager(t *testing.T) { var _ = BeforeSuite(func() { scheme = runtime.NewScheme() - err := spiderpoolv2beta1.AddToScheme(scheme) + err := spiderpoolv1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) err = kruiseapi.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) fakeClient = fake.NewClientBuilder(). WithScheme(scheme). - WithIndex(&spiderpoolv2beta1.SpiderSubnet{}, metav1.ObjectNameField, func(raw client.Object) []string { - subnet := raw.(*spiderpoolv2beta1.SpiderSubnet) + WithIndex(&spiderpoolv1.SpiderSubnet{}, metav1.ObjectNameField, func(raw client.Object) []string { + subnet := raw.(*spiderpoolv1.SpiderSubnet) return []string{subnet.GetObjectMeta().GetName()} }). - WithStatusSubresource(&spiderpoolv2beta1.SpiderSubnet{}). + WithStatusSubresource(&spiderpoolv1.SpiderSubnet{}). Build() _, err = metric.InitMetric(context.TODO(), constant.SpiderpoolController, false, false) @@ -73,11 +73,11 @@ var _ = BeforeSuite(func() { fakeAPIReader = fake.NewClientBuilder(). WithScheme(scheme). WithObjectTracker(tracker). - WithIndex(&spiderpoolv2beta1.SpiderSubnet{}, metav1.ObjectNameField, func(raw client.Object) []string { - subnet := raw.(*spiderpoolv2beta1.SpiderSubnet) + WithIndex(&spiderpoolv1.SpiderSubnet{}, metav1.ObjectNameField, func(raw client.Object) []string { + subnet := raw.(*spiderpoolv1.SpiderSubnet) return []string{subnet.GetObjectMeta().GetName()} }). - WithStatusSubresource(&spiderpoolv2beta1.SpiderSubnet{}). + WithStatusSubresource(&spiderpoolv1.SpiderSubnet{}). Build() fakeDynamicClient = dynamicfake.NewSimpleDynamicClient(scheme) diff --git a/pkg/subnetmanager/subnet_manager_test.go b/pkg/subnetmanager/subnet_manager_test.go index 63f8c0158b..a88aa83b6b 100644 --- a/pkg/subnetmanager/subnet_manager_test.go +++ b/pkg/subnetmanager/subnet_manager_test.go @@ -19,7 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/subnetmanager" "github.com/spidernet-io/spiderpool/pkg/types" ) @@ -51,7 +51,7 @@ var _ = Describe("SubnetManager", Label("subnet_manager_test"), func() { var count uint64 var subnetName string var labels map[string]string - var subnetT *spiderpoolv2beta1.SpiderSubnet + var subnetT *spiderpoolv1.SpiderSubnet BeforeEach(func() { ctx = context.TODO() @@ -59,7 +59,7 @@ var _ = Describe("SubnetManager", Label("subnet_manager_test"), func() { atomic.AddUint64(&count, 1) subnetName = fmt.Sprintf("subnet-%v", count) labels = map[string]string{"foo": fmt.Sprintf("bar-%v", count)} - subnetT = &spiderpoolv2beta1.SpiderSubnet{ + subnetT = &spiderpoolv1.SpiderSubnet{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderSubnet, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -68,7 +68,7 @@ var _ = Describe("SubnetManager", Label("subnet_manager_test"), func() { Name: subnetName, Labels: labels, }, - Spec: spiderpoolv2beta1.SubnetSpec{}, + Spec: spiderpoolv1.SubnetSpec{}, } }) @@ -225,7 +225,7 @@ var _ = Describe("SubnetManager", Label("subnet_manager_test"), func() { It("reconcile an auto IPPool for Deployment", func() { subnet := subnetT.DeepCopy() - subnet.Spec = spiderpoolv2beta1.SubnetSpec{ + subnet.Spec = spiderpoolv1.SubnetSpec{ IPVersion: ptr.To(int64(4)), Subnet: "172.16.0.0/16", IPs: []string{"172.16.41.1-172.16.41.200"}, diff --git a/pkg/subnetmanager/subnet_mutate.go b/pkg/subnetmanager/subnet_mutate.go index eea3a2586c..d52e4f7534 100644 --- a/pkg/subnetmanager/subnet_mutate.go +++ b/pkg/subnetmanager/subnet_mutate.go @@ -11,12 +11,12 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/types" ) -func (sw *SubnetWebhook) mutateSubnet(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) error { +func (sw *SubnetWebhook) mutateSubnet(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) error { logger := logutils.FromContext(ctx) logger.Info("Start to mutate Subnet") diff --git a/pkg/subnetmanager/subnet_validate.go b/pkg/subnetmanager/subnet_validate.go index 3fcebad71b..5b895aa9e1 100644 --- a/pkg/subnetmanager/subnet_validate.go +++ b/pkg/subnetmanager/subnet_validate.go @@ -14,7 +14,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" "github.com/spidernet-io/spiderpool/pkg/ippoolmanager" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/utils/convert" ) @@ -29,7 +29,7 @@ var ( controlledIPPoolsField *field.Path = field.NewPath("status").Child("controlledIPPools") ) -func (sw *SubnetWebhook) validateCreateSubnet(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) field.ErrorList { +func (sw *SubnetWebhook) validateCreateSubnet(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) field.ErrorList { if err := sw.validateSubnetIPVersion(subnet.Spec.IPVersion); err != nil { return field.ErrorList{err} } @@ -50,7 +50,7 @@ func (sw *SubnetWebhook) validateCreateSubnet(ctx context.Context, subnet *spide return errs } -func (sw *SubnetWebhook) validateUpdateSubnet(ctx context.Context, oldSubnet, newSubnet *spiderpoolv2beta1.SpiderSubnet) field.ErrorList { +func (sw *SubnetWebhook) validateUpdateSubnet(ctx context.Context, oldSubnet, newSubnet *spiderpoolv1.SpiderSubnet) field.ErrorList { if err := validateSubnetShouldNotBeChanged(oldSubnet, newSubnet); err != nil { return field.ErrorList{err} } @@ -75,7 +75,7 @@ func (sw *SubnetWebhook) validateUpdateSubnet(ctx context.Context, oldSubnet, ne return errs } -func validateSubnetShouldNotBeChanged(oldSubnet, newSubnet *spiderpoolv2beta1.SpiderSubnet) *field.Error { +func validateSubnetShouldNotBeChanged(oldSubnet, newSubnet *spiderpoolv1.SpiderSubnet) *field.Error { if newSubnet.Spec.IPVersion != nil && oldSubnet.Spec.IPVersion != nil && *newSubnet.Spec.IPVersion != *oldSubnet.Spec.IPVersion { return field.Forbidden( @@ -94,7 +94,7 @@ func validateSubnetShouldNotBeChanged(oldSubnet, newSubnet *spiderpoolv2beta1.Sp return nil } -func (sw *SubnetWebhook) validateSubnetSpec(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) *field.Error { +func (sw *SubnetWebhook) validateSubnetSpec(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) *field.Error { if err := validateSubnetIPs(*subnet.Spec.IPVersion, subnet.Spec.Subnet, subnet.Spec.IPs); err != nil { return err } @@ -108,7 +108,7 @@ func (sw *SubnetWebhook) validateSubnetSpec(ctx context.Context, subnet *spiderp return validateSubnetRoutes(*subnet.Spec.IPVersion, subnet.Spec.Subnet, subnet.Spec.Routes) } -func validateSubnetIPInUse(subnet *spiderpoolv2beta1.SpiderSubnet) *field.Error { +func validateSubnetIPInUse(subnet *spiderpoolv1.SpiderSubnet) *field.Error { totalIPs, err := spiderpoolip.AssembleTotalIPs(*subnet.Spec.IPVersion, subnet.Spec.IPs, subnet.Spec.ExcludeIPs) if err != nil { return field.InternalError(ipsField, fmt.Errorf("failed to assemble the total IP addresses of the Subnet %s: %v", subnet.Name, err)) @@ -177,7 +177,7 @@ func (sw *SubnetWebhook) validateSubnetIPVersion(version *types.IPVersion) *fiel return nil } -func (sw *SubnetWebhook) validateSubnetCIDR(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) *field.Error { +func (sw *SubnetWebhook) validateSubnetCIDR(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) *field.Error { if err := spiderpoolip.IsCIDR(*subnet.Spec.IPVersion, subnet.Spec.Subnet); err != nil { return field.Invalid( subnetField, @@ -189,7 +189,7 @@ func (sw *SubnetWebhook) validateSubnetCIDR(ctx context.Context, subnet *spiderp return field.Invalid(subnetField, subnet.Spec.Subnet, err.Error()) } - subnetList := spiderpoolv2beta1.SpiderSubnetList{} + subnetList := spiderpoolv1.SpiderSubnetList{} if err := sw.APIReader.List(ctx, &subnetList); err != nil { return field.InternalError(subnetField, fmt.Errorf("failed to list Subnets: %v", err)) } @@ -222,8 +222,8 @@ func (sw *SubnetWebhook) validateSubnetCIDR(ctx context.Context, subnet *spiderp // validateOrphanIPPool will check the SpiderSubnet.Spec.Subnet whether overlaps with the cluster orphan SpiderIPPool.Spec.Subnet. // And we also require the IPPool.Spec.IPs belong to Subnet.Spec.IPs if they are in the same subnet -func (sw *SubnetWebhook) validateOrphanIPPool(ctx context.Context, subnet *spiderpoolv2beta1.SpiderSubnet) *field.Error { - poolList := spiderpoolv2beta1.SpiderIPPoolList{} +func (sw *SubnetWebhook) validateOrphanIPPool(ctx context.Context, subnet *spiderpoolv1.SpiderSubnet) *field.Error { + poolList := spiderpoolv1.SpiderIPPoolList{} err := sw.APIReader.List(ctx, &poolList) if nil != err { return field.InternalError(subnetField, fmt.Errorf("failed to list IPPools: %v", err)) @@ -282,7 +282,7 @@ func validateSubnetExcludeIPs(version types.IPVersion, subnet string, excludeIPs return nil } -func validateSubnetGateway(subnet *spiderpoolv2beta1.SpiderSubnet) *field.Error { +func validateSubnetGateway(subnet *spiderpoolv1.SpiderSubnet) *field.Error { if subnet.Spec.Gateway == nil { return nil } @@ -312,7 +312,7 @@ func validateSubnetGateway(subnet *spiderpoolv2beta1.SpiderSubnet) *field.Error return nil } -func validateSubnetRoutes(version types.IPVersion, subnet string, routes []spiderpoolv2beta1.Route) *field.Error { +func validateSubnetRoutes(version types.IPVersion, subnet string, routes []spiderpoolv1.Route) *field.Error { if len(routes) == 0 { return nil } diff --git a/pkg/subnetmanager/subnet_webhook.go b/pkg/subnetmanager/subnet_webhook.go index b7dafcb42e..bce395efdc 100644 --- a/pkg/subnetmanager/subnet_webhook.go +++ b/pkg/subnetmanager/subnet_webhook.go @@ -20,7 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" ) @@ -40,7 +40,7 @@ func (sw *SubnetWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error { } return ctrl.NewWebhookManagedBy(mgr). - For(&spiderpoolv2beta1.SpiderSubnet{}). + For(&spiderpoolv1.SpiderSubnet{}). WithDefaulter(sw). WithValidator(sw). Complete() @@ -50,7 +50,7 @@ var _ webhook.CustomDefaulter = (*SubnetWebhook)(nil) // Default implements webhook.CustomDefaulter so a webhook will be registered for the type. func (sw *SubnetWebhook) Default(ctx context.Context, obj runtime.Object) error { - subnet := obj.(*spiderpoolv2beta1.SpiderSubnet) + subnet := obj.(*spiderpoolv1.SpiderSubnet) logger := WebhookLogger.Named("Mutating").With( zap.String("SubnetName", subnet.Name), @@ -69,7 +69,7 @@ var _ webhook.CustomValidator = (*SubnetWebhook)(nil) // ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type. func (sw *SubnetWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - subnet := obj.(*spiderpoolv2beta1.SpiderSubnet) + subnet := obj.(*spiderpoolv1.SpiderSubnet) logger := WebhookLogger.Named("Validating").With( zap.String("SubnetName", subnet.Name), @@ -84,7 +84,7 @@ func (sw *SubnetWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) // Refer to https://github.com/spidernet-io/spiderpool/issues/3321 switch { case strings.Contains(aggregatedErr.Error(), string(metav1.StatusReasonAlreadyExists)): - return nil, apierrors.NewAlreadyExists(spiderpoolv2beta1.Resource(constant.KindSpiderSubnet), subnet.Name) + return nil, apierrors.NewAlreadyExists(spiderpoolv1.Resource(constant.KindSpiderSubnet), subnet.Name) default: return nil, apierrors.NewInvalid( schema.GroupKind{Group: constant.SpiderpoolAPIGroup, Kind: constant.KindSpiderSubnet}, @@ -99,8 +99,8 @@ func (sw *SubnetWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) // ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type. func (sw *SubnetWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - oldSubnet := oldObj.(*spiderpoolv2beta1.SpiderSubnet) - newSubnet := newObj.(*spiderpoolv2beta1.SpiderSubnet) + oldSubnet := oldObj.(*spiderpoolv1.SpiderSubnet) + newSubnet := newObj.(*spiderpoolv1.SpiderSubnet) logger := WebhookLogger.Named("Validating").With( zap.String("SubnetName", newSubnet.Name), diff --git a/pkg/subnetmanager/subnet_webhook_test.go b/pkg/subnetmanager/subnet_webhook_test.go index abb9ba1976..8b13caee44 100644 --- a/pkg/subnetmanager/subnet_webhook_test.go +++ b/pkg/subnetmanager/subnet_webhook_test.go @@ -23,7 +23,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/subnetmanager" "github.com/spidernet-io/spiderpool/pkg/utils/convert" @@ -49,7 +49,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { var count uint64 var subnetName, existSubnetName string - var subnetT, existSubnetT *spiderpoolv2beta1.SpiderSubnet + var subnetT, existSubnetT *spiderpoolv1.SpiderSubnet BeforeEach(func() { subnetmanager.WebhookLogger = logutils.Logger.Named("Subnet-Webhook") @@ -60,7 +60,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { atomic.AddUint64(&count, 1) subnetName = fmt.Sprintf("subnet-%v", count) - subnetT = &spiderpoolv2beta1.SpiderSubnet{ + subnetT = &spiderpoolv1.SpiderSubnet{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderSubnet, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -68,11 +68,11 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: subnetName, }, - Spec: spiderpoolv2beta1.SubnetSpec{}, + Spec: spiderpoolv1.SubnetSpec{}, } existSubnetName = fmt.Sprintf("z-exist-subnet-%v", count) - existSubnetT = &spiderpoolv2beta1.SpiderSubnet{ + existSubnetT = &spiderpoolv1.SpiderSubnet{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderSubnet, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -80,7 +80,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: existSubnetName, }, - Spec: spiderpoolv2beta1.SubnetSpec{}, + Spec: spiderpoolv1.SubnetSpec{}, } }) @@ -527,7 +527,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }) It("overlaps with existing orphan IPPool resource", func() { - orphanPool := &spiderpoolv2beta1.SpiderIPPool{ + orphanPool := &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -535,7 +535,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: "orphanPool", }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv4), Subnet: "172.18.40.0/25", IPs: []string{"172.18.40.40"}, @@ -596,7 +596,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }) It("orphan IPPool with extra IPs", func() { - orphanPool := &spiderpoolv2beta1.SpiderIPPool{ + orphanPool := &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -604,7 +604,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: "orphanPool", }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv4), Subnet: "172.18.40.0/25", IPs: []string{"172.18.40.40-172.18.40.45"}, @@ -749,7 +749,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "0.0.0.0/0", Gw: "172.18.40.1", }, @@ -770,11 +770,11 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.1", }, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.2", }, @@ -795,7 +795,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: constant.InvalidCIDR, Gw: "172.18.40.1", }, @@ -816,7 +816,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: constant.InvalidIP, }, @@ -837,7 +837,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.41.1", }, @@ -861,7 +861,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { subnetT.Spec.ExcludeIPs = append(subnetT.Spec.ExcludeIPs, "172.18.40.10") subnetT.Spec.Gateway = ptr.To("172.18.40.1") subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.40", }, @@ -884,7 +884,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { subnetT.Spec.ExcludeIPs = append(subnetT.Spec.ExcludeIPs, "abcd:1234::a") subnetT.Spec.Gateway = ptr.To("abcd:1234::1") subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "fd00:40::/120", Gw: "abcd:1234::28", }, @@ -896,7 +896,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }) It("create IPv4 Subnet with orphan IPPool exist", func() { - orphanPool := &spiderpoolv2beta1.SpiderIPPool{ + orphanPool := &spiderpoolv1.SpiderIPPool{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderIPPool, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -904,7 +904,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { ObjectMeta: metav1.ObjectMeta{ Name: "orphanPool", }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv4), Subnet: "172.18.40.0/25", IPs: []string{"172.18.40.40-172.18.40.41"}, @@ -1183,7 +1183,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { newSubnetT := subnetT.DeepCopy() newSubnetT.Spec.Routes = append(newSubnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "0.0.0.0/0", Gw: "172.18.40.1", }, @@ -1204,7 +1204,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) subnetT.Spec.Routes = append(subnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.1", }, @@ -1212,7 +1212,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { newSubnetT := subnetT.DeepCopy() newSubnetT.Spec.Routes = append(newSubnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.2", }, @@ -1235,7 +1235,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { newSubnetT := subnetT.DeepCopy() newSubnetT.Spec.Routes = append(newSubnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: constant.InvalidCIDR, Gw: "172.18.40.1", }, @@ -1258,7 +1258,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { newSubnetT := subnetT.DeepCopy() newSubnetT.Spec.Routes = append(newSubnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: constant.InvalidIP, }, @@ -1281,7 +1281,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { newSubnetT := subnetT.DeepCopy() newSubnetT.Spec.Routes = append(newSubnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.41.1", }, @@ -1307,8 +1307,8 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) - preAllocations := spiderpoolv2beta1.PoolIPPreAllocations{ - "pool": spiderpoolv2beta1.PoolIPPreAllocation{ + preAllocations := spiderpoolv1.PoolIPPreAllocations{ + "pool": spiderpoolv1.PoolIPPreAllocation{ IPs: []string{ "172.18.40.10", }, @@ -1336,8 +1336,8 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) - preAllocations := spiderpoolv2beta1.PoolIPPreAllocations{ - "pool": spiderpoolv2beta1.PoolIPPreAllocation{ + preAllocations := spiderpoolv1.PoolIPPreAllocations{ + "pool": spiderpoolv1.PoolIPPreAllocation{ IPs: constant.InvalidIPRanges, }, } @@ -1363,8 +1363,8 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) - preAllocations := spiderpoolv2beta1.PoolIPPreAllocations{ - "pool": spiderpoolv2beta1.PoolIPPreAllocation{ + preAllocations := spiderpoolv1.PoolIPPreAllocations{ + "pool": spiderpoolv1.PoolIPPreAllocation{ IPs: []string{ "172.18.40.10", }, @@ -1392,8 +1392,8 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { }..., ) - preAllocations := spiderpoolv2beta1.PoolIPPreAllocations{ - "pool": spiderpoolv2beta1.PoolIPPreAllocation{ + preAllocations := spiderpoolv1.PoolIPPreAllocations{ + "pool": spiderpoolv1.PoolIPPreAllocation{ IPs: []string{ "172.18.40.1", }, @@ -1449,7 +1449,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { newSubnetT.Spec.ExcludeIPs = append(newSubnetT.Spec.ExcludeIPs, "172.18.40.10") newSubnetT.Spec.Gateway = ptr.To("172.18.40.1") newSubnetT.Spec.Routes = append(newSubnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "192.168.40.0/24", Gw: "172.18.40.40", }, @@ -1470,7 +1470,7 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() { newSubnetT.Spec.ExcludeIPs = append(newSubnetT.Spec.ExcludeIPs, "abcd:1234::a") newSubnetT.Spec.Gateway = ptr.To("abcd:1234::1") newSubnetT.Spec.Routes = append(newSubnetT.Spec.Routes, - spiderpoolv2beta1.Route{ + spiderpoolv1.Route{ Dst: "fd00:40::/120", Gw: "abcd:1234::28", }, diff --git a/pkg/utils/convert/convert.go b/pkg/utils/convert/convert.go index ad565437e2..081e6f491b 100644 --- a/pkg/utils/convert/convert.go +++ b/pkg/utils/convert/convert.go @@ -16,11 +16,11 @@ import ( "github.com/spidernet-io/spiderpool/api/v1/agent/models" "github.com/spidernet-io/spiderpool/pkg/constant" spiderpoolip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" ) -func ConvertIPDetailsToIPConfigsAndAllRoutes(details []spiderpoolv2beta1.IPAllocationDetail) ([]*models.IPConfig, []*models.Route) { +func ConvertIPDetailsToIPConfigsAndAllRoutes(details []spiderpoolv1.IPAllocationDetail) ([]*models.IPConfig, []*models.Route) { var ips []*models.IPConfig var routes []*models.Route for _, d := range details { @@ -113,8 +113,8 @@ func genDefaultRoute(nic, gateway string) *models.Route { return route } -func ConvertResultsToIPDetails(results []*types.AllocationResult, isMultipleNicWithNoName bool) []spiderpoolv2beta1.IPAllocationDetail { - nicToDetail := map[string]*spiderpoolv2beta1.IPAllocationDetail{} +func ConvertResultsToIPDetails(results []*types.AllocationResult, isMultipleNicWithNoName bool) []spiderpoolv1.IPAllocationDetail { + nicToDetail := map[string]*spiderpoolv1.IPAllocationDetail{} for _, r := range results { var gateway *string var cleanGateway *bool @@ -144,7 +144,7 @@ func ConvertResultsToIPDetails(results []*types.AllocationResult, isMultipleNicW } if *r.IP.Version == constant.IPv4 { - nicToDetail[*r.IP.Nic] = &spiderpoolv2beta1.IPAllocationDetail{ + nicToDetail[*r.IP.Nic] = &spiderpoolv1.IPAllocationDetail{ NIC: *r.IP.Nic, IPv4: &address, IPv4Pool: &pool, @@ -154,7 +154,7 @@ func ConvertResultsToIPDetails(results []*types.AllocationResult, isMultipleNicW Routes: routes, } } else { - nicToDetail[*r.IP.Nic] = &spiderpoolv2beta1.IPAllocationDetail{ + nicToDetail[*r.IP.Nic] = &spiderpoolv1.IPAllocationDetail{ NIC: *r.IP.Nic, IPv6: &address, IPv6Pool: &pool, @@ -166,7 +166,7 @@ func ConvertResultsToIPDetails(results []*types.AllocationResult, isMultipleNicW } } - details := []spiderpoolv2beta1.IPAllocationDetail{} + details := []spiderpoolv1.IPAllocationDetail{} for _, d := range nicToDetail { details = append(details, *d) } @@ -213,7 +213,7 @@ func ConvertAnnoPodRoutesToOAIRoutes(annoPodRoutes types.AnnoPodRoutesValue) []* return routes } -func ConvertSpecRoutesToOAIRoutes(nic string, specRoutes []spiderpoolv2beta1.Route) []*models.Route { +func ConvertSpecRoutesToOAIRoutes(nic string, specRoutes []spiderpoolv1.Route) []*models.Route { var routes []*models.Route for _, r := range specRoutes { dst := r.Dst @@ -228,10 +228,10 @@ func ConvertSpecRoutesToOAIRoutes(nic string, specRoutes []spiderpoolv2beta1.Rou return routes } -func ConvertOAIRoutesToSpecRoutes(oaiRoutes []*models.Route) []spiderpoolv2beta1.Route { - var routes []spiderpoolv2beta1.Route +func ConvertOAIRoutesToSpecRoutes(oaiRoutes []*models.Route) []spiderpoolv1.Route { + var routes []spiderpoolv1.Route for _, r := range oaiRoutes { - routes = append(routes, spiderpoolv2beta1.Route{ + routes = append(routes, spiderpoolv1.Route{ Dst: *r.Dst, Gw: *r.Gw, }) @@ -240,7 +240,7 @@ func ConvertOAIRoutesToSpecRoutes(oaiRoutes []*models.Route) []spiderpoolv2beta1 return routes } -func GroupIPAllocationDetails(uid string, details []spiderpoolv2beta1.IPAllocationDetail) types.PoolNameToIPAndUIDs { +func GroupIPAllocationDetails(uid string, details []spiderpoolv1.IPAllocationDetail) types.PoolNameToIPAndUIDs { pius := types.PoolNameToIPAndUIDs{} for _, d := range details { if d.IPv4 != nil { @@ -260,7 +260,7 @@ func GroupIPAllocationDetails(uid string, details []spiderpoolv2beta1.IPAllocati return pius } -func GenIPConfigResult(allocateIP net.IP, nic string, ipPool *spiderpoolv2beta1.SpiderIPPool) *models.IPConfig { +func GenIPConfigResult(allocateIP net.IP, nic string, ipPool *spiderpoolv1.SpiderIPPool) *models.IPConfig { ipNet, _ := spiderpoolip.ParseIP(*ipPool.Spec.IPVersion, ipPool.Spec.Subnet, true) ipNet.IP = allocateIP address := ipNet.String() @@ -279,12 +279,12 @@ func GenIPConfigResult(allocateIP net.IP, nic string, ipPool *spiderpoolv2beta1. } } -func UnmarshalIPPoolAllocatedIPs(data *string) (spiderpoolv2beta1.PoolIPAllocations, error) { +func UnmarshalIPPoolAllocatedIPs(data *string) (spiderpoolv1.PoolIPAllocations, error) { if data == nil { return nil, nil } - var records spiderpoolv2beta1.PoolIPAllocations + var records spiderpoolv1.PoolIPAllocations if err := json.Unmarshal([]byte(*data), &records); err != nil { return nil, err } @@ -292,7 +292,7 @@ func UnmarshalIPPoolAllocatedIPs(data *string) (spiderpoolv2beta1.PoolIPAllocati return records, nil } -func MarshalIPPoolAllocatedIPs(records spiderpoolv2beta1.PoolIPAllocations) (*string, error) { +func MarshalIPPoolAllocatedIPs(records spiderpoolv1.PoolIPAllocations) (*string, error) { if len(records) == 0 { return nil, nil } @@ -306,12 +306,12 @@ func MarshalIPPoolAllocatedIPs(records spiderpoolv2beta1.PoolIPAllocations) (*st return &data, nil } -func UnmarshalSubnetAllocatedIPPools(data *string) (spiderpoolv2beta1.PoolIPPreAllocations, error) { +func UnmarshalSubnetAllocatedIPPools(data *string) (spiderpoolv1.PoolIPPreAllocations, error) { if data == nil { return nil, nil } - var subnetStatusAllocatedIPPool spiderpoolv2beta1.PoolIPPreAllocations + var subnetStatusAllocatedIPPool spiderpoolv1.PoolIPPreAllocations err := json.Unmarshal([]byte(*data), &subnetStatusAllocatedIPPool) if nil != err { return nil, err @@ -320,7 +320,7 @@ func UnmarshalSubnetAllocatedIPPools(data *string) (spiderpoolv2beta1.PoolIPPreA return subnetStatusAllocatedIPPool, nil } -func MarshalSubnetAllocatedIPPools(preAllocations spiderpoolv2beta1.PoolIPPreAllocations) (*string, error) { +func MarshalSubnetAllocatedIPPools(preAllocations spiderpoolv1.PoolIPPreAllocations) (*string, error) { if len(preAllocations) == 0 { return nil, nil } diff --git a/pkg/workloadendpointmanager/utils.go b/pkg/workloadendpointmanager/utils.go index 47272619df..28d77f61c9 100644 --- a/pkg/workloadendpointmanager/utils.go +++ b/pkg/workloadendpointmanager/utils.go @@ -4,10 +4,10 @@ package workloadendpointmanager import ( - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) -func RetrieveIPAllocation(uid, nic string, endpoint *spiderpoolv2beta1.SpiderEndpoint, isStatic bool) *spiderpoolv2beta1.PodIPAllocation { +func RetrieveIPAllocation(uid, nic string, endpoint *spiderpoolv1.SpiderEndpoint, isStatic bool) *spiderpoolv1.PodIPAllocation { if endpoint == nil { return nil } diff --git a/pkg/workloadendpointmanager/utils_test.go b/pkg/workloadendpointmanager/utils_test.go index 68eadb6787..719f5cf1d6 100644 --- a/pkg/workloadendpointmanager/utils_test.go +++ b/pkg/workloadendpointmanager/utils_test.go @@ -13,15 +13,15 @@ import ( "k8s.io/utils/ptr" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/workloadendpointmanager" ) var _ = Describe("WorkloadEndpointManager utils", Label("workloadendpoint_manager_utils_test"), func() { - var endpointT *spiderpoolv2beta1.SpiderEndpoint + var endpointT *spiderpoolv1.SpiderEndpoint BeforeEach(func() { - endpointT = &spiderpoolv2beta1.SpiderEndpoint{ + endpointT = &spiderpoolv1.SpiderEndpoint{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderEndpoint, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -30,23 +30,23 @@ var _ = Describe("WorkloadEndpointManager utils", Label("workloadendpoint_manage Name: "endpoint", Namespace: "default", }, - Status: spiderpoolv2beta1.WorkloadEndpointStatus{}, + Status: spiderpoolv1.WorkloadEndpointStatus{}, } }) Describe("Test RetrieveIPAllocation", func() { var nic1, nic2 string var uid string - var allocationT spiderpoolv2beta1.PodIPAllocation + var allocationT spiderpoolv1.PodIPAllocation BeforeEach(func() { nic1 = "eth0" nic2 = "net1" uid = string(uuid.NewUUID()) - allocationT = spiderpoolv2beta1.PodIPAllocation{ + allocationT = spiderpoolv1.PodIPAllocation{ UID: uid, - IPs: []spiderpoolv2beta1.IPAllocationDetail{ + IPs: []spiderpoolv1.IPAllocationDetail{ { NIC: nic1, Vlan: ptr.To(int64(0)), @@ -92,7 +92,7 @@ var _ = Describe("WorkloadEndpointManager utils", Label("workloadendpoint_manage }) It("retrieves the IP allocation of empty nic", func() { - allocationT.IPs = append(allocationT.IPs, spiderpoolv2beta1.IPAllocationDetail{ + allocationT.IPs = append(allocationT.IPs, spiderpoolv1.IPAllocationDetail{ NIC: "", Vlan: ptr.To(int64(0)), IPv4: ptr.To("10.60.1.2/24"), diff --git a/pkg/workloadendpointmanager/workloadendpoint_manager.go b/pkg/workloadendpointmanager/workloadendpoint_manager.go index ef68cc6aa9..3ca5dffe0b 100644 --- a/pkg/workloadendpointmanager/workloadendpoint_manager.go +++ b/pkg/workloadendpointmanager/workloadendpoint_manager.go @@ -17,7 +17,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/logutils" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/utils/convert" @@ -25,14 +25,14 @@ import ( ) type WorkloadEndpointManager interface { - GetEndpointByName(ctx context.Context, namespace, podName string, cached bool) (*spiderpoolv2beta1.SpiderEndpoint, error) - ListEndpoints(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderEndpointList, error) - DeleteEndpoint(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint) error - RemoveFinalizer(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint) error - PatchIPAllocationResults(ctx context.Context, results []*types.AllocationResult, endpoint *spiderpoolv2beta1.SpiderEndpoint, pod *corev1.Pod, podController types.PodTopController, isMultipleNicWithNoName bool) error - ReallocateCurrentIPAllocation(ctx context.Context, uid, nodeName, nic string, endpoint *spiderpoolv2beta1.SpiderEndpoint, isMultipleNicWithNoName bool) error - UpdateAllocationNICName(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint, nic string) (*spiderpoolv2beta1.PodIPAllocation, error) - ReleaseEndpointIPs(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint, uid string) ([]spiderpoolv2beta1.IPAllocationDetail, error) + GetEndpointByName(ctx context.Context, namespace, podName string, cached bool) (*spiderpoolv1.SpiderEndpoint, error) + ListEndpoints(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderEndpointList, error) + DeleteEndpoint(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint) error + RemoveFinalizer(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint) error + PatchIPAllocationResults(ctx context.Context, results []*types.AllocationResult, endpoint *spiderpoolv1.SpiderEndpoint, pod *corev1.Pod, podController types.PodTopController, isMultipleNicWithNoName bool) error + ReallocateCurrentIPAllocation(ctx context.Context, uid, nodeName, nic string, endpoint *spiderpoolv1.SpiderEndpoint, isMultipleNicWithNoName bool) error + UpdateAllocationNICName(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint, nic string) (*spiderpoolv1.PodIPAllocation, error) + ReleaseEndpointIPs(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint, uid string) ([]spiderpoolv1.IPAllocationDetail, error) ReleaseEndpointAndFinalizer(ctx context.Context, namespace, podName string, cached bool) error } @@ -60,13 +60,13 @@ func NewWorkloadEndpointManager(client client.Client, apiReader client.Reader, e }, nil } -func (em *workloadEndpointManager) GetEndpointByName(ctx context.Context, namespace, podName string, cached bool) (*spiderpoolv2beta1.SpiderEndpoint, error) { +func (em *workloadEndpointManager) GetEndpointByName(ctx context.Context, namespace, podName string, cached bool) (*spiderpoolv1.SpiderEndpoint, error) { reader := em.apiReader if cached == constant.UseCache { reader = em.client } - var endpoint spiderpoolv2beta1.SpiderEndpoint + var endpoint spiderpoolv1.SpiderEndpoint if err := reader.Get(ctx, apitypes.NamespacedName{Namespace: namespace, Name: podName}, &endpoint); nil != err { return nil, err } @@ -74,13 +74,13 @@ func (em *workloadEndpointManager) GetEndpointByName(ctx context.Context, namesp return &endpoint, nil } -func (em *workloadEndpointManager) ListEndpoints(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv2beta1.SpiderEndpointList, error) { +func (em *workloadEndpointManager) ListEndpoints(ctx context.Context, cached bool, opts ...client.ListOption) (*spiderpoolv1.SpiderEndpointList, error) { reader := em.apiReader if cached == constant.UseCache { reader = em.client } - var endpointList spiderpoolv2beta1.SpiderEndpointList + var endpointList spiderpoolv1.SpiderEndpointList if err := reader.List(ctx, &endpointList, opts...); err != nil { return nil, err } @@ -88,7 +88,7 @@ func (em *workloadEndpointManager) ListEndpoints(ctx context.Context, cached boo return &endpointList, nil } -func (em *workloadEndpointManager) DeleteEndpoint(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint) error { +func (em *workloadEndpointManager) DeleteEndpoint(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint) error { if err := em.client.Delete(ctx, endpoint); err != nil { return client.IgnoreNotFound(err) } @@ -96,7 +96,7 @@ func (em *workloadEndpointManager) DeleteEndpoint(ctx context.Context, endpoint return nil } -func (em *workloadEndpointManager) RemoveFinalizer(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint) error { +func (em *workloadEndpointManager) RemoveFinalizer(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint) error { if endpoint == nil { return fmt.Errorf("endpoint %w", constant.ErrMissingRequiredParam) } @@ -115,7 +115,7 @@ func (em *workloadEndpointManager) RemoveFinalizer(ctx context.Context, endpoint return nil } -func (em *workloadEndpointManager) PatchIPAllocationResults(ctx context.Context, results []*types.AllocationResult, endpoint *spiderpoolv2beta1.SpiderEndpoint, pod *corev1.Pod, podController types.PodTopController, isMultipleNicWithNoName bool) error { +func (em *workloadEndpointManager) PatchIPAllocationResults(ctx context.Context, results []*types.AllocationResult, endpoint *spiderpoolv1.SpiderEndpoint, pod *corev1.Pod, podController types.PodTopController, isMultipleNicWithNoName bool) error { if pod == nil { return fmt.Errorf("pod %w", constant.ErrMissingRequiredParam) } @@ -123,13 +123,13 @@ func (em *workloadEndpointManager) PatchIPAllocationResults(ctx context.Context, logger := logutils.FromContext(ctx) if endpoint == nil { - endpoint = &spiderpoolv2beta1.SpiderEndpoint{ + endpoint = &spiderpoolv1.SpiderEndpoint{ ObjectMeta: metav1.ObjectMeta{ Name: pod.Name, Namespace: pod.Namespace, }, - Status: spiderpoolv2beta1.WorkloadEndpointStatus{ - Current: spiderpoolv2beta1.PodIPAllocation{ + Status: spiderpoolv1.WorkloadEndpointStatus{ + Current: spiderpoolv1.PodIPAllocation{ UID: string(pod.UID), Node: pod.Spec.NodeName, IPs: convert.ConvertResultsToIPDetails(results, isMultipleNicWithNoName), @@ -169,7 +169,7 @@ func (em *workloadEndpointManager) PatchIPAllocationResults(ctx context.Context, return em.client.Update(ctx, endpoint) } -func (em *workloadEndpointManager) ReallocateCurrentIPAllocation(ctx context.Context, uid, nodeName, nic string, endpoint *spiderpoolv2beta1.SpiderEndpoint, isMultipleNicWithNoName bool) error { +func (em *workloadEndpointManager) ReallocateCurrentIPAllocation(ctx context.Context, uid, nodeName, nic string, endpoint *spiderpoolv1.SpiderEndpoint, isMultipleNicWithNoName bool) error { if endpoint == nil { return fmt.Errorf("endpoint %w", constant.ErrMissingRequiredParam) } @@ -206,7 +206,7 @@ func (em *workloadEndpointManager) ReallocateCurrentIPAllocation(ctx context.Con return em.client.Update(ctx, endpoint) } -func (em *workloadEndpointManager) UpdateAllocationNICName(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint, nic string) (*spiderpoolv2beta1.PodIPAllocation, error) { +func (em *workloadEndpointManager) UpdateAllocationNICName(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint, nic string) (*spiderpoolv1.PodIPAllocation, error) { for index := range endpoint.Status.Current.IPs { if endpoint.Status.Current.IPs[index].NIC != "" { if endpoint.Status.Current.IPs[index].NIC == nic { @@ -228,7 +228,7 @@ func (em *workloadEndpointManager) UpdateAllocationNICName(ctx context.Context, } // ReleaseEndpointIPs will release the SpiderEndpoint status recorded IPs. -func (em *workloadEndpointManager) ReleaseEndpointIPs(ctx context.Context, endpoint *spiderpoolv2beta1.SpiderEndpoint, podUID string) ([]spiderpoolv2beta1.IPAllocationDetail, error) { +func (em *workloadEndpointManager) ReleaseEndpointIPs(ctx context.Context, endpoint *spiderpoolv1.SpiderEndpoint, podUID string) ([]spiderpoolv1.IPAllocationDetail, error) { log := logutils.FromContext(ctx) if endpoint.Status.Current.UID != podUID { @@ -237,7 +237,7 @@ func (em *workloadEndpointManager) ReleaseEndpointIPs(ctx context.Context, endpo recordedIPAllocationDetails := endpoint.Status.Current.IPs if len(recordedIPAllocationDetails) != 0 { - endpoint.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{} + endpoint.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{} log.Sugar().Debugf("try to clean up SpiderEndpoint recorded IPs: %s", endpoint) err := em.client.Update(ctx, endpoint) if nil != err { diff --git a/pkg/workloadendpointmanager/workloadendpoint_manager_suite_test.go b/pkg/workloadendpointmanager/workloadendpoint_manager_suite_test.go index fe8b632b82..e2ff7a83e8 100644 --- a/pkg/workloadendpointmanager/workloadendpoint_manager_suite_test.go +++ b/pkg/workloadendpointmanager/workloadendpoint_manager_suite_test.go @@ -16,7 +16,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/workloadendpointmanager" ) @@ -33,7 +33,7 @@ func TestWorkloadEndpointManager(t *testing.T) { var _ = BeforeSuite(func() { scheme = runtime.NewScheme() - err := spiderpoolv2beta1.AddToScheme(scheme) + err := spiderpoolv1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) err = corev1.AddToScheme(scheme) @@ -41,8 +41,8 @@ var _ = BeforeSuite(func() { fakeClient = fake.NewClientBuilder(). WithScheme(scheme). - WithIndex(&spiderpoolv2beta1.SpiderEndpoint{}, metav1.ObjectNameField, func(raw client.Object) []string { - endpoint := raw.(*spiderpoolv2beta1.SpiderEndpoint) + WithIndex(&spiderpoolv1.SpiderEndpoint{}, metav1.ObjectNameField, func(raw client.Object) []string { + endpoint := raw.(*spiderpoolv1.SpiderEndpoint) return []string{endpoint.GetObjectMeta().GetName()} }). Build() @@ -51,8 +51,8 @@ var _ = BeforeSuite(func() { fakeAPIReader = fake.NewClientBuilder(). WithScheme(scheme). WithObjectTracker(tracker). - WithIndex(&spiderpoolv2beta1.SpiderEndpoint{}, metav1.ObjectNameField, func(raw client.Object) []string { - endpoint := raw.(*spiderpoolv2beta1.SpiderEndpoint) + WithIndex(&spiderpoolv1.SpiderEndpoint{}, metav1.ObjectNameField, func(raw client.Object) []string { + endpoint := raw.(*spiderpoolv1.SpiderEndpoint) return []string{endpoint.GetObjectMeta().GetName()} }). Build() diff --git a/pkg/workloadendpointmanager/workloadendpoint_manager_test.go b/pkg/workloadendpointmanager/workloadendpoint_manager_test.go index 13d892026c..1702004dd8 100644 --- a/pkg/workloadendpointmanager/workloadendpoint_manager_test.go +++ b/pkg/workloadendpointmanager/workloadendpoint_manager_test.go @@ -25,7 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" spiderpooltypes "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/workloadendpointmanager" ) @@ -62,7 +62,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test var namespace string var endpointName string var labels map[string]string - var endpointT *spiderpoolv2beta1.SpiderEndpoint + var endpointT *spiderpoolv1.SpiderEndpoint BeforeEach(func() { ctx = context.TODO() @@ -71,7 +71,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test namespace = "default" endpointName = fmt.Sprintf("endpoint-%v", count) labels = map[string]string{"foo": fmt.Sprintf("bar-%v", count)} - endpointT = &spiderpoolv2beta1.SpiderEndpoint{ + endpointT = &spiderpoolv1.SpiderEndpoint{ TypeMeta: metav1.TypeMeta{ Kind: constant.KindSpiderEndpoint, APIVersion: fmt.Sprintf("%s/%s", constant.SpiderpoolAPIGroup, constant.SpiderpoolAPIVersion), @@ -81,8 +81,8 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test Namespace: namespace, Labels: labels, }, - Status: spiderpoolv2beta1.WorkloadEndpointStatus{ - Current: spiderpoolv2beta1.PodIPAllocation{}, + Status: spiderpoolv1.WorkloadEndpointStatus{ + Current: spiderpoolv1.PodIPAllocation{}, }, } }) @@ -294,7 +294,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test err = endpointManager.RemoveFinalizer(ctx, endpointT) Expect(err).NotTo(HaveOccurred()) - var endpoint spiderpoolv2beta1.SpiderEndpoint + var endpoint spiderpoolv1.SpiderEndpoint err = fakeClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: endpointName}, &endpoint) Expect(err).NotTo(HaveOccurred()) @@ -364,7 +364,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test ) Expect(err).NotTo(HaveOccurred()) - var endpoint spiderpoolv2beta1.SpiderEndpoint + var endpoint spiderpoolv1.SpiderEndpoint err = fakeClient.Get(ctx, types.NamespacedName{Namespace: podT.Namespace, Name: podT.Name}, &endpoint) Expect(err).NotTo(HaveOccurred()) @@ -393,7 +393,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test ) Expect(err).NotTo(HaveOccurred()) - var endpoint spiderpoolv2beta1.SpiderEndpoint + var endpoint spiderpoolv1.SpiderEndpoint err = fakeClient.Get(ctx, types.NamespacedName{Namespace: podT.Namespace, Name: podT.Name}, &endpoint) Expect(err).NotTo(HaveOccurred()) @@ -424,7 +424,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test ) Expect(err).NotTo(HaveOccurred()) - var endpoint spiderpoolv2beta1.SpiderEndpoint + var endpoint spiderpoolv1.SpiderEndpoint err = fakeClient.Get(ctx, types.NamespacedName{Namespace: podT.Namespace, Name: vmiName}, &endpoint) Expect(err).NotTo(HaveOccurred()) @@ -487,7 +487,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test endpointT.Status.Current.UID = string(uuid.NewUUID()) endpointT.Status.Current.Node = "old-node" - endpointT.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{ + endpointT.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{ {NIC: nic}, } @@ -508,7 +508,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test It("update the current IP allocation with new NIC name for empty nic field", func() { endpointT.Status.Current.UID = string(uuid.NewUUID()) endpointT.Status.Current.Node = "old-node" - endpointT.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{{NIC: ""}} + endpointT.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{{NIC: ""}} err := fakeClient.Create(ctx, endpointT) Expect(err).NotTo(HaveOccurred()) @@ -533,7 +533,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test endpointT.Status.Current.UID = string(uuid.NewUUID()) endpointT.Status.Current.Node = "old-node" - endpointT.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{ + endpointT.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{ {NIC: ""}, } @@ -548,7 +548,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test It("failed to update the Endpoint status current IPs with new NIC name for empty nic filed", func() { endpointT.Status.Current.UID = string(uuid.NewUUID()) endpointT.Status.Current.Node = "old-node" - endpointT.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{ + endpointT.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{ {NIC: ""}, } @@ -566,7 +566,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test nic := "eth0" endpointT.Status.Current.UID = string(uuid.NewUUID()) endpointT.Status.Current.Node = "old-node" - endpointT.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{ + endpointT.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{ {NIC: nic}, } @@ -603,7 +603,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test podUID := string(uuid.NewUUID()) endpointT.Status.Current.UID = podUID - endpointT.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{ + endpointT.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{ { NIC: "eth0", IPv4: ptr.To("172.10.2.3/16"), @@ -621,7 +621,7 @@ var _ = Describe("WorkloadEndpointManager", Label("workloadendpoint_manager_test podUID := string(uuid.NewUUID()) endpointT.Status.Current.UID = podUID - endpointT.Status.Current.IPs = []spiderpoolv2beta1.IPAllocationDetail{ + endpointT.Status.Current.IPs = []spiderpoolv1.IPAllocationDetail{ { NIC: "eth0", IPv4: ptr.To("172.100.1.2/16"), diff --git a/test/e2e/affinity/affinity_suite_test.go b/test/e2e/affinity/affinity_suite_test.go index 98b9a337aa..b7fe29868b 100644 --- a/test/e2e/affinity/affinity_suite_test.go +++ b/test/e2e/affinity/affinity_suite_test.go @@ -6,7 +6,7 @@ import ( "testing" e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "k8s.io/apimachinery/pkg/runtime" . "github.com/onsi/ginkgo/v2" diff --git a/test/e2e/affinity/affinity_test.go b/test/e2e/affinity/affinity_test.go index 540714ac24..ba4f1f0f7b 100644 --- a/test/e2e/affinity/affinity_test.go +++ b/test/e2e/affinity/affinity_test.go @@ -14,7 +14,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -22,7 +22,7 @@ import ( var _ = Describe("test Affinity", Label("affinity"), func() { var namespace string var v4SubnetName, v6SubnetName string - var v4SubnetObject, v6SubnetObject *spiderpoolv2beta1.SpiderSubnet + var v4SubnetObject, v6SubnetObject *spiderpoolv1.SpiderSubnet BeforeEach(func() { if frame.Info.SpiderSubnetEnabled { @@ -81,8 +81,8 @@ var _ = Describe("test Affinity", Label("affinity"), func() { matchedNode, unMatchedNode *corev1.Node v4PoolName string v6PoolName string - v4Pool *spiderpoolv2beta1.SpiderIPPool - v6Pool *spiderpoolv2beta1.SpiderIPPool + v4Pool *spiderpoolv1.SpiderIPPool + v6Pool *spiderpoolv1.SpiderIPPool v4PoolNameList, v6PoolNameList []string ) @@ -377,7 +377,7 @@ var _ = Describe("test Affinity", Label("affinity"), func() { Context("Support Statefulset pod who will be always assigned same IP addresses.", func() { var v4PoolName, v6PoolName, defaultV4PoolName, defaultV6PoolName, statefulSetName string - var v4PoolObj, v6PoolObj, defaultV4PoolObj, defaultV6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj, defaultV4PoolObj, defaultV6PoolObj *spiderpoolv1.SpiderIPPool var newPodList *corev1.PodList var defaultV4PoolNameList, defaultV6PoolNameList []string const stsOriginialNum = int(1) @@ -591,7 +591,7 @@ var _ = Describe("test Affinity", Label("affinity"), func() { Context("one IPPool can be used by multiple namespace", func() { var v4PoolName, v6PoolName, nsName1 string - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool var v4PoolNameList, v6PoolNameList []string nsName1 = "ns1" + tools.RandomName() diff --git a/test/e2e/annotation/annotation_suite_test.go b/test/e2e/annotation/annotation_suite_test.go index e51211f410..c149efaed6 100644 --- a/test/e2e/annotation/annotation_suite_test.go +++ b/test/e2e/annotation/annotation_suite_test.go @@ -5,7 +5,7 @@ package annotation_test import ( "testing" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/test/e2e/annotation/annotation_test.go b/test/e2e/annotation/annotation_test.go index f36531701c..1ccb5e25fa 100644 --- a/test/e2e/annotation/annotation_test.go +++ b/test/e2e/annotation/annotation_test.go @@ -15,10 +15,9 @@ import ( "github.com/spidernet-io/e2eframework/tools" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/utils/ptr" pkgconstant "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -208,82 +207,6 @@ var _ = Describe("test annotation", Label("annotation"), func() { }]`), ) - It("it fails to run a pod with different VLAN for ipv4 and ipv6 ippool", Pending, Label("A00001", "Deprecated"), func() { - var ( - v4PoolName, v6PoolName string - iPv4PoolObj, iPv6PoolObj *spiderpool.SpiderIPPool - err error - ipNum int = 2 - ipv4Vlan int64 = 10 - ipv6Vlan int64 = 20 - ) - - // The case relies on a Dual-stack - if !frame.Info.IpV6Enabled || !frame.Info.IpV4Enabled { - Skip("Test conditions (Dual-stack) are not met") - } - - // Create IPv4Pool and IPv6Pool - Eventually(func() error { - v4PoolName, iPv4PoolObj = common.GenerateExampleIpv4poolObject(ipNum) - iPv4PoolObj.Spec.Vlan = ptr.To(ipv4Vlan) - GinkgoWriter.Printf("try to create ipv4pool: %v \n", v4PoolName) - if frame.Info.SpiderSubnetEnabled { - ctx, cancel := context.WithTimeout(context.Background(), common.PodStartTimeout) - defer cancel() - err = common.CreateIppoolInSpiderSubnet(ctx, frame, v4SubnetName, iPv4PoolObj, ipNum) - } else { - err = common.CreateIppool(frame, iPv4PoolObj) - } - if err != nil { - GinkgoWriter.Printf("Failed to create v4 IPPool: %v \n", err) - return err - } - - v6PoolName, iPv6PoolObj = common.GenerateExampleIpv6poolObject(ipNum) - iPv6PoolObj.Spec.Vlan = ptr.To(ipv6Vlan) - GinkgoWriter.Printf("try to create ipv6pool: %v \n", v6PoolName) - if frame.Info.SpiderSubnetEnabled { - ctx, cancel := context.WithTimeout(context.Background(), common.PodStartTimeout) - defer cancel() - err = common.CreateIppoolInSpiderSubnet(ctx, frame, v6SubnetName, iPv6PoolObj, ipNum) - } else { - err = common.CreateIppool(frame, iPv6PoolObj) - } - if err != nil { - GinkgoWriter.Printf("Failed to create v6 IPPool: %v \n", err) - return err - } - return nil - }).WithTimeout(time.Minute).WithPolling(time.Second * 3).Should(BeNil()) - // Generate IPPool annotations string - podIppoolAnnoStr := common.GeneratePodIPPoolAnnotations(frame, common.NIC1, []string{v4PoolName}, []string{v6PoolName}) - - // Generate Pod yaml and add IPPool annotations to it - GinkgoWriter.Printf("try to create pod %v/%v with annotation %v=%v \n", nsName, podName, pkgconstant.AnnoPodIPPool, podIppoolAnnoStr) - podYaml := common.GenerateExamplePodYaml(podName, nsName) - podYaml.Annotations = map[string]string{pkgconstant.AnnoPodIPPool: podIppoolAnnoStr} - Expect(frame.CreatePod(podYaml)).NotTo(HaveOccurred()) - - // It fails to run a pod with different VLAN for ipv4 and ipv6 ippool - ctx1, cancel1 := context.WithTimeout(context.Background(), common.EventOccurTimeout) - defer cancel1() - GinkgoWriter.Printf("different VLAN for ipv4 and ipv6 ippool with fail to run pod %v/%v \n", nsName, podName) - err = frame.WaitExceptEventOccurred(ctx1, common.OwnerPod, podName, nsName, common.CNIFailedToSetUpNetwork) - Expect(err).NotTo(HaveOccurred(), "Failedto get event %v/%v = %v\n", nsName, podName, common.CNIFailedToSetUpNetwork) - pod, err := frame.GetPod(podName, nsName) - Expect(err).NotTo(HaveOccurred()) - Expect(pod.Status.Phase).To(Equal(corev1.PodPending)) - - // Cleaning up the test env - Expect(frame.DeletePod(podName, nsName)).NotTo(HaveOccurred(), "failed to delete pod %v/%v \n", nsName, podName) - GinkgoWriter.Printf("Successful deletion of pods %v/%v \n", nsName, podName) - Expect(common.DeleteIPPoolByName(frame, v4PoolName)).NotTo(HaveOccurred()) - GinkgoWriter.Printf("Successful deletion of ipv4pool %v \n", v4PoolName) - Expect(common.DeleteIPPoolByName(frame, v6PoolName)).NotTo(HaveOccurred()) - GinkgoWriter.Printf("Successful deletion of ipv6pool %v \n", v6PoolName) - }) - Context("annotation priority", func() { var v4PoolName, v6PoolName, podIppoolAnnoStr, podIppoolsAnnoStr string var iPv4PoolObj, iPv6PoolObj *spiderpool.SpiderIPPool diff --git a/test/e2e/assignip/assiginip_suite_test.go b/test/e2e/assignip/assiginip_suite_test.go index ee53b9e901..4e85243cb0 100644 --- a/test/e2e/assignip/assiginip_suite_test.go +++ b/test/e2e/assignip/assiginip_suite_test.go @@ -5,7 +5,7 @@ package assignip_test import ( "testing" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/test/e2e/assignip/assignip_test.go b/test/e2e/assignip/assignip_test.go index 6d18c928b8..884ec7c3ff 100644 --- a/test/e2e/assignip/assignip_test.go +++ b/test/e2e/assignip/assignip_test.go @@ -14,7 +14,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -23,9 +23,9 @@ var _ = Describe("test pod", Label("assignip"), func() { Context("fail to run a pod when IP resource of an ippool is exhausted or its IP been set excludeIPs", func() { var deployName, v4PoolName, v6PoolName, namespace string var v4PoolNameList, v6PoolNameList []string - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool var v4SubnetName, v6SubnetName string - var v4SubnetObject, v6SubnetObject *spiderpoolv2beta1.SpiderSubnet + var v4SubnetObject, v6SubnetObject *spiderpoolv1.SpiderSubnet var ( deployOriginialNum int = 1 diff --git a/test/e2e/common/reservedip.go b/test/e2e/common/reservedip.go index c0f80285a1..de5624f51c 100644 --- a/test/e2e/common/reservedip.go +++ b/test/e2e/common/reservedip.go @@ -17,7 +17,7 @@ import ( apitypes "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) func CreateReservedIP(f *frame.Framework, ReservedIP *spiderpool.SpiderReservedIP, opts ...client.CreateOption) error { diff --git a/test/e2e/common/spiderpool.go b/test/e2e/common/spiderpool.go index c1ac8b309a..0dbb32ba7c 100644 --- a/test/e2e/common/spiderpool.go +++ b/test/e2e/common/spiderpool.go @@ -10,7 +10,7 @@ import ( "sync" "time" - v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + v1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/lock" "github.com/spidernet-io/spiderpool/pkg/utils/convert" "k8s.io/client-go/tools/cache" @@ -32,41 +32,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -func GetSpiderClaimParameter(f *frame.Framework, name, ns string) (*v1.SpiderClaimParameter, error) { - if name == "" || f == nil { - return nil, errors.New("wrong input") - } - - v := apitypes.NamespacedName{Name: name, Namespace: ns} - existing := &v1.SpiderClaimParameter{} - e := f.GetResource(v, existing) - if e != nil { - return nil, e - } - return existing, nil -} - -func CreateSpiderClaimParameter(f *frame.Framework, scp *v1.SpiderClaimParameter, opts ...client.CreateOption) error { - if f == nil || scp == nil { - return fmt.Errorf("invalid parameters") - } - - return f.CreateResource(scp, opts...) -} - -func DeleteSpiderClaimParameter(f *frame.Framework, spiderClaimName, ns string, opts ...client.DeleteOption) error { - if spiderClaimName == "" || f == nil { - return errors.New("wrong input") - } - pool := &v1.SpiderClaimParameter{ - ObjectMeta: metav1.ObjectMeta{ - Name: spiderClaimName, - Namespace: ns, - }, - } - return f.DeleteResource(pool, opts...) -} - func CreateIppool(f *frame.Framework, ippool *v1.SpiderIPPool, opts ...client.CreateOption) error { if f == nil || ippool == nil { return errors.New("wrong input") diff --git a/test/e2e/common/spidersubnet.go b/test/e2e/common/spidersubnet.go index faef46f755..4e2ad4dbcd 100644 --- a/test/e2e/common/spidersubnet.go +++ b/test/e2e/common/spidersubnet.go @@ -16,7 +16,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/utils/convert" ip "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" . "github.com/onsi/ginkgo/v2" diff --git a/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_suite_test.go b/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_suite_test.go index 4db943ea40..e5d751a2ed 100644 --- a/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_suite_test.go +++ b/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_suite_test.go @@ -11,12 +11,11 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/ptr" ) func TestMacvlanOverlayOne(t *testing.T) { @@ -59,7 +58,6 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) copy := smc.Spec - copy.CoordinatorConfig.HostRPFilter = ptr.To(1) err = frame.CreateSpiderMultusInstance(&spiderpool.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("test-macvlan%d", idx+1), diff --git a/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_test.go b/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_test.go index f72be43b4e..f0ad53a7eb 100644 --- a/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_test.go +++ b/test/e2e/coordinator/macvlan-overlay-one/macvlan_overlay_one_test.go @@ -26,7 +26,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" pkgconstant "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/test/e2e/common" corev1 "k8s.io/api/core/v1" @@ -372,7 +372,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") Expect(err).NotTo(HaveOccurred()) Eventually(func() error { - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool if frame.Info.IpV4Enabled { v4PoolName, v4PoolObj = common.GenerateExampleIpv4poolObject(1) gateway := strings.Split(v4PoolObj.Spec.Subnet, "0/")[0] + "1" @@ -398,17 +398,17 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") return nil }).WithTimeout(time.Minute).WithPolling(time.Second * 3).Should(BeNil()) // Define multus cni NetworkAttachmentDefinition and create - nad := &spiderpoolv2beta1.SpiderMultusConfig{ + nad := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: v1.ObjectMeta{ Name: multusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodMACPrefix: &macPrefix, PodDefaultRouteNIC: &common.NIC2, Mode: &mode, @@ -578,17 +578,17 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") detectGateway := true // Define multus cni NetworkAttachmentDefinition and set DetectGateway to true - nad := &spiderpoolv2beta1.SpiderMultusConfig{ + nad := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: v1.ObjectMeta{ Name: detectGatewayMultusName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ Mode: &mode, DetectGateway: &detectGateway, PodCIDRType: &podCidrType, @@ -663,7 +663,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") Context("ip conflict detection (ipv4, ipv6)", func() { var v4IpConflict, v6IpConflict string var depName, namespace, v4PoolName, v6PoolName, mode, podCidrType string - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool var ipConflict bool var multusNadName = "test-multus-" + common.GenerateString(10, true) @@ -678,17 +678,17 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") Expect(err).NotTo(HaveOccurred()) // Define multus cni NetworkAttachmentDefinition and create - nad := &spiderpoolv2beta1.SpiderMultusConfig{ + nad := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: v1.ObjectMeta{ Name: multusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ Mode: &mode, DetectIPConflict: &ipConflict, PodCIDRType: &podCidrType, @@ -715,7 +715,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") var vlanID int32 = 200 Eventually(func() error { - var smc spiderpoolv2beta1.SpiderMultusConfig + var smc spiderpoolv1.SpiderMultusConfig err := frame.KClient.Get(context.TODO(), apitypes.NamespacedName{ Namespace: namespace, Name: multusNadName, @@ -905,7 +905,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") podAnno := types.AnnoPodIPPoolValue{} // 2. create an IPPool with conflicted IPs - var conflictV4Pool spiderpoolv2beta1.SpiderIPPool + var conflictV4Pool spiderpoolv1.SpiderIPPool var firstConflictV4IP string if frame.Info.IpV4Enabled { conflictV4PoolName := "conflict-v4-pool" @@ -923,7 +923,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") return nil } - var v4Subnet spiderpoolv2beta1.SpiderSubnet + var v4Subnet spiderpoolv1.SpiderSubnet err := frame.KClient.Get(ctx, apitypes.NamespacedName{Name: common.SpiderPoolIPv4SubnetDefault}, &v4Subnet) if nil != err { if api_errors.IsNotFound(err) { @@ -955,7 +955,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") podAnno.IPv4Pools = []string{conflictV4PoolName} } - var conflictV6Pool spiderpoolv2beta1.SpiderIPPool + var conflictV6Pool spiderpoolv1.SpiderIPPool var firstConflictV6IP string if frame.Info.IpV6Enabled { conflictV6PoolName := "conflict-v6-pool" @@ -974,7 +974,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") return nil } - var v6Subnet spiderpoolv2beta1.SpiderSubnet + var v6Subnet spiderpoolv1.SpiderSubnet err := frame.KClient.Get(ctx, apitypes.NamespacedName{Name: common.SpiderPoolIPv6SubnetDefault}, &v6Subnet) if nil != err { if api_errors.IsNotFound(err) { @@ -1113,7 +1113,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") Expect(err).NotTo(HaveOccurred()) Eventually(func() error { - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool if frame.Info.IpV4Enabled { v4PoolName, v4PoolObj = common.GenerateExampleIpv4poolObject(1) gateway := strings.Split(v4PoolObj.Spec.Subnet, "0/")[0] + "1" @@ -1138,17 +1138,17 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") }).WithTimeout(time.Minute).WithPolling(time.Second * 3).Should(BeNil()) // Define multus cni NetworkAttachmentDefinition and create - nad := &spiderpoolv2beta1.SpiderMultusConfig{ + nad := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: v1.ObjectMeta{ Name: multusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ Mode: &mode, PodCIDRType: &podCidrType, }, @@ -1600,7 +1600,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") Context("Validation of different input fields in the coodinator.", func() { var namespace, depName, mode, multusNadName string - var nad *spiderpoolv2beta1.SpiderMultusConfig + var nad *spiderpoolv1.SpiderMultusConfig BeforeEach(func() { mode = "overlay" @@ -1611,17 +1611,17 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") err := frame.CreateNamespaceUntilDefaultServiceAccountReady(namespace, common.ServiceAccountReadyTimeout) Expect(err).NotTo(HaveOccurred()) - nad = &spiderpoolv2beta1.SpiderMultusConfig{ + nad = &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: v1.ObjectMeta{ Name: multusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ Mode: &mode, }, }, @@ -1789,7 +1789,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator") // 1. Create an IP pool and set the IP number to 1. var v4PoolName, v6PoolName, dirtyV4IPUsed, dirtyV6IPUsed string - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool if frame.Info.IpV4Enabled { v4PoolName, v4PoolObj = common.GenerateExampleIpv4poolObject(1) err = common.CreateIppool(frame, v4PoolObj) diff --git a/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_suite_test.go b/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_suite_test.go index 49913ab443..3953130fa4 100644 --- a/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_suite_test.go +++ b/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_suite_test.go @@ -10,7 +10,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" "k8s.io/apimachinery/pkg/runtime" ) diff --git a/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_test.go b/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_test.go index 4377d3033b..70f4c993c2 100644 --- a/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_test.go +++ b/test/e2e/coordinator/macvlan-underlay-one/macvlan_underlay_one_test.go @@ -21,7 +21,7 @@ import ( pkgconstant "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/test/e2e/common" corev1 "k8s.io/api/core/v1" @@ -209,7 +209,7 @@ var _ = Describe("MacvlanUnderlayOne", Serial, Label("underlay", "one-interface" Expect(err).NotTo(HaveOccurred()) Eventually(func() error { - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool if frame.Info.IpV4Enabled { v4PoolName, v4PoolObj = common.GenerateExampleIpv4poolObject(1) gateway := strings.Split(v4PoolObj.Spec.Subnet, "0/")[0] + "1" @@ -234,18 +234,18 @@ var _ = Describe("MacvlanUnderlayOne", Serial, Label("underlay", "one-interface" }).WithTimeout(time.Minute).WithPolling(time.Second * 3).Should(BeNil()) // Define multus cni NetworkAttachmentDefinition and create - nad := &spiderpoolv2beta1.SpiderMultusConfig{ + nad := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: v1.ObjectMeta{ Name: multusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(pkgconstant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, VlanID: ptr.To(int32(100)), }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodDefaultRouteNIC: &common.NIC2, }, }, diff --git a/test/e2e/ifacer/ifacer_suite_test.go b/test/e2e/ifacer/ifacer_suite_test.go index 42d4b8e2d3..156332996c 100644 --- a/test/e2e/ifacer/ifacer_suite_test.go +++ b/test/e2e/ifacer/ifacer_suite_test.go @@ -8,7 +8,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "k8s.io/apimachinery/pkg/runtime" ) diff --git a/test/e2e/ifacer/ifacer_test.go b/test/e2e/ifacer/ifacer_test.go index b0a4e1b5d9..6bc38de1f3 100644 --- a/test/e2e/ifacer/ifacer_test.go +++ b/test/e2e/ifacer/ifacer_test.go @@ -15,14 +15,14 @@ import ( "github.com/spidernet-io/e2eframework/tools" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" ) var _ = Describe("test ifacer", Label("ifacer"), func() { var namespace, dsName, spiderMultusNadName, mainInterface string var vlanInterface int - var spiderMultusConfig *spiderpoolv2beta1.SpiderMultusConfig + var spiderMultusConfig *spiderpoolv1.SpiderMultusConfig BeforeEach(func() { dsName = "ds-" + common.GenerateString(10, true) @@ -37,22 +37,22 @@ var _ = Describe("test ifacer", Label("ifacer"), func() { GinkgoWriter.Printf("create namespace %v. \n", namespace) Expect(err).NotTo(HaveOccurred()) - spiderMultusConfig = &spiderpoolv2beta1.SpiderMultusConfig{ + spiderMultusConfig = &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: spiderMultusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, VlanID: ptr.To(int32(vlanInterface)), - SpiderpoolConfigPools: &spiderpoolv2beta1.SpiderpoolPools{ + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{common.SpiderPoolIPv4PoolDefault}, IPv6IPPool: []string{common.SpiderPoolIPv6PoolDefault}, }, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{}, + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{}, }, } GinkgoWriter.Printf("Generate spiderMultusConfig %v \n", spiderMultusConfig) @@ -245,17 +245,17 @@ var _ = Describe("test ifacer", Label("ifacer"), func() { sameVlanInterface := 50 GinkgoWriter.Println("Generate vlan ID of sub-interface:", sameVlanInterface) newSpiderMultusNadName := "new-test-multus-" + common.GenerateString(10, true) - spiderMultusConfig = &spiderpoolv2beta1.SpiderMultusConfig{ + spiderMultusConfig = &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: newSpiderMultusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{mainInterface}, VlanID: ptr.To(int32(sameVlanInterface)), - SpiderpoolConfigPools: &spiderpoolv2beta1.SpiderpoolPools{ + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{common.SpiderPoolIPv4PoolDefault}, IPv6IPPool: []string{common.SpiderPoolIPv6PoolDefault}, }, diff --git a/test/e2e/ippoolcr/ippoolcr_suite_test.go b/test/e2e/ippoolcr/ippoolcr_suite_test.go index b1926f5da6..7202b403de 100644 --- a/test/e2e/ippoolcr/ippoolcr_suite_test.go +++ b/test/e2e/ippoolcr/ippoolcr_suite_test.go @@ -10,7 +10,7 @@ import ( e2e "github.com/spidernet-io/e2eframework/framework" "k8s.io/apimachinery/pkg/runtime" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) func TestIppoolCR(t *testing.T) { diff --git a/test/e2e/ippoolcr/ippoolcr_test.go b/test/e2e/ippoolcr/ippoolcr_test.go index 68726b9053..8d25c9628b 100644 --- a/test/e2e/ippoolcr/ippoolcr_test.go +++ b/test/e2e/ippoolcr/ippoolcr_test.go @@ -20,7 +20,7 @@ import ( "github.com/spidernet-io/e2eframework/tools" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -28,11 +28,11 @@ import ( var _ = Describe("test ippool CR", Label("ippoolCR"), func() { var nsName string var v4PoolName, v6PoolName, deployName string - var v4PoolObj, v6PoolObj *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj, v6PoolObj *spiderpoolv1.SpiderIPPool var v4PoolNameList, v6PoolNameList []string var disable = new(bool) var v4SubnetName, v6SubnetName string - var v4SubnetObject, v6SubnetObject *spiderpoolv2beta1.SpiderSubnet + var v4SubnetObject, v6SubnetObject *spiderpoolv1.SpiderSubnet BeforeEach(func() { // Init namespace name and create @@ -113,7 +113,7 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Context("test ippool CR", func() { var v4PoolName1, v6PoolName1 string - var v4PoolObj1, v6PoolObj1 *spiderpoolv2beta1.SpiderIPPool + var v4PoolObj1, v6PoolObj1 *spiderpoolv1.SpiderIPPool It("fails to append an ip that already exists in another ippool to the ippool", Label("D00001"), func() { @@ -213,7 +213,7 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { podName2 := "pod" + tools.RandomName() var v4Gateway, v6Gateway, v4Dst, v6Dst, v4Via, v6Via string var v4InvalidGateway, v6InvalidGateway string - var v4Pool, v6Pool *spiderpoolv2beta1.SpiderIPPool + var v4Pool, v6Pool *spiderpoolv1.SpiderIPPool // Generate Invalid Gateway and Dst v4InvalidGateway = common.GenerateRandomIPV4() @@ -247,11 +247,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Expect(err).NotTo(HaveOccurred()) v4Pool.Spec.Gateway = &v4InvalidGateway - route := spiderpoolv2beta1.Route{ + route := spiderpoolv1.Route{ Dst: v4Dst, Gw: v4Via, } - v4Pool.Spec.Routes = []spiderpoolv2beta1.Route{route} + v4Pool.Spec.Routes = []spiderpoolv1.Route{route} Expect(common.PatchIppool(frame, v4Pool, originalV4Pool)).NotTo(Succeed(), "error: we expect failed to update v4 ippool: %v with invalid gateway: %v, and valid route: %+v\n", v4PoolName, v4InvalidGateway, route) By("update v4 pool: valid `gateway` and invalid `route`") @@ -260,11 +260,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Expect(err).NotTo(HaveOccurred()) v4Pool.Spec.Gateway = &v4Gateway - route = spiderpoolv2beta1.Route{ + route = spiderpoolv1.Route{ Dst: v4Dst, Gw: v4InvalidGateway, } - v4Pool.Spec.Routes = []spiderpoolv2beta1.Route{route} + v4Pool.Spec.Routes = []spiderpoolv1.Route{route} Expect(common.PatchIppool(frame, v4Pool, originalV4Pool)).NotTo(Succeed(), "error: we expect failed to update v4 ippool: %v with valid gateway: %v, and invalid route: %+v\n", v4PoolName, v4InvalidGateway, route) By("update v4 pool: valid `gateway` and `route`") @@ -273,11 +273,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Expect(err).NotTo(HaveOccurred()) v4Pool.Spec.Gateway = &v4Gateway - route = spiderpoolv2beta1.Route{ + route = spiderpoolv1.Route{ Dst: v4Dst, Gw: v4Via, } - v4Pool.Spec.Routes = []spiderpoolv2beta1.Route{route} + v4Pool.Spec.Routes = []spiderpoolv1.Route{route} Expect(common.PatchIppool(frame, v4Pool, originalV4Pool)).To(Succeed(), "failed to update v4 ippool: %v with valid gateway: %v, and route: %+v\n", v4PoolName, v4Gateway, route) } if frame.Info.IpV6Enabled { @@ -289,11 +289,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Expect(err).NotTo(HaveOccurred()) v6Pool.Spec.Gateway = &v6InvalidGateway - route := spiderpoolv2beta1.Route{ + route := spiderpoolv1.Route{ Dst: v6Dst, Gw: v6Via, } - v6Pool.Spec.Routes = []spiderpoolv2beta1.Route{route} + v6Pool.Spec.Routes = []spiderpoolv1.Route{route} Expect(common.PatchIppool(frame, v6Pool, originalV6Pool)).NotTo(Succeed(), "error: we expect failed to update v6 ippool: %v with invalid gateway: %v, and valid route: %+v\n", v6PoolName, v6InvalidGateway, route) By("update v6 pool: valid `gateway` and invalid `route`") @@ -302,11 +302,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Expect(err).NotTo(HaveOccurred()) v6Pool.Spec.Gateway = &v6Gateway - route = spiderpoolv2beta1.Route{ + route = spiderpoolv1.Route{ Dst: v6Dst, Gw: v6InvalidGateway, } - v6Pool.Spec.Routes = []spiderpoolv2beta1.Route{route} + v6Pool.Spec.Routes = []spiderpoolv1.Route{route} Expect(common.PatchIppool(frame, v6Pool, originalV6Pool)).NotTo(Succeed(), "error: we expect failed to update v6 ippool: %v with valid gateway: %v, and invalid route: %+v\n", v6PoolName, v6InvalidGateway, route) By("update v6 pool: valid `gateway` and `route`") @@ -315,11 +315,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Expect(err).NotTo(HaveOccurred()) v6Pool.Spec.Gateway = &v6Gateway - route = spiderpoolv2beta1.Route{ + route = spiderpoolv1.Route{ Dst: v6Dst, Gw: v6Via, } - v6Pool.Spec.Routes = []spiderpoolv2beta1.Route{route} + v6Pool.Spec.Routes = []spiderpoolv1.Route{route} Expect(common.PatchIppool(frame, v6Pool, originalV6Pool)).To(Succeed(), "failed to update v6 ippool: %v with valid gateway: %v, and route: %+v\n", v6PoolName, v6Gateway, route) } @@ -579,10 +579,10 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Context("Test multusName affinity", Label("multusName"), func() { var namespace, v4PoolName, v6PoolName, dsName, spiderMultusNadName string - var iPv4PoolObj, iPv6PoolObj *spiderpoolv2beta1.SpiderIPPool + var iPv4PoolObj, iPv6PoolObj *spiderpoolv1.SpiderIPPool var v4SubnetName, v6SubnetName string - var v4SubnetObject, v6SubnetObject *spiderpoolv2beta1.SpiderSubnet - var spiderMultusConfig *spiderpoolv2beta1.SpiderMultusConfig + var v4SubnetObject, v6SubnetObject *spiderpoolv1.SpiderSubnet + var spiderMultusConfig *spiderpoolv1.SpiderMultusConfig BeforeEach(func() { dsName = "ds-" + common.GenerateString(10, true) @@ -639,21 +639,21 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { return nil }).WithTimeout(time.Minute).WithPolling(time.Second * 3).Should(BeNil()) - spiderMultusConfig = &spiderpoolv2beta1.SpiderMultusConfig{ + spiderMultusConfig = &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: spiderMultusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, - SpiderpoolConfigPools: &spiderpoolv2beta1.SpiderpoolPools{ + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{v4PoolName}, IPv6IPPool: []string{v6PoolName}, }, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{}, + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{}, }, } GinkgoWriter.Printf("Generate spiderMultusConfig %v \n", spiderMultusConfig) @@ -828,9 +828,9 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { // 4. The Pod is scheduled to a node that does not have affinity with IPPool, and the Pod cannot run. Context("Test nodeName affinity", func() { var namespace, v4PoolName, v6PoolName, dsName string - var iPv4PoolObj, iPv6PoolObj *spiderpoolv2beta1.SpiderIPPool + var iPv4PoolObj, iPv6PoolObj *spiderpoolv1.SpiderIPPool var v4SubnetName, v6SubnetName string - var v4SubnetObject, v6SubnetObject *spiderpoolv2beta1.SpiderSubnet + var v4SubnetObject, v6SubnetObject *spiderpoolv1.SpiderSubnet var nodeNameMatchedNode, nodeAffinityMatchedNode *corev1.Node var podAnnoMarshalString string @@ -1001,16 +1001,16 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { subnet := "172.16.0.0/16" ips := "172.16.0.2" gateway := "172.16.0.1" - route := spiderpoolv2beta1.Route{ + route := spiderpoolv1.Route{ Dst: "172.17.0.0/16", Gw: "172.16.41.1", } - demoSpiderIPPool := &spiderpoolv2beta1.SpiderIPPool{ + demoSpiderIPPool := &spiderpoolv1.SpiderIPPool{ ObjectMeta: metav1.ObjectMeta{ Name: poolName, }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv4), Subnet: subnet, IPs: []string{ips}, @@ -1021,16 +1021,16 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { Expect(err).NotTo(HaveOccurred()) time.Sleep(time.Second * 5) - demoSpiderSubnet := &spiderpoolv2beta1.SpiderSubnet{ + demoSpiderSubnet := &spiderpoolv1.SpiderSubnet{ ObjectMeta: metav1.ObjectMeta{ Name: subnetName, }, - Spec: spiderpoolv2beta1.SubnetSpec{ + Spec: spiderpoolv1.SubnetSpec{ IPVersion: ptr.To(constant.IPv4), Subnet: subnet, IPs: []string{ips}, Gateway: ptr.To(gateway), - Routes: []spiderpoolv2beta1.Route{route}, + Routes: []spiderpoolv1.Route{route}, }, } GinkgoWriter.Printf("Generate SpiderSubnet %s, try to create it\n", demoSpiderSubnet.String()) @@ -1076,21 +1076,21 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { subnet := "fd00:172:16::/64" ips := "fd00:172:16::2" gateway := "fd00:172:16::1" - route := spiderpoolv2beta1.Route{ + route := spiderpoolv1.Route{ Dst: "fd00:172:17::/64", Gw: "fd00:172:16::100", } - demoSpiderSubnet := &spiderpoolv2beta1.SpiderSubnet{ + demoSpiderSubnet := &spiderpoolv1.SpiderSubnet{ ObjectMeta: metav1.ObjectMeta{ Name: subnetName, }, - Spec: spiderpoolv2beta1.SubnetSpec{ + Spec: spiderpoolv1.SubnetSpec{ IPVersion: ptr.To(constant.IPv6), Subnet: subnet, IPs: []string{ips}, Gateway: ptr.To(gateway), - Routes: []spiderpoolv2beta1.Route{route}, + Routes: []spiderpoolv1.Route{route}, }, } GinkgoWriter.Printf("Generate SpiderSubnet %s, try to create it\n", demoSpiderSubnet.String()) @@ -1103,11 +1103,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { } time.Sleep(time.Second * 5) - demoSpiderIPPool := &spiderpoolv2beta1.SpiderIPPool{ + demoSpiderIPPool := &spiderpoolv1.SpiderIPPool{ ObjectMeta: metav1.ObjectMeta{ Name: poolName, }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv6), Subnet: subnet, IPs: []string{ips}, @@ -1145,11 +1145,11 @@ var _ = Describe("test ippool CR", Label("ippoolCR"), func() { if frame.Info.IpV6Enabled { poolName := "large-ipv6-pool" - pool := &spiderpoolv2beta1.SpiderIPPool{ + pool := &spiderpoolv1.SpiderIPPool{ ObjectMeta: metav1.ObjectMeta{ Name: poolName, }, - Spec: spiderpoolv2beta1.IPPoolSpec{ + Spec: spiderpoolv1.IPPoolSpec{ IPVersion: ptr.To(constant.IPv6), Subnet: "fd12:3456:789a::/48", IPs: []string{"fd12:3456:789a:baba::1-fd12:3456:789a:ffff:ffff:ffff:ffff:ffff"}, diff --git a/test/e2e/kruise/kruise_suite_test.go b/test/e2e/kruise/kruise_suite_test.go index 9a75824f7b..f621a17782 100644 --- a/test/e2e/kruise/kruise_suite_test.go +++ b/test/e2e/kruise/kruise_suite_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/gomega" kruiseapi "github.com/openkruise/kruise-api" e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "k8s.io/apimachinery/pkg/runtime" ) diff --git a/test/e2e/kruise/kruise_test.go b/test/e2e/kruise/kruise_test.go index 873574f388..226ee602d1 100644 --- a/test/e2e/kruise/kruise_test.go +++ b/test/e2e/kruise/kruise_test.go @@ -12,7 +12,7 @@ import ( "github.com/spidernet-io/e2eframework/tools" "github.com/spidernet-io/spiderpool/pkg/constant" pkgconstant "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/test/e2e/common" corev1 "k8s.io/api/core/v1" @@ -103,7 +103,7 @@ var _ = Describe("Third party control: OpenKruise", Label("kruise"), func() { Context("SpiderSubnet feature supports third party controllers.", func() { var v4SubnetName, v6SubnetName string - var v4SubnetObject, v6SubnetObject *spiderpoolv2beta1.SpiderSubnet + var v4SubnetObject, v6SubnetObject *spiderpoolv1.SpiderSubnet var ( replicasNum int32 = 1 diff --git a/test/e2e/kubevirt/kubevirt_suite_test.go b/test/e2e/kubevirt/kubevirt_suite_test.go index fab12223c3..9f0ce8d5f1 100644 --- a/test/e2e/kubevirt/kubevirt_suite_test.go +++ b/test/e2e/kubevirt/kubevirt_suite_test.go @@ -17,7 +17,7 @@ import ( kubevirtv1 "kubevirt.io/api/core/v1" k8yaml "sigs.k8s.io/yaml" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -44,7 +44,7 @@ var _ = BeforeSuite(func() { } var err error - frame, err = e2e.NewFramework(GinkgoT(), []func(*runtime.Scheme) error{spiderpoolv2beta1.AddToScheme, kubevirtv1.AddToScheme}) + frame, err = e2e.NewFramework(GinkgoT(), []func(*runtime.Scheme) error{spiderpoolv1.AddToScheme, kubevirtv1.AddToScheme}) Expect(err).NotTo(HaveOccurred()) // make sure we have macvlan net-attach-def resource @@ -116,8 +116,8 @@ func readTestVMTemplate() { Expect(err).NotTo(HaveOccurred()) } -func getSpiderIPPoolByName(name string) (*spiderpoolv2beta1.SpiderIPPool, error) { - var pool spiderpoolv2beta1.SpiderIPPool +func getSpiderIPPoolByName(name string) (*spiderpoolv1.SpiderIPPool, error) { + var pool spiderpoolv1.SpiderIPPool err := frame.GetResource(types.NamespacedName{ Name: name, }, &pool) diff --git a/test/e2e/kubevirt/kubevirt_test.go b/test/e2e/kubevirt/kubevirt_test.go index 2e6991fe74..73f864f64c 100644 --- a/test/e2e/kubevirt/kubevirt_test.go +++ b/test/e2e/kubevirt/kubevirt_test.go @@ -20,7 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -256,7 +256,7 @@ var _ = Describe("test kubevirt", Label("kubevirt"), func() { GinkgoWriter.Printf("kubevirt VMI '%s/%s' is ready, try to check its IP allocations", vmi.Namespace, vmi.Name) // 3. check the SpiderEndpoint resource IP allocations - var endpoint spiderpoolv2beta1.SpiderEndpoint + var endpoint spiderpoolv1.SpiderEndpoint err = frame.KClient.Get(ctx, types.NamespacedName{ Namespace: vmi.Namespace, Name: vmi.Name, diff --git a/test/e2e/performance/performance_suite_test.go b/test/e2e/performance/performance_suite_test.go index 40800d4692..573249f059 100644 --- a/test/e2e/performance/performance_suite_test.go +++ b/test/e2e/performance/performance_suite_test.go @@ -10,7 +10,7 @@ import ( e2e "github.com/spidernet-io/e2eframework/framework" "k8s.io/apimachinery/pkg/runtime" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) func TestPerformance(t *testing.T) { diff --git a/test/e2e/performance/performance_test.go b/test/e2e/performance/performance_test.go index 6bcb7967d3..c1aee99283 100644 --- a/test/e2e/performance/performance_test.go +++ b/test/e2e/performance/performance_test.go @@ -7,7 +7,7 @@ import ( "fmt" "time" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -24,7 +24,7 @@ var _ = Describe("performance test case", Serial, Label("performance"), func() { err error dpm *appsv1.Deployment podlist *corev1.PodList - iPv4PoolObj, iPv6PoolObj *spiderpoolv2beta1.SpiderIPPool + iPv4PoolObj, iPv6PoolObj *spiderpoolv1.SpiderIPPool v4PoolNameList, v6PoolNameList []string ) BeforeEach(func() { diff --git a/test/e2e/podwebhook/podwebhook_suite_test.go b/test/e2e/podwebhook/podwebhook_suite_test.go index bcae769fc7..09283a150a 100644 --- a/test/e2e/podwebhook/podwebhook_suite_test.go +++ b/test/e2e/podwebhook/podwebhook_suite_test.go @@ -10,7 +10,7 @@ import ( . "github.com/onsi/gomega" e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "k8s.io/apimachinery/pkg/runtime" ) diff --git a/test/e2e/podwebhook/podwebhook_test.go b/test/e2e/podwebhook/podwebhook_test.go index eb9a8ec018..faf2c03817 100644 --- a/test/e2e/podwebhook/podwebhook_test.go +++ b/test/e2e/podwebhook/podwebhook_test.go @@ -10,7 +10,7 @@ import ( . "github.com/onsi/gomega" "github.com/spidernet-io/spiderpool/pkg/constant" - "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + v2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -53,7 +53,6 @@ var _ = Describe("Podwebhook", func() { CniType: ptr.To(constant.MacvlanCNI), MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, - EnableRdma: true, RdmaResourceName: "spidernet.io/rdma_resource" + "_" + name, SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ IPv4IPPool: []string{"test-ipv4-pool"}, diff --git a/test/e2e/reclaim/chaos_test.go b/test/e2e/reclaim/chaos_test.go index 5f49fda47d..151fd18a3d 100644 --- a/test/e2e/reclaim/chaos_test.go +++ b/test/e2e/reclaim/chaos_test.go @@ -18,7 +18,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" corev1 "k8s.io/api/core/v1" "k8s.io/kubectl/pkg/util/podutils" diff --git a/test/e2e/reclaim/reclaim_suite_test.go b/test/e2e/reclaim/reclaim_suite_test.go index 40fb0352d7..0caedea747 100644 --- a/test/e2e/reclaim/reclaim_suite_test.go +++ b/test/e2e/reclaim/reclaim_suite_test.go @@ -5,7 +5,7 @@ package reclaim_test import ( "testing" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/test/e2e/reclaim/reclaim_test.go b/test/e2e/reclaim/reclaim_test.go index dff308e431..d2dcf274e5 100644 --- a/test/e2e/reclaim/reclaim_test.go +++ b/test/e2e/reclaim/reclaim_test.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/nodemanager" "github.com/spidernet-io/spiderpool/pkg/openapi" "github.com/spidernet-io/spiderpool/pkg/utils/convert" diff --git a/test/e2e/reliability/reliability_suite_test.go b/test/e2e/reliability/reliability_suite_test.go index c0b74fae67..b9f59a88c7 100644 --- a/test/e2e/reliability/reliability_suite_test.go +++ b/test/e2e/reliability/reliability_suite_test.go @@ -6,7 +6,7 @@ import ( "testing" e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "k8s.io/apimachinery/pkg/runtime" . "github.com/onsi/ginkgo/v2" diff --git a/test/e2e/reservedip/reservedip_suite_test.go b/test/e2e/reservedip/reservedip_suite_test.go index 1a257227be..a7bc670604 100644 --- a/test/e2e/reservedip/reservedip_suite_test.go +++ b/test/e2e/reservedip/reservedip_suite_test.go @@ -5,7 +5,7 @@ package reservedip_test import ( "testing" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/test/e2e/reservedip/reservedip_test.go b/test/e2e/reservedip/reservedip_test.go index 4e914f953e..e2c268973d 100644 --- a/test/e2e/reservedip/reservedip_test.go +++ b/test/e2e/reservedip/reservedip_test.go @@ -7,7 +7,7 @@ import ( "encoding/json" "time" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "sigs.k8s.io/controller-runtime/pkg/client" . "github.com/onsi/ginkgo/v2" @@ -21,11 +21,11 @@ import ( var _ = Describe("test reservedIP", Label("reservedIP"), func() { var nsName, manualDeployName, autoDeployName, v4PoolName, v6PoolName, v4ReservedIpName, v6ReservedIpName string var v4PoolNameList, v6PoolNameList []string - var iPv4PoolObj, iPv6PoolObj *spiderpoolv2beta1.SpiderIPPool - var v4ReservedIpObj, v6ReservedIpObj *spiderpoolv2beta1.SpiderReservedIP + var iPv4PoolObj, iPv6PoolObj *spiderpoolv1.SpiderIPPool + var v4ReservedIpObj, v6ReservedIpObj *spiderpoolv1.SpiderReservedIP var err error var v4SubnetName, v6SubnetName string - var v4SubnetObject, v6SubnetObject *spiderpoolv2beta1.SpiderSubnet + var v4SubnetObject, v6SubnetObject *spiderpoolv1.SpiderSubnet BeforeEach(func() { if frame.Info.SpiderSubnetEnabled { diff --git a/test/e2e/spiderclaimparameter/spiderclaimparameter_suite_test.go b/test/e2e/spiderclaimparameter/spiderclaimparameter_suite_test.go deleted file mode 100644 index aca4fe1d73..0000000000 --- a/test/e2e/spiderclaimparameter/spiderclaimparameter_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2024 Authors of spidernet-io -// SPDX-License-Identifier: Apache-2.0 -package spiderclaimparameter_test - -import ( - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - e2e "github.com/spidernet-io/e2eframework/framework" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" - "github.com/spidernet-io/spiderpool/test/e2e/common" - "k8s.io/api/resource/v1alpha2" - - "k8s.io/apimachinery/pkg/runtime" -) - -func TestSpiderclaimparameter(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Spiderclaimparameter Suite") -} - -var frame *e2e.Framework - -var _ = BeforeSuite(func() { - if !common.IsDRAEnabled() { - GinkgoWriter.Println("DRA feature is disabled. Skip") - Skip("DRA feature is disabled. Skip") - } - - defer GinkgoRecover() - var e error - frame, e = e2e.NewFramework(GinkgoT(), []func(*runtime.Scheme) error{spiderpool.AddToScheme, v1alpha2.AddToScheme}) - Expect(e).NotTo(HaveOccurred()) -}) diff --git a/test/e2e/spiderclaimparameter/spiderclaimparameter_test.go b/test/e2e/spiderclaimparameter/spiderclaimparameter_test.go deleted file mode 100644 index f6c5b78f3c..0000000000 --- a/test/e2e/spiderclaimparameter/spiderclaimparameter_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2024 Authors of spidernet-io -// SPDX-License-Identifier: Apache-2.0 -package spiderclaimparameter_test - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/spidernet-io/spiderpool/pkg/constant" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" - "github.com/spidernet-io/spiderpool/test/e2e/common" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" -) - -var _ = Describe("Spiderclaimparameter", Label("SpiderClaimParameter"), func() { - Context("Test Spiderclaimparameter", func() { - var namespace, multusNadName, spiderClaimName string - - BeforeEach(func() { - // generate some test data - namespace = "ns-" + common.GenerateString(10, true) - multusNadName = "test-multus-" + common.GenerateString(10, true) - spiderClaimName = "spc-" + common.GenerateString(10, true) - - // create namespace and ippool - err := frame.CreateNamespaceUntilDefaultServiceAccountReady(namespace, common.ServiceAccountReadyTimeout) - Expect(err).NotTo(HaveOccurred()) - - DeferCleanup(func() { - GinkgoWriter.Printf("delete spiderMultusConfig %v/%v. \n", namespace, multusNadName) - Expect(frame.DeleteSpiderMultusInstance(namespace, multusNadName)).NotTo(HaveOccurred()) - - GinkgoWriter.Printf("delete namespace %v. \n", namespace) - Expect(frame.DeleteNamespace(namespace)).NotTo(HaveOccurred()) - - //Expect( - // common.DeleteSpiderClaimParameter(frame, spiderClaimName, namespace), - //).NotTo(HaveOccurred()) - }) - }) - - It(("test create spiderclaimparameter"), Label("Y00001"), func() { - // Define multus cni NetworkAttachmentDefinition and create - nad := &spiderpoolv2beta1.SpiderMultusConfig{ - ObjectMeta: metav1.ObjectMeta{ - Name: multusNadName, - Namespace: namespace, - }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ - CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ - Master: []string{common.NIC1}, - VlanID: ptr.To(int32(100)), - }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ - PodDefaultRouteNIC: &common.NIC2, - }, - }, - } - Expect(frame.CreateSpiderMultusInstance(nad)).NotTo(HaveOccurred()) - - defer func() { - Expect(frame.DeleteSpiderMultusInstance(namespace, multusNadName)).NotTo(HaveOccurred()) - }() - - Expect(common.CreateSpiderClaimParameter(frame, &spiderpoolv2beta1.SpiderClaimParameter{ - ObjectMeta: metav1.ObjectMeta{ - Name: spiderClaimName, - Namespace: namespace, - // kind k8s v1.29.0 -> use containerd v1.7.1 -> use cdi version(v0.5.4) - // v0.5.4 don't support CDISpec version 0.6.0, so update the cdi version - // by the annotation - Annotations: map[string]string{ - constant.AnnoDraCdiVersion: "0.5.0", - }, - }, - Spec: spiderpoolv2beta1.ClaimParameterSpec{ - // RdmaAcc: true, - SecondaryNics: []spiderpoolv2beta1.MultusConfig{{ - MultusName: multusNadName, - Namespace: namespace, - }, - }}, - })).NotTo(HaveOccurred()) - }) - - It(("test create spiderclaimparameter for empty staticNics"), Label("Y00002"), func() { - // Define multus cni NetworkAttachmentDefinition and create - nad := &spiderpoolv2beta1.SpiderMultusConfig{ - ObjectMeta: metav1.ObjectMeta{ - Name: multusNadName, - Namespace: namespace, - }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ - CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ - Master: []string{common.NIC1}, - VlanID: ptr.To(int32(100)), - }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ - PodDefaultRouteNIC: &common.NIC2, - }, - }, - } - Expect(frame.CreateSpiderMultusInstance(nad)).NotTo(HaveOccurred()) - - defer func() { - Expect(frame.DeleteSpiderMultusInstance(namespace, multusNadName)).NotTo(HaveOccurred()) - }() - - err := common.CreateSpiderClaimParameter(frame, &spiderpoolv2beta1.SpiderClaimParameter{ - ObjectMeta: metav1.ObjectMeta{ - Name: spiderClaimName, - Namespace: namespace, - // kind k8s v1.29.0 -> use containerd v1.7.1 -> use cdi version(v0.5.4) - // v0.5.4 don't support CDISpec version 0.6.0, so update the cdi version - // by the annotation - Annotations: map[string]string{ - constant.AnnoDraCdiVersion: "0.5.0", - }, - }, - Spec: spiderpoolv2beta1.ClaimParameterSpec{ - // RdmaAcc: true, - SecondaryNics: []spiderpoolv2beta1.MultusConfig{{ - MultusName: multusNadName, - Namespace: namespace, - }, - }}, - }) - - Expect(err).To(HaveOccurred(), "expect err: %v", err) - }) - - It(("test create spiderclaimparameter for no found spiderMultusConfig"), func() { - err := common.CreateSpiderClaimParameter(frame, &spiderpoolv2beta1.SpiderClaimParameter{ - ObjectMeta: metav1.ObjectMeta{ - Name: spiderClaimName, - Namespace: namespace, - // kind k8s v1.29.0 -> use containerd v1.7.1 -> use cdi version(v0.5.4) - // v0.5.4 don't support CDISpec version 0.6.0, so update the cdi version - // by the annotation - Annotations: map[string]string{ - constant.AnnoDraCdiVersion: "0.5.0", - }, - }, - Spec: spiderpoolv2beta1.ClaimParameterSpec{ - // RdmaAcc: true, - SecondaryNics: []spiderpoolv2beta1.MultusConfig{{ - MultusName: multusNadName, - Namespace: namespace, - }, - }}, - }) - - Expect(err).To(HaveOccurred(), "expect err: %v", err) - }) - }) -}) diff --git a/test/e2e/spidercoordinator/spidercoordinator_suite_test.go b/test/e2e/spidercoordinator/spidercoordinator_suite_test.go index 4778a89c21..8374cb4c00 100644 --- a/test/e2e/spidercoordinator/spidercoordinator_suite_test.go +++ b/test/e2e/spidercoordinator/spidercoordinator_suite_test.go @@ -15,7 +15,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -39,7 +39,7 @@ var v4PodCIDRString, v6PodCIDRString string var _ = BeforeSuite(func() { defer GinkgoRecover() var e error - frame, e = e2e.NewFramework(GinkgoT(), []func(*runtime.Scheme) error{spiderpoolv2beta1.AddToScheme, networkingv1.AddToScheme}) + frame, e = e2e.NewFramework(GinkgoT(), []func(*runtime.Scheme) error{spiderpoolv1.AddToScheme, networkingv1.AddToScheme}) Expect(e).NotTo(HaveOccurred()) if !common.CheckRunOverlayCNI() && !common.CheckCalicoFeatureOn() && !common.CheckCiliumFeatureOn() { @@ -73,8 +73,8 @@ var _ = BeforeSuite(func() { } }) -func GetSpiderCoordinator(name string) (*spiderpoolv2beta1.SpiderCoordinator, error) { - var spc spiderpoolv2beta1.SpiderCoordinator +func GetSpiderCoordinator(name string) (*spiderpoolv1.SpiderCoordinator, error) { + var spc spiderpoolv1.SpiderCoordinator err := frame.GetResource(types.NamespacedName{ Name: name, }, &spc) @@ -85,7 +85,7 @@ func GetSpiderCoordinator(name string) (*spiderpoolv2beta1.SpiderCoordinator, er return &spc, nil } -func PatchSpiderCoordinator(desired, original *spiderpoolv2beta1.SpiderCoordinator, opts ...client.PatchOption) error { +func PatchSpiderCoordinator(desired, original *spiderpoolv1.SpiderCoordinator, opts ...client.PatchOption) error { mergePatch := client.MergeFrom(original) d, err := mergePatch.Data(desired) diff --git a/test/e2e/spidercoordinator/spidercoordinator_test.go b/test/e2e/spidercoordinator/spidercoordinator_test.go index a36818310b..52960677bf 100644 --- a/test/e2e/spidercoordinator/spidercoordinator_test.go +++ b/test/e2e/spidercoordinator/spidercoordinator_test.go @@ -18,7 +18,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/coordinatormanager" "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -384,7 +384,7 @@ var _ = Describe("SpiderCoordinator", Label("spidercoordinator", "overlay"), Ser Context("It can get the clusterCIDR from kubeadmConfig and kube-controller-manager pod", func() { - var spc *spiderpoolv2beta1.SpiderCoordinator + var spc *spiderpoolv1.SpiderCoordinator var cm *corev1.ConfigMap var masterNode string var err error @@ -631,7 +631,7 @@ var _ = Describe("SpiderCoordinator", Label("spidercoordinator", "overlay"), Ser }) Context("It can get service cidr from k8s serviceCIDR resources", Label("V00010"), func() { - var spc *spiderpoolv2beta1.SpiderCoordinator + var spc *spiderpoolv1.SpiderCoordinator var err error BeforeEach(func() { // serviceCIDR feature is available in k8s v1.29, DO NOT RUN this case diff --git a/test/e2e/spidermultus/spidermultus_suite_test.go b/test/e2e/spidermultus/spidermultus_suite_test.go index 21e9eada8a..b4de6f80ea 100644 --- a/test/e2e/spidermultus/spidermultus_suite_test.go +++ b/test/e2e/spidermultus/spidermultus_suite_test.go @@ -10,7 +10,7 @@ import ( e2e "github.com/spidernet-io/e2eframework/framework" "k8s.io/apimachinery/pkg/runtime" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" ) func TestSpiderMultus(t *testing.T) { diff --git a/test/e2e/spidermultus/spidermultus_test.go b/test/e2e/spidermultus/spidermultus_test.go index 07a2c0728f..6808bfb1b9 100644 --- a/test/e2e/spidermultus/spidermultus_test.go +++ b/test/e2e/spidermultus/spidermultus_test.go @@ -23,8 +23,7 @@ import ( "k8s.io/utils/ptr" "github.com/spidernet-io/spiderpool/pkg/constant" - "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" - spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpoolv1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/test/e2e/common" ) @@ -57,17 +56,17 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { podCidrType = "cluster" // Define multus cni NetworkAttachmentDefinition and create - nad := &spiderpoolv2beta1.SpiderMultusConfig{ + nad := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: spiderMultusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ Mode: &mode, // mode = "disabled" PodCIDRType: &podCidrType, }, @@ -129,24 +128,24 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { Context("Change multus attributes via spidermultus annotation", func() { var spiderMultusNadName, mode string - var smc *spiderpoolv2beta1.SpiderMultusConfig + var smc *spiderpoolv1.SpiderMultusConfig BeforeEach(func() { spiderMultusNadName = "test-multus-" + common.GenerateString(10, true) mode = "disabled" // Define spidermultus cr and create - smc = &spiderpoolv2beta1.SpiderMultusConfig{ + smc = &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: spiderMultusNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ Mode: &mode, }, }, @@ -329,14 +328,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { Expect(err).NotTo(HaveOccurred()) // Define spidermultus cr and create - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: alreadyExistingNadName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, }, @@ -366,14 +365,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { var smcName string = "multus-" + common.GenerateString(10, true) // Define Spidermultus cr where cniType does not agree with cniConf and create. - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.IPVlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, }, @@ -388,14 +387,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { var smcName string = "multus-" + common.GenerateString(10, true) // Define Spidermultus cr with vlanID -1 - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, VlanID: ptr.To(int32(-1)), }, @@ -407,14 +406,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { Expect(err).To(HaveOccurred()) // Define Spidermultus cr with vlanID 4095 - smc = &spiderpoolv2beta1.SpiderMultusConfig{ + smc = &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, VlanID: ptr.To(int32(4095)), }, @@ -430,14 +429,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { var smcName string = "ipvlan-" + common.GenerateString(10, true) // Define Spidermultus cr with ipvlan - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.IPVlanCNI), - IPVlanConfig: &spiderpoolv2beta1.SpiderIPvlanCniConfig{ + IPVlanConfig: &spiderpoolv1.SpiderIPvlanCniConfig{ Master: []string{common.NIC3}, }, }, @@ -463,14 +462,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { var smcName string = "sriov-" + common.GenerateString(10, true) // Define Spidermultus cr with sriov - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.SriovCNI), - SriovConfig: &spiderpoolv2beta1.SpiderSRIOVCniConfig{ + SriovConfig: &spiderpoolv1.SpiderSRIOVCniConfig{ ResourceName: "sriov-test", }, }, @@ -497,12 +496,12 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { invalidJson := `{ "invalid" }` // Define Spidermultus cr with invalid json config - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: v2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.CustomCNI), CustomCNIConfig: &invalidJson, }, @@ -538,16 +537,16 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("set sriov.enableRdma to true and see if multus's nad has rdma config", Label("M00018"), func() { var smcName string = "enable-radm-" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.SriovCNI), - SriovConfig: &spiderpoolv2beta1.SpiderSRIOVCniConfig{ - ResourceName: "spidernet.io/mellanoxrdma", - EnableRdma: true, + SriovConfig: &spiderpoolv1.SpiderSRIOVCniConfig{ + ResourceName: "spidernet.io/mellanoxrdma", + RdmaIsolation: true, }, }, } @@ -580,7 +579,7 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("set spidermultusconfig.spec to empty and see if works", Label("M00019"), func() { smcName := "test-multus-" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, @@ -604,14 +603,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("Update spidermultusConfig: add new bond config", Label("M00009", "M00006"), func() { smcName := "test-multus-" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{"eth0"}, }, EnableCoordinator: ptr.To(false), @@ -646,10 +645,10 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { }).WithTimeout(time.Minute * 2).WithPolling(time.Second * 5).Should(BeNil()) // update the SpiderMultusConfig with bond - smc.Spec.MacvlanConfig = &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + smc.Spec.MacvlanConfig = &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{"eth0", "eth1"}, VlanID: ptr.To(int32(10)), - Bond: &spiderpoolv2beta1.BondConfig{ + Bond: &spiderpoolv1.BondConfig{ Name: "ens1", Mode: 0, }, @@ -689,20 +688,19 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("test hostRPFilter and podRPFilter in spiderMultusConfig", Label("M00022"), func() { var smcName string = "rpfilter-multus-" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ - HostRPFilter: nil, - PodRPFilter: nil, + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ + PodRPFilter: nil, }, }, } @@ -742,20 +740,19 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("set hostRPFilter and podRPFilter to a invalid value", Label("M00023"), func() { var smcName string = "invalid-rpfilter-multus-" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ - HostRPFilter: ptr.To(14), - PodRPFilter: nil, + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ + PodRPFilter: nil, }, }, } @@ -766,7 +763,7 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("rdma must be enabled and ippools config must be set when spidermutlus with annotation: cni.spidernet.io/rdma-resource-inject", Label("M00027"), func() { var smcName string = "ann-rdma-resource" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, @@ -774,18 +771,17 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { constant.AnnoPodResourceInject: "test", }, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, - EnableRdma: true, RdmaResourceName: "test", - SpiderpoolConfigPools: &spiderpoolv2beta1.SpiderpoolPools{ + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, }, }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodRPFilter: nil, }, }, @@ -797,7 +793,7 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("return an err if rdma is not enabled when spidermutlus with annotation: cni.spidernet.io/rdma-resource-inject", Label("M00028"), func() { var smcName string = "ann-rdma-resource" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, @@ -805,18 +801,17 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { constant.AnnoPodResourceInject: "test", }, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, - EnableRdma: false, - RdmaResourceName: "test", - SpiderpoolConfigPools: &spiderpoolv2beta1.SpiderpoolPools{ + RdmaResourceName: "", + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{"test"}, }, }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodRPFilter: nil, }, }, @@ -828,7 +823,7 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("return an err if no ippools config when spidermutlus with annotation: cni.spidernet.io/rdma-resource-inject", Label("M00029"), func() { var smcName string = "ann-rdma-resource" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, @@ -836,15 +831,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { constant.AnnoPodResourceInject: "test", }, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, - EnableRdma: true, RdmaResourceName: "test", }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodRPFilter: nil, }, }, @@ -856,7 +850,7 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("return an err if cniType is not in [macvlan,ipvlan,sriov,ib-sriov,ipoib] when spidermutlus with annotation: cni.spidernet.io/rdma-resource-inject", Label("M00030"), func() { var smcName string = "ann-rdma-resource" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, @@ -864,14 +858,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { constant.AnnoPodResourceInject: "test", }, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.OvsCNI), - OvsConfig: &spiderpoolv2beta1.SpiderOvsCniConfig{ + OvsConfig: &spiderpoolv1.SpiderOvsCniConfig{ BrName: "test", DeviceID: "test", }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodRPFilter: nil, }, }, @@ -885,14 +879,14 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { var smcName string = "disable-ipam-multus-" + common.GenerateString(10, true) // Define Spidermultus cr with DisableIPAM=true - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &spiderpoolv2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{common.NIC1}, }, DisableIPAM: ptr.To(true), @@ -937,16 +931,16 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { invalidJson := `{ "invalid" }` // Define Spidermultus cr with invalid json config - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: v2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{"eth0"}, - SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{"spiderpool-ipv4-ippool"}, }, }, @@ -1062,21 +1056,21 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { It("verify the podMACPrefix filed", Label("M00024"), func() { smcName := "test-multus-" + common.GenerateString(10, true) - smc := &spiderpoolv2beta1.SpiderMultusConfig{ + smc := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: smcName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{"eth0"}, - SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{"spiderpool-ipv4-ippool"}, }, }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodMACPrefix: ptr.To("9e:10"), }, }, @@ -1087,21 +1081,21 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() { Expect(err).NotTo(HaveOccurred()) tmpName := "invalid-macprefix" + common.GenerateString(10, true) - invalid := &spiderpoolv2beta1.SpiderMultusConfig{ + invalid := &spiderpoolv1.SpiderMultusConfig{ ObjectMeta: metav1.ObjectMeta{ Name: tmpName, Namespace: namespace, }, - Spec: spiderpoolv2beta1.MultusCNIConfigSpec{ + Spec: spiderpoolv1.MultusCNIConfigSpec{ CniType: ptr.To(constant.MacvlanCNI), - MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{ + MacvlanConfig: &spiderpoolv1.SpiderMacvlanCniConfig{ Master: []string{"eth0"}, - SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{ + SpiderpoolConfigPools: &spiderpoolv1.SpiderpoolPools{ IPv4IPPool: []string{"spiderpool-ipv4-ippool"}, }, }, EnableCoordinator: ptr.To(true), - CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{ + CoordinatorConfig: &spiderpoolv1.CoordinatorSpec{ PodMACPrefix: ptr.To("01:10"), }, }, diff --git a/test/e2e/subnet/subnet_suite_test.go b/test/e2e/subnet/subnet_suite_test.go index 1fe955d082..ca3b7050ae 100644 --- a/test/e2e/subnet/subnet_suite_test.go +++ b/test/e2e/subnet/subnet_suite_test.go @@ -5,7 +5,7 @@ package subnet_test import ( "testing" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/test/e2e/subnet/subnet_test.go b/test/e2e/subnet/subnet_test.go index 93e90dcfba..85a38b806c 100644 --- a/test/e2e/subnet/subnet_test.go +++ b/test/e2e/subnet/subnet_test.go @@ -26,7 +26,7 @@ import ( "github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers" "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/ip" - spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" + spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v1" "github.com/spidernet-io/spiderpool/pkg/lock" "github.com/spidernet-io/spiderpool/pkg/types" "github.com/spidernet-io/spiderpool/pkg/utils/convert" diff --git a/test/scripts/install-multus.sh b/test/scripts/install-multus.sh index 092be8a1d1..4a5fd237cf 100755 --- a/test/scripts/install-multus.sh +++ b/test/scripts/install-multus.sh @@ -52,7 +52,7 @@ if [ ${OS} == "darwin" ]; then SED_COMMAND=gsed ; fi Install::MultusCR(){ MACVLAN_CR_TEMPLATE=' -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: <> @@ -72,7 +72,7 @@ spec: ' OVS_CR_TEMPLATE=' -apiVersion: spiderpool.spidernet.io/v2beta1 +apiVersion: spiderpool.spidernet.io/v1 kind: SpiderMultusConfig metadata: name: <> @@ -241,7 +241,7 @@ Install::SpiderpoolCR(){ INSTALL_V4_CR(){ cat <