diff --git a/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml b/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml
index 7b80f6f4bf..6e3569dce7 100644
--- a/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml
+++ b/charts/spiderpool/crds/spiderpool.spidernet.io_spidermultusconfigs.yaml
@@ -43,6 +43,7 @@ spec:
- macvlan
- ipvlan
- sriov
+ - ovs
- custom
type: string
coordinator:
@@ -126,7 +127,7 @@ spec:
items:
type: string
type: array
- vlanID:
+ vlan:
format: int32
maximum: 4094
minimum: 0
@@ -168,7 +169,7 @@ spec:
items:
type: string
type: array
- vlanID:
+ vlan:
format: int32
maximum: 4094
minimum: 0
@@ -176,6 +177,49 @@ spec:
required:
- master
type: object
+ ovs:
+ properties:
+ bridge:
+ type: string
+ deviceID:
+ description: PCI address of a VF in valid sysfs format
+ type: string
+ ippools:
+ description: SpiderpoolPools could specify the IPAM spiderpool
+ CNI configuration default IPv4&IPv6 pools.
+ properties:
+ ipv4:
+ items:
+ type: string
+ type: array
+ ipv6:
+ items:
+ type: string
+ type: array
+ type: object
+ trunk:
+ items:
+ properties:
+ id:
+ maximum: 4094
+ minimum: 0
+ type: integer
+ maxID:
+ maximum: 4094
+ minimum: 0
+ type: integer
+ minID:
+ maximum: 4094
+ minimum: 0
+ type: integer
+ type: object
+ type: array
+ vlan:
+ format: int32
+ type: integer
+ required:
+ - bridge
+ type: object
sriov:
properties:
ippools:
@@ -193,7 +237,7 @@ spec:
type: object
resourceName:
type: string
- vlanID:
+ vlan:
format: int32
maximum: 4094
minimum: 0
diff --git a/cmd/ifacer/cmd/types.go b/cmd/ifacer/cmd/types.go
index a7a53aafe2..b0dd46a880 100644
--- a/cmd/ifacer/cmd/types.go
+++ b/cmd/ifacer/cmd/types.go
@@ -18,7 +18,7 @@ var DefaultBondName = "sp_bond0"
type Ifacer struct {
types.NetConf
Interfaces []string `json:"interfaces,omitempty"`
- VlanID int `json:"vlanID,omitempty"`
+ VlanID int `json:"vlan,omitempty"`
Bond *Bond `json:"bond,omitempty"`
}
@@ -40,7 +40,7 @@ func ParseConfig(stdin []byte) (*Ifacer, error) {
}
if conf.VlanID < 0 || conf.VlanID > 4094 {
- return nil, fmt.Errorf("invalid vlanID %v: vlanID must be in range [0,4094]", conf.VlanID)
+ return nil, fmt.Errorf("invalid vlan tag %v: vlan tag must be in range [0,4094]", conf.VlanID)
}
if conf.Bond != nil && conf.Bond.Name == "" {
diff --git a/docs/reference/crd-spidermultusconfig.md b/docs/reference/crd-spidermultusconfig.md
index 87b91ecaaa..3358ed748a 100644
--- a/docs/reference/crd-spidermultusconfig.md
+++ b/docs/reference/crd-spidermultusconfig.md
@@ -19,7 +19,7 @@ spec:
cniType: macvlan
macvlan:
master: ["eth0"]
- vlanID: 100
+ vlan: 100
ippools:
ipv4: ["default-pool-v4"]
ipv6: ["default-pool-v6"]
@@ -49,22 +49,23 @@ And you can also use special annotation `multus.spidernet.io/cr-name` and `multu
This is the SpiderReservedIP spec for users to configure.
-| Field | Description | Schema | Validation | Values | Default |
-|-------------------|---------------------------------------------------|------------------------------------------------------------------------------|------------|-----------------------------|---------|
-| cniType | expected main CNI type | string | require | macvlan,ipvlan,sriov,custom | |
-| macvlan | macvlan CNI configuration | [SpiderMacvlanCniConfig](./crd-spidermultusconfig.md#SpiderMacvlanCniConfig) | optional | | |
-| ipvlan | ipvlan CNI configuration | [SpiderIPvlanCniConfig](./crd-spidermultusconfig.md#SpiderIPvlanCniConfig) | optional | | |
-| sriov | sriov CNI configuration | [SpiderSRIOVCniConfig](./crd-spidermultusconfig.md#SpiderSRIOVCniConfig) | optional | | |
-| enableCoordinator | enable coordinator or not | boolean | optional | true,false | true |
-| coordinator | coordinator CNI configuration | [CoordinatorSpec](./crd-spidercoordinator.md#Spec) | optional | | |
-| customCNI | a string that represents custom CNI configuration | string | optional | | |
+| Field | Description | Schema | Validation | Values | Default |
+|-------------------|---------------------------------------------------|------------------------------------------------------------------------------|------------|---------------------------------|---------|
+| cniType | expected main CNI type | string | require | macvlan,ipvlan,sriov,ovs,custom | |
+| macvlan | macvlan CNI configuration | [SpiderMacvlanCniConfig](./crd-spidermultusconfig.md#SpiderMacvlanCniConfig) | optional | | |
+| ipvlan | ipvlan CNI configuration | [SpiderIPvlanCniConfig](./crd-spidermultusconfig.md#SpiderIPvlanCniConfig) | optional | | |
+| sriov | sriov CNI configuration | [SpiderSRIOVCniConfig](./crd-spidermultusconfig.md#SpiderSRIOVCniConfig) | optional | | |
+| ovs | ovs CNI configuration | [SpiderOvsCniConfig](./crd-spidermultusconfig.md#SpiderOvsCniConfig) | optional | | |
+| enableCoordinator | enable coordinator or not | boolean | optional | true,false | true |
+| coordinator | coordinator CNI configuration | [CoordinatorSpec](./crd-spidercoordinator.md#Spec) | optional | | |
+| customCNI | a string that represents custom CNI configuration | string | optional | | |
#### SpiderMacvlanCniConfig
| Field | Description | Schema | Validation | Values |
|---------|------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|------------|----------|
| 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] |
+| vlan | vlan ID | int | optional | [0,4094] |
| bond | expected bond Interface configurations | [BondConfig](./crd-spidermultusconfig.md#BondConfig) | optional | |
| ippools | the default IPPools in your CNI configurations | [SpiderpoolPools](./crd-spidermultusconfig.md#SpiderpoolPools) | optional | |
@@ -73,7 +74,7 @@ This is the SpiderReservedIP spec for users to configure.
| Field | Description | Schema | Validation | Values |
|---------|------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|------------|----------|
| 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] |
+| vlan | vlan ID | int | optional | [0,4094] |
| bond | expected bond Interface configurations | [BondConfig](./crd-spidermultusconfig.md#BondConfig) | optional | |
| ippools | the default IPPools in your CNI configurations | [SpiderpoolPools](./crd-spidermultusconfig.md#SpiderpoolPools) | optional | |
@@ -82,7 +83,17 @@ This is the SpiderReservedIP spec for users to configure.
| Field | Description | Schema | Validation |
|--------------|-------------------------------------------------------------------------------------------|----------------------------------------------------------------|------------|
| resourceName | this property will create an annotation for Multus net-attach-def to cooperate with SRIOV | string | required |
-| vlanID | vlan ID | int | optional |
+| vlan | vlan ID | int | optional |
+| ippools | the default IPPools in your CNI configurations | [SpiderpoolPools](./crd-spidermultusconfig.md#SpiderpoolPools) | optional |
+
+#### SpiderOvsCniConfig
+
+| Field | Description | Schema | Validation |
+|--------------|-------------------------------------------------------------------------------------------|----------------------------------------------------------------|------------|
+| bridge | name of the bridge to use | string | required |
+| vlan | vlan ID of attached port. Trunk port if not specified | int | optional |
+| trunk | List of VLAN ID's and/or ranges of accepted VLAN ID's | [Trunk](./crd-spidermultusconfig.md#Trunk) | optional |
+| deviceID | PCI address of a VF in valid sysfs format | string | optional |
| ippools | the default IPPools in your CNI configurations | [SpiderpoolPools](./crd-spidermultusconfig.md#SpiderpoolPools) | optional |
#### BondConfig
@@ -93,6 +104,14 @@ This is the SpiderReservedIP spec for users to configure.
| Mode | bond interface mode | int | required | [0,6] |
| Options | expected bond Interface configurations | string | optional | |
+#### Trunk
+
+| Field | Description | Schema | Validation | Values |
+|-----------------------|----------------------------------------|--------|------------|----------|
+| minID | the min value of vlan ID | int | optional | [0,4094] |
+| maxID | the max value of vlan ID | int | optional | [0,4094] |
+| id | the value of vlan ID | int | optional | [0,4094] |
+
#### SpiderpoolPools
| Field | Description | Schema | Validation |
diff --git a/docs/reference/plugin-ifacer.md b/docs/reference/plugin-ifacer.md
index e7f604b60a..9df16d3a4d 100644
--- a/docs/reference/plugin-ifacer.md
+++ b/docs/reference/plugin-ifacer.md
@@ -21,7 +21,7 @@ spec:
{
"type": "ifacer",
"interfaces": ["ens160"],
- "vlanID": 120
+ "vlan": 120
},
{
"type": "macvlan",
@@ -42,11 +42,11 @@ Fields description:
- plugins[0].type(string, required): ifacer, the name of plugin.
- plugins[0].interfaces([]string,required): ifacer create VLAN sub-interfaces based on this master interface. Note: When creating a VLAN sub-interface, the elements of the array must have only one master interface. And the interface exists on the host.
-- plugins[0].vlanID: The VLAN tag of the VLAN sub-interface. Note: the value must be in range: [0,4094]. and "0" indicates that no VLAN sub-interfaces will be created.
+- plugins[0].vlan: The VLAN tag of the VLAN sub-interface. Note: the value must be in range: [0,4094]. and "0" indicates that no VLAN sub-interfaces will be created.
Note:
-- The name of the created vlan sub-interface is spliced from the master interface and vlanId. The format is: ".".
+- The name of the created vlan sub-interface is spliced from the master interface and vlanId. The format is: ".".
- If a VLAN sub-interface with the same name already exists on the node, ifacer checks if the interface is in the UP state. if not, sets to UP and exits.
@@ -69,7 +69,7 @@ spec:
{
"type": "ifacer",
"interfaces": ["ens160","ens192"],
- "vlanID": 120,
+ "vlan": 120,
"bond": {
"name": "bond0",
"mode": 0,
@@ -95,7 +95,7 @@ Fields description:
- plugins[0].type(string, required): ifacer, the name of plugin.
- plugins[0].interfaces([]string,required): ifacer create VLAN sub-interfaces based on this master interface. Note: When creating a VLAN sub-interface, the elements of the array must have only one master interface. And the interface exists on the host.
-- plugins[0].vlanID(int,optional): The VLAN tag of the VLAN sub-interface created based on the bond device. Note: the value must be in range: [0,4094]. and "0" indicates that no VLAN sub-interfaces will be created.
+- plugins[0].vlan(int,optional): The VLAN tag of the VLAN sub-interface created based on the bond device. Note: the value must be in range: [0,4094]. and "0" indicates that no VLAN sub-interfaces will be created.
- plugins[0].bond.name(string,optional): the name of bond device, If not specified, the default is sp_bond0.
- plugins[0].bond.mode(string,optional): bond mode, the value must be in range: [0,6].
- plugins[0].bond.options(string,optional), bond options for the bonding driver are supplied as parameters to the bonding module at load time, or are specified via sysfs. Multiple parameters separated by ";",input-formatted: "primary=ens160;arp_interval=1". More details see .
diff --git a/docs/usage/ifacer-zh_CN.md b/docs/usage/ifacer-zh_CN.md
index d47069234d..c58f11d524 100644
--- a/docs/usage/ifacer-zh_CN.md
+++ b/docs/usage/ifacer-zh_CN.md
@@ -82,7 +82,7 @@ spec:
macvlan:
master:
- ens192
- vlanID: 100
+ vlan: 100
ippools:
ipv4:
- vlan100
@@ -103,7 +103,7 @@ spidermultusconfig.spiderpool.spidernet.io/macvlan-conf created
"interfaces": [
"ens192"
],
- "vlanID": 100
+ "vlan": 100
},
{
"type": "macvlan",
@@ -126,7 +126,7 @@ spidermultusconfig.spiderpool.spidernet.io/macvlan-conf created
> ifacer 作为 CNI 链式调用顺序的第一个,最先被调用。 根据配置,ifacer 将基于 `ens192` 创建一个 vlan tag 为: 100 的子接口
> main cni: macvlan 的 master 字段的值为: `ens192.100`, 也就是通过 `ifacer` 创建的 Vlan 子接口: `ens192.100`
-如果节点上已经创建好 Vlan 子接口,不需要使用 `ifacer` 。我们可以直接配置 master 字段为: `ens192.100`,并且不配置 vlanID 即可, 如下:
+如果节点上已经创建好 Vlan 子接口,不需要使用 `ifacer` 。我们可以直接配置 master 字段为: `ens192.100`,并且不配置 vlan 即可, 如下:
```yaml
apiVersion: spiderpool.spidernet.io/v2beta1
@@ -206,7 +206,7 @@ spec:
master:
- ens192
- ens160
- vlanID: 200
+ vlan: 200
ippools:
ipv4:
- vlan200
@@ -232,7 +232,7 @@ spidermultusconfig.spiderpool.spidernet.io/macvlan-conf created
"ens192"
"ens160"
],
- "vlanID": 200,
+ "vlan": 200,
"bond": {
"name": "bond0",
"mode": 1
diff --git a/docs/usage/install/overlay/get-started-calico-zh_cn.md b/docs/usage/install/overlay/get-started-calico-zh_cn.md
index 741eb7e8c6..45c58e6da9 100644
--- a/docs/usage/install/overlay/get-started-calico-zh_cn.md
+++ b/docs/usage/install/overlay/get-started-calico-zh_cn.md
@@ -94,7 +94,7 @@ spec:
ippools:
ipv4:
- 10-6-v4
- vlanID: 0
+ vlan: 0
EOF
```
@@ -109,7 +109,7 @@ kind: NetworkAttachmentDefinition
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
- {"apiVersion":"spiderpool.spidernet.io/v2beta1","kind":"SpiderMultusConfig","metadata":{"annotations":{},"name":"macvlan-ens192","namespace":"default"},"spec":{"cniType":"macvlan","coordinator":{"podCIDRType":"cluster","tuneMode":"overlay"},"enableCoordinator":true,"macvlan":{"master":["ens192"],"spiderpoolConfigPools":{"IPv4IPPool":["10-6-v4"]},"vlanID":0}}}
+ {"apiVersion":"spiderpool.spidernet.io/v2beta1","kind":"SpiderMultusConfig","metadata":{"annotations":{},"name":"macvlan-ens192","namespace":"default"},"spec":{"cniType":"macvlan","coordinator":{"podCIDRType":"cluster","tuneMode":"overlay"},"enableCoordinator":true,"macvlan":{"master":["ens192"],"spiderpoolConfigPools":{"IPv4IPPool":["10-6-v4"]},"vlan":0}}}
creationTimestamp: "2023-06-30T07:12:21Z"
generation: 1
name: macvlan-ens192
diff --git a/docs/usage/install/overlay/get-started-cilium-zh_cn.md b/docs/usage/install/overlay/get-started-cilium-zh_cn.md
index c037c68c14..c037ee3ee4 100644
--- a/docs/usage/install/overlay/get-started-cilium-zh_cn.md
+++ b/docs/usage/install/overlay/get-started-cilium-zh_cn.md
@@ -97,7 +97,7 @@ spec:
ippools:
ipv4:
- 10-6-v4
- vlanID: 0
+ vlan: 0
EOF
```
@@ -114,7 +114,7 @@ kind: NetworkAttachmentDefinition
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
- {"apiVersion":"spiderpool.spidernet.io/v2beta1","kind":"SpiderMultusConfig","metadata":{"annotations":{},"name":"macvlan-ens192","namespace":"default"},"spec":{"cniType":"macvlan","coordinator":{"podCIDRType":"cluster","tuneMode":"overlay"},"enableCoordinator":true,"macvlan":{"master":["ens192"],"spiderpoolConfigPools":{"IPv4IPPool":["10-6-v4"]},"vlanID":0}}}
+ {"apiVersion":"spiderpool.spidernet.io/v2beta1","kind":"SpiderMultusConfig","metadata":{"annotations":{},"name":"macvlan-ens192","namespace":"default"},"spec":{"cniType":"macvlan","coordinator":{"podCIDRType":"cluster","tuneMode":"overlay"},"enableCoordinator":true,"macvlan":{"master":["ens192"],"spiderpoolConfigPools":{"IPv4IPPool":["10-6-v4"]},"vlan":0}}}
creationTimestamp: "2023-06-30T07:12:21Z"
generation: 1
name: macvlan-ens192
diff --git a/docs/usage/install/underlay/get-started-ovs-zh_CN.md b/docs/usage/install/underlay/get-started-ovs-zh_CN.md
index 0d5f045697..256436bb46 100644
--- a/docs/usage/install/underlay/get-started-ovs-zh_CN.md
+++ b/docs/usage/install/underlay/get-started-ovs-zh_CN.md
@@ -120,31 +120,23 @@ ec16d9e1-6187-4b21-9c2f-8b6cb75434b9
~#
```
-4. 为 ovs-cni 创建 multus NetworkAttachmentDefinition CR
+4. Spiderpool 为简化书写 JSON 格式的 Multus CNI 配置,它提供了 SpiderMultusConfig CR 来自动管理 Multus NetworkAttachmentDefinition CR。如下是创建 Ovs SpiderMultusConfig 配置的示例:
- ```bash
+* 确认 ovs-cni 所需的网桥名称,本例子以 br1 为例:
+
+ ```shell
+ BRIDGE_NAME="br1"
cat < 0 {
@@ -448,7 +455,7 @@ func generateMacvlanCNIConf(multusConfSpec spiderpoolv2beta1.MultusCNIConfigSpec
masterName = multusConfSpec.MacvlanConfig.Bond.Name
}
- // set vlanID for interface basement name
+ // set vlan for interface basement name
if multusConfSpec.MacvlanConfig.VlanID != nil {
if *multusConfSpec.MacvlanConfig.VlanID != 0 {
masterName = fmt.Sprintf("%s.%d", masterName, *multusConfSpec.MacvlanConfig.VlanID)
@@ -528,34 +535,51 @@ func generateSriovCNIConf(multusConfSpec spiderpoolv2beta1.MultusCNIConfigSpec)
return netConf
}
+func generateOvsCNIConf(multusConfSpec *spiderpoolv2beta1.MultusCNIConfigSpec) interface{} {
+ netConf := OvsNetConf{
+ Type: OvsType,
+ IPAM: spiderpoolcmd.IPAMConfig{
+ Type: constant.Spiderpool,
+ },
+ }
+
+ if multusConfSpec.OvsConfig != nil {
+ if multusConfSpec.OvsConfig.VlanTag != nil {
+ netConf.Vlan = multusConfSpec.OvsConfig.VlanTag
+ }
+
+ if len(multusConfSpec.OvsConfig.Trunk) > 0 {
+ netConf.Trunk = multusConfSpec.OvsConfig.Trunk
+ }
+
+ if multusConfSpec.OvsConfig.SpiderpoolConfigPools != nil {
+ netConf.IPAM.DefaultIPv4IPPool = multusConfSpec.OvsConfig.SpiderpoolConfigPools.IPv4IPPool
+ netConf.IPAM.DefaultIPv6IPPool = multusConfSpec.OvsConfig.SpiderpoolConfigPools.IPv6IPPool
+ }
+
+ netConf.BrName = multusConfSpec.OvsConfig.BrName
+ netConf.DeviceID = multusConfSpec.OvsConfig.DeviceID
+ }
+ return netConf
+}
+
func generateIfacer(master []string, vlanID int32, bond *spiderpoolv2beta1.BondConfig) interface{} {
netConf := IfacerNetConf{
- NetConf: types.NetConf{
- Type: constant.Ifacer,
- },
+ Type: constant.Ifacer,
Interfaces: master,
VlanID: int(vlanID),
}
if bond != nil {
- netConf.Bond = &ifacercmd.Bond{
- Name: bond.Name,
- Mode: int(bond.Mode),
- }
-
- if bond.Options != nil {
- netConf.Bond.Options = *bond.Options
- }
+ netConf.Bond = bond
}
return netConf
}
func generateCoordinatorCNIConf(coordinatorSpec *spiderpoolv2beta1.CoordinatorSpec) interface{} {
- coordinatorNetConf := coordinatorcmd.Config{
- NetConf: types.NetConf{
- Type: constant.Coordinator,
- },
+ coordinatorNetConf := CoordinatorConfig{
+ Type: constant.Coordinator,
}
// coordinatorSpec could be nil, and we just need the coorinator CNI specified and use the default configuration
@@ -569,18 +593,9 @@ func generateCoordinatorCNIConf(coordinatorSpec *spiderpoolv2beta1.CoordinatorSp
if coordinatorSpec.PodMACPrefix != nil {
coordinatorNetConf.MacPrefix = *coordinatorSpec.PodMACPrefix
}
- if coordinatorSpec.TunePodRoutes != nil {
- coordinatorNetConf.TunePodRoutes = coordinatorSpec.TunePodRoutes
- }
if coordinatorSpec.PodDefaultRouteNIC != nil {
coordinatorNetConf.PodDefaultRouteNIC = *coordinatorSpec.PodDefaultRouteNIC
}
- if coordinatorSpec.HostRuleTable != nil {
- coordinatorNetConf.HostRuleTable = pointer.Int64(int64(*coordinatorSpec.HostRuleTable))
- }
- if coordinatorSpec.HostRPFilter != nil {
- coordinatorNetConf.RPFilter = int32(*coordinatorSpec.HostRPFilter)
- }
if coordinatorSpec.DetectIPConflict != nil {
coordinatorNetConf.IPConflict = coordinatorSpec.DetectIPConflict
}
diff --git a/pkg/multuscniconfig/multusconfig_validate.go b/pkg/multuscniconfig/multusconfig_validate.go
index dd3616a26f..9a7b848b15 100644
--- a/pkg/multuscniconfig/multusconfig_validate.go
+++ b/pkg/multuscniconfig/multusconfig_validate.go
@@ -22,6 +22,7 @@ var (
macvlanConfigField = field.NewPath("spec").Child("macvlanConfig")
ipvlanConfigField = field.NewPath("spec").Child("ipvlanConfig")
sriovConfigField = field.NewPath("spec").Child("sriovConfig")
+ ovsConfigField = field.NewPath("spec").Child("ovsConfig")
customCniConfigField = field.NewPath("spec").Child("customCniTypeConfig")
annotationField = field.NewPath("metadata").Child("annotations")
)
@@ -106,6 +107,39 @@ func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *fiel
return field.Forbidden(cniTypeField, fmt.Sprintf("the cniType %s only supports %s, please remove other CNI configs", SriovType, sriovConfigField.String()))
}
+ case OvsType:
+ if multusConfig.Spec.OvsConfig == nil {
+ return field.Required(sriovConfigField, fmt.Sprintf("no %s specified", ovsConfigField.String()))
+ }
+
+ if multusConfig.Spec.OvsConfig.VlanTag != nil {
+ if err := validateVlanId(*multusConfig.Spec.OvsConfig.VlanTag); err != nil {
+ return field.Invalid(ovsConfigField, *multusConfig.Spec.OvsConfig.VlanTag, err.Error())
+ }
+ }
+
+ for idx, trunk := range multusConfig.Spec.OvsConfig.Trunk {
+ if trunk.MinID != nil {
+ if *trunk.MinID > 4094 {
+ return field.Invalid(ovsConfigField, multusConfig.Spec.OvsConfig.Trunk[idx], "incorrect trunk minID parameter")
+ }
+ }
+ if trunk.MaxID != nil {
+ if *trunk.MaxID > 4094 {
+ return field.Invalid(ovsConfigField, multusConfig.Spec.OvsConfig.Trunk[idx], "incorrect trunk maxID parameter")
+ }
+ if *trunk.MaxID < *trunk.MinID {
+ return field.Invalid(ovsConfigField, multusConfig.Spec.OvsConfig.Trunk[idx], "minID is greater than maxID in trunk parameter")
+ }
+ }
+
+ if trunk.ID != nil {
+ if *trunk.ID > 4096 {
+ return field.Invalid(ovsConfigField, multusConfig.Spec.OvsConfig.Trunk[idx], "incorrect trunk id parameter")
+ }
+ }
+ }
+
case CustomType:
// multusConfig.Spec.CustomCNIConfig can be empty
if multusConfig.Spec.MacvlanConfig != nil || multusConfig.Spec.IPVlanConfig != nil || multusConfig.Spec.SriovConfig != nil {
diff --git a/pkg/multuscniconfig/utils.go b/pkg/multuscniconfig/utils.go
index 605b4de358..81ad884f23 100644
--- a/pkg/multuscniconfig/utils.go
+++ b/pkg/multuscniconfig/utils.go
@@ -28,38 +28,66 @@ import (
netv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
- ifacercmd "github.com/spidernet-io/spiderpool/cmd/ifacer/cmd"
+ coordinatorcmd "github.com/spidernet-io/spiderpool/cmd/coordinator/cmd"
spiderpoolcmd "github.com/spidernet-io/spiderpool/cmd/spiderpool/cmd"
+ spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1"
)
const (
MacVlanType = "macvlan"
IpVlanType = "ipvlan"
SriovType = "sriov"
+ OvsType = "ovs"
CustomType = "custom"
)
type MacvlanNetConf struct {
Type string `json:"type"`
- IPAM spiderpoolcmd.IPAMConfig `json:"ipam"`
Master string `json:"master"`
Mode string `json:"mode"`
+ IPAM spiderpoolcmd.IPAMConfig `json:"ipam"`
}
type IPvlanNetConf struct {
Type string `json:"type"`
- IPAM spiderpoolcmd.IPAMConfig `json:"ipam"`
Master string `json:"master"`
+ IPAM spiderpoolcmd.IPAMConfig `json:"ipam"`
}
type SRIOVNetConf struct {
- Type string `json:"type"`
- IPAM spiderpoolcmd.IPAMConfig `json:"ipam"`
Vlan *int32 `json:"vlan,omitempty"`
+ Type string `json:"type"`
DeviceID string `json:"deviceID,omitempty"`
+ IPAM spiderpoolcmd.IPAMConfig `json:"ipam"`
+}
+
+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"`
+ Trunk []*spiderpoolv2beta1.Trunk `json:"trunk,omitempty"`
}
-type IfacerNetConf = ifacercmd.Ifacer
+type IfacerNetConf struct {
+ VlanID int `json:"vlan,omitempty"`
+ Type string `json:"type"`
+ Interfaces []string `json:"interfaces,omitempty"`
+ Bond *spiderpoolv2beta1.BondConfig `json:"bond,omitempty"`
+}
+
+type CoordinatorConfig struct {
+ IPConflict *bool `json:"detectIPConflict,omitempty"`
+ DetectGateway *bool `json:"detectGateway,omitempty"`
+ MacPrefix string `json:"podMACPrefix,omitempty"`
+ Mode coordinatorcmd.Mode `json:"mode,omitempty"`
+ Type string `json:"type"`
+ PodDefaultRouteNIC string `json:"podDefaultRouteNic,omitempty"`
+ OverlayPodCIDR []string `json:"overlayPodCIDR,omitempty"`
+ ServiceCIDR []string `json:"serviceCIDR,omitempty"`
+ HijackCIDR []string `json:"hijackCIDR,omitempty"`
+}
func ParsePodNetworkAnnotation(podNetworks, defaultNamespace string) ([]*netv1.NetworkSelectionElement, error) {
var networks []*netv1.NetworkSelectionElement
diff --git a/test/doc/spidermultus.md b/test/doc/spidermultus.md
index fa72af82d9..c69d8ffb8a 100644
--- a/test/doc/spidermultus.md
+++ b/test/doc/spidermultus.md
@@ -9,16 +9,19 @@
| M00005 | testing creating spiderMultusConfig with cniType: custom and invalid json config, expect error happened | p2 | | | |
| M00006 | testing creating spiderMultusConfig with cniType: macvlan with vlanId with one master and checking the net-attach-conf config if works | p1 | smoke | | |
| M00007 | testing creating spiderMultusConfig with cniType: macvlan with vlanId with two master with bond config and checking the net-attach-conf config if works | p1 | smoke | | |
-| M00008 | After deleting spiderMultusConfig, the corresponding net-attach-conf will also be deleted | p2 | | done | |
-| M00009 | Update spidermultusConfig, the corresponding multus net-attach-conf will also be updated | p2 | | | |
-| M00010 | Update spidermultusConfig: add new bond config | p1 | smoke | | |
-| M00011 | Manually delete the net-attach-conf of multus, it will be created automatically | p1 | | done | |
-| M00012 | Customize net-attach-conf name via annotation multus.spidernet.io/cr-name | p2 | | done | |
-| M00013 | webhook validation for multus.spidernet.io/cr-name | p3 | | done | |
-| M00014 | Change net-attach-conf version via annotation multus.spidernet.io/cni-version | p2 | | done | |
-| M00015 | webhook validation for multus.spidernet.io/cni-version | p3 | | done | |
-| M00016 | Set enableCoordinator to false, multus cr will not generate coordinator configuration | p3 | | | |
-| M00017 | Already have multus cr, spidermultus should take care of it | p3 | | done | |
-| M00018 | Multiple annotations of spidermultus should be inherited by multus CR | p3 | | | |
-| M00019 | The value of webhook verification cniType is inconsistent with cniConf | p3 | | done | |
-| M00020 | vlanID is not in the range of 0-4094 and will not be created | p3 | | done | |
+| M00008 | testing creating spiderMultusConfig with cniType: ovs with vlanId with and checking the net-attach-conf config if works | p1 | smoke | | |
+| M00009 | testing creating spiderMultusConfig with cniType: ovs with trunk with and checking the net-attach-conf config if works | p1 | smoke | | |
+| M00010 | testing creating spiderMultusConfig with cniType: ovs with device with and checking the net-attach-conf config if has annotations: ovs-cni.network.kubevirt.io/ | p1 | smoke | | |
+| M00011 | After deleting spiderMultusConfig, the corresponding net-attach-conf will also be deleted | p2 | | done | |
+| M00012 | Update spidermultusConfig, the corresponding multus net-attach-conf will also be updated | p2 | | | |
+| M00013 | Update spidermultusConfig: add new bond config | p1 | smoke | | |
+| M00014 | Manually delete the net-attach-conf of multus, it will be created automatically | p1 | | done | |
+| M00015 | Customize net-attach-conf name via annotation multus.spidernet.io/cr-name | p2 | | | |
+| M00016 | webhook validation for multus.spidernet.io/cr-name | p3 | | | |
+| M00017 | Change net-attach-conf version via annotation multus.spidernet.io/cni-version | p2 | | | |
+| M00018 | webhook validation for multus.spidernet.io/cni-version | p3 | | | |
+| M00019 | Set enableCoordinator to false, multus cr will not generate coordinator configuration | p3 | | | |
+| M00020 | Already have multus cr, spidermultus should take care of it | p3 | | | |
+| M00021 | Multiple annotations of spidermultus should be inherited by multus CR | p3 | | | |
+| M00022 | The value of webhook verification cniType is inconsistent with cniConf | p3 | | | |
+| M00023 | vlan is not in the range of 0-4094 and will not be created | p3 | | | |
diff --git a/test/scripts/install-multus.sh b/test/scripts/install-multus.sh
index beae2780a5..2a9b964c6b 100755
--- a/test/scripts/install-multus.sh
+++ b/test/scripts/install-multus.sh
@@ -52,7 +52,7 @@ spec:
cniType: macvlan
macvlan:
master: ["<>"]
- vlanID: <>
+ vlan: <>
ippools:
ipv4: [<>]
ipv6: [<>]
@@ -122,6 +122,7 @@ spec:
| sed 's?<>?vlan200-v4?g' \
| sed 's?<>?vlan200-v6?g' \
| kubectl apply --kubeconfig ${E2E_KUBECONFIG} -f -
+
}
@@ -231,5 +232,7 @@ EOF
Install::MultusCR
Install::SpiderpoolCR
+kubectl get sp -o wide --kubeconfig ${E2E_KUBECONFIG}
+kubectl get network-attachment-definitions.k8s.cni.cncf.io --kubeconfig ${E2E_KUBECONFIG} -n kube-system -o yaml
echo "$CURRENT_FILENAME : done"
\ No newline at end of file