Skip to content

Commit

Permalink
update spiderpool apis from v2beta1 to v1
Browse files Browse the repository at this point in the history
Signed-off-by: cyclinder <[email protected]>

api: update enableRdma/rdmaIsolation field for spiderMultusConfig

Signed-off-by: Cyclinder Kuo <[email protected]>
  • Loading branch information
cyclinder committed Dec 3, 2024
1 parent 2ae877f commit 8b09d25
Show file tree
Hide file tree
Showing 236 changed files with 5,427 additions and 1,628 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: <negative number>/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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: <negative number>/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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/spiderpool-agent/cmd/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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()))
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/spiderpool-agent/cmd/crd_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand All @@ -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
Expand Down
19 changes: 7 additions & 12 deletions cmd/spiderpool-controller/cmd/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/spiderpool-controller/cmd/crd_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 8b09d25

Please sign in to comment.