Skip to content

Commit

Permalink
spidermultusconfig: ovs cni config supported
Browse files Browse the repository at this point in the history
  • Loading branch information
cyclinder committed Aug 21, 2023
1 parent 4f34d47 commit 8e107cd
Show file tree
Hide file tree
Showing 17 changed files with 358 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ spec:
- macvlan
- ipvlan
- sriov
- ovs
- custom
type: string
coordinator:
Expand Down Expand Up @@ -126,7 +127,7 @@ spec:
items:
type: string
type: array
vlanID:
vlan:
format: int32
maximum: 4094
minimum: 0
Expand Down Expand Up @@ -168,14 +169,57 @@ spec:
items:
type: string
type: array
vlanID:
vlan:
format: int32
maximum: 4094
minimum: 0
type: integer
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:
Expand All @@ -193,7 +237,7 @@ spec:
type: object
resourceName:
type: string
vlanID:
vlan:
format: int32
maximum: 4094
minimum: 0
Expand Down
4 changes: 2 additions & 2 deletions cmd/ifacer/cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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 == "" {
Expand Down
45 changes: 32 additions & 13 deletions docs/reference/crd-spidermultusconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
cniType: macvlan
macvlan:
master: ["eth0"]
vlanID: 100
vlan: 100
ippools:
ipv4: ["default-pool-v4"]
ipv6: ["default-pool-v6"]
Expand Down Expand Up @@ -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<br/> 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 | |

Expand All @@ -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<br/> 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 | |

Expand All @@ -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
Expand All @@ -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 |
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/plugin-ifacer.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
{
"type": "ifacer",
"interfaces": ["ens160"],
"vlanID": 120
"vlan": 120
},
{
"type": "macvlan",
Expand All @@ -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: "<master>.<vlanID>".
- The name of the created vlan sub-interface is spliced from the master interface and vlanId. The format is: "<master>.<vlan>".
- 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.
Expand All @@ -69,7 +69,7 @@ spec:
{
"type": "ifacer",
"interfaces": ["ens160","ens192"],
"vlanID": 120,
"vlan": 120,
"bond": {
"name": "bond0",
"mode": 0,
Expand All @@ -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 <https://www.kernel.org/doc/Documentation/networking/bonding.txt>.
Expand Down
10 changes: 5 additions & 5 deletions docs/usage/ifacer-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ spec:
macvlan:
master:
- ens192
vlanID: 100
vlan: 100
ippools:
ipv4:
- vlan100
Expand All @@ -103,7 +103,7 @@ spidermultusconfig.spiderpool.spidernet.io/macvlan-conf created
"interfaces": [
"ens192"
],
"vlanID": 100
"vlan": 100
},
{
"type": "macvlan",
Expand All @@ -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
Expand Down Expand Up @@ -206,7 +206,7 @@ spec:
master:
- ens192
- ens160
vlanID: 200
vlan: 200
ippools:
ipv4:
- vlan200
Expand All @@ -232,7 +232,7 @@ spidermultusconfig.spiderpool.spidernet.io/macvlan-conf created
"ens192"
"ens160"
],
"vlanID": 200,
"vlan": 200,
"bond": {
"name": "bond0",
"mode": 1
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/install/overlay/get-started-calico-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ spec:
ippools:
ipv4:
- 10-6-v4
vlanID: 0
vlan: 0
EOF
```

Expand All @@ -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
Expand Down
Loading

0 comments on commit 8e107cd

Please sign in to comment.