Skip to content

Commit 0cd2eed

Browse files
authored
Document SecondaryNetwork support for SR-IOV (#7076)
Signed-off-by: Quan Tian <[email protected]>
1 parent eb7ce24 commit 0cd2eed

File tree

2 files changed

+154
-16
lines changed

2 files changed

+154
-16
lines changed

docs/secondary-network.md

+154-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
11
# Antrea Secondary Network Support
22

3+
## Table of Contents
4+
5+
<!-- toc -->
6+
- [Introduction](#introduction)
7+
- [Prerequisites](#prerequisites)
8+
- [Configurations](#configurations)
9+
- [VLAN](#vlan)
10+
- [OVS bridge configuration](#ovs-bridge-configuration)
11+
- [Secondary VLAN network configuration](#secondary-vlan-network-configuration)
12+
- [Pod secondary interface configuration](#pod-secondary-interface-configuration)
13+
- [SR-IOV](#sr-iov)
14+
- [Creating network functions](#creating-network-functions)
15+
- [Installing SR-IOV Network Device Plugin](#installing-sr-iov-network-device-plugin)
16+
- [Secondary SR-IOV network configuration](#secondary-sr-iov-network-configuration)
17+
- [Pod secondary interface configuration](#pod-secondary-interface-configuration-1)
18+
- [Limitations](#limitations)
19+
<!-- /toc -->
20+
21+
## Introduction
22+
323
Antrea can work with Multus, in which case Antrea is the primary CNI of the
424
Kubernetes cluster and provisions the "primary" network interfaces of Pods;
525
while Multus manages secondary networks and executes other CNIs to create
626
secondary network interfaces of Pods. The [Antrea + Multus guide](cookbooks/multus)
727
talks about how to use Antrea with Multus.
828

9-
Starting with Antrea v1.15, Antrea can also provision secondary network
10-
interfaces and connect them to VLAN networks. This document describes Antrea's
11-
native support for VLAN secondary networks.
29+
Starting with Antrea v1.5, native support for secondary networks was introduced,
30+
initially for SR-IOV based networks. In Antrea v1.15, support was extended to
31+
include VLAN-based networks. The table below summarizes the capabilities of this
32+
feature across different releases.
33+
34+
| Release | SR-IOV on Bare-Metal Server | VLAN | SR-IOV on Virtual Machine |
35+
|---------------|-----------------------------|---------|---------------------------|
36+
| v1.5 - v1.14 | `Alpha` | | |
37+
| v1.15 - v2.2 | `Alpha` | `Alpha` | |
38+
| v2.3 - latest | `Alpha` | `Alpha` | `Alpha` |
39+
40+
This document describes steps to enable and use Antrea's native support for
41+
secondary networks.
1242

1343
## Prerequisites
1444

@@ -46,7 +76,17 @@ following command:
4676
kubectl apply -f https://github.com/k8snetworkplumbingwg/network-attachment-definition-client/raw/master/artifacts/networks-crd.yaml
4777
```
4878

49-
## Secondary OVS bridge configuration
79+
## Configurations
80+
81+
You can configure secondary networks for your Pods using one or more of the
82+
following types:
83+
84+
- [VLAN](#vlan)
85+
- [SR-IOV](#sr-iov)
86+
87+
### VLAN
88+
89+
#### OVS bridge configuration
5090

5191
A VLAN secondary interface will be connected to a separate OVS bridge on the
5292
Node. You can specify the secondary OVS bridge configuration in the
@@ -77,7 +117,7 @@ is moved to the OVS bridge, because of the interface state change. Please consid
77117
a static DNS configuration in `/etc/systemd/resolved.conf` before installing Antrea to
78118
use the primary NIC as a physical interface. Check more details on [issue 6558](https://github.com/antrea-io/antrea/issues/6558).
79119

80-
## Secondary VLAN network configuration
120+
#### Secondary VLAN network configuration
81121

82122
A secondary VLAN network is defined by a NetworkAttachmentDefinition CR. For
83123
example, the following NetworkAttachmentDefinition defines a VLAN network
@@ -112,7 +152,7 @@ interface, OVS will insert the VLAN tag in the packets.
112152
A few extra notes about the NetworkAttachmentDefinition `config` fields:
113153

114154
* `type` - must be set to `antrea`.
115-
* `networkType` - the only supported network type is `vlan` as of now.
155+
* `networkType` - should be set to `vlan` if VLAN-based network is desired.
116156
* `mtu` - defaults to 1500 if not set.
117157
* `vlan` - can be set to 0 or a valid VLAN ID (1 - 4094). Defaults to 0. The
118158
VLAN ID can also be specified as part of the spec of an IPPool referenced in the
@@ -122,7 +162,7 @@ the VLAN in IPPool(s) if both are set.
122162
network won't have an IP address allocated. For more information about secondary
123163
network IPAM configuration, please refer to the [Antrea IPAM document](antrea-ipam.md#ipam-for-secondary-network).
124164

125-
## Pod secondary interface configuration
165+
#### Pod secondary interface configuration
126166

127167
You can create a Pod with secondary network interfaces by adding the
128168
`k8s.v1.cni.cncf.io/networks` annotation to the Pod. The following example Pod
@@ -134,9 +174,7 @@ is created in Namespace `networks`.
134174
apiVersion: v1
135175
kind: Pod
136176
metadata:
137-
name: sample-pod
138-
labels:
139-
app: antrea-secondary-network-demo
177+
name: sample-pod-secondary-network-vlan
140178
annotations:
141179
k8s.v1.cni.cncf.io/networks: '[
142180
{"name": "vlan100"},
@@ -159,9 +197,7 @@ For example:
159197
apiVersion: v1
160198
kind: Pod
161199
metadata:
162-
name: sample-pod
163-
labels:
164-
app: antrea-secondary-network-demo
200+
name: sample-pod-secondary-network-vlan
165201
annotations:
166202
k8s.v1.cni.cncf.io/networks: networks/vlan200@eth200
167203
spec:
@@ -170,7 +206,110 @@ spec:
170206
image: antrea/toolbox:latest
171207
```
172208

173-
**At the moment, we do NOT support annotation update / removal: when the
209+
### SR-IOV
210+
211+
#### Creating network functions
212+
213+
To configure SR-IOV network for Pods, the required network functions must be
214+
available on the Kubernetes Node, whether it is a virtual machine or a
215+
bare-metal server. You can follow the following docs to create SR-IOV Virtual
216+
Functions (VFs) or Subfunctions (SFs).
217+
218+
* [Creating SR-IOV Virtual Functions](https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/docs/vf-setup.md)
219+
* [Creating Subfunctions](https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/blob/master/docs/subfunctions/README.md)
220+
221+
**While the implementation is designed to work with all SR-IOV capable NICs,
222+
we currently lack the resources to test every model, particularly those with
223+
SFs. Please open an issue if you encounter issues with a specific NIC.**
224+
225+
#### Installing SR-IOV Network Device Plugin
226+
227+
After creating network functions, you need to install the [SR-IOV Network
228+
Device Plugin](https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin),
229+
a Kubernetes device plugin that discovers and advertises networking resources,
230+
including SR-IOV VFs and SFs, on a Kubernetes Node. You can follow [this doc](https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin?tab=readme-ov-file#install-sr-iov-network-device-plugin)
231+
to install the plugin.
232+
233+
On successful installation, the allocatable resource list for the Node should
234+
be updated with network resources discovered by the plugin, as shown below:
235+
236+
```bash
237+
$ kubectl get node node1 -o json | jq '.status.allocatable'
238+
{
239+
"cpu": "8",
240+
"ephemeral-storage": "169986638772",
241+
"hugepages-1Gi": "0",
242+
"hugepages-2Mi": "8Gi",
243+
"intel.com/sriov_net_A": "8",
244+
"intel.com/sriov_net_B": "8",
245+
"memory": "7880620Ki",
246+
"pods": "1k"
247+
}
248+
```
249+
250+
#### Secondary SR-IOV network configuration
251+
252+
You can now define a secondary SR-IOV network using a
253+
NetworkAttachmentDefinition of `sriov` network type, which references the
254+
discovered network resource. For example, the following
255+
NetworkAttachmentDefinition defines a SR-IOV network named `sriov-net-a`, linked
256+
to the network resource `intel.com/sriov_net_A`:
257+
258+
```yaml
259+
apiVersion: "k8s.cni.cncf.io/v1"
260+
kind: NetworkAttachmentDefinition
261+
metadata:
262+
name: sriov-net-a
263+
annotations:
264+
k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_net_A
265+
spec:
266+
config: '{
267+
"cniVersion": "0.3.0",
268+
"type": "antrea",
269+
"networkType": "sriov",
270+
"ipam": {
271+
"type": "antrea",
272+
"ippools": ["sriov-ipv4"]
273+
}
274+
}'
275+
```
276+
277+
A few extra notes about the NetworkAttachmentDefinition `config` fields:
278+
279+
* `type` - must be set to `antrea`.
280+
* `networkType` - should be set to `sriov` if SR-IOV based network is desired.
281+
* `mtu` - defaults to 1500 if not set.
282+
* `ipam` - it is optional. If not set, the secondary interfaces created for the
283+
network won't have an IP address allocated. For more information about secondary
284+
network IPAM configuration, please refer to the [Antrea IPAM document](antrea-ipam.md#ipam-for-secondary-network).
285+
286+
#### Pod secondary interface configuration
287+
288+
Finally, to create a Pod with a secondary SR-IOV interface, add the
289+
`k8s.v1.cni.cncf.io/networks` annotation to the Pod, specifying the desired
290+
SR-IOV network.
291+
292+
```yaml
293+
apiVersion: v1
294+
kind: Pod
295+
metadata:
296+
name: sample-pod-secondary-network-sriov
297+
annotations:
298+
k8s.v1.cni.cncf.io/networks: sriov-net-a
299+
spec:
300+
containers:
301+
- name: toolbox
302+
image: antrea/toolbox:latest
303+
resources:
304+
requests:
305+
intel.com/sriov_net_A: '1'
306+
limits:
307+
intel.com/sriov_net_A: '1'
308+
```
309+
310+
## Limitations
311+
312+
* At the moment, we do NOT support annotation update / removal: when the
174313
annotation is added to the Pod for the first time (e.g., when creating the
175314
Pod), we will configure the secondary network interfaces accordingly, and no
176-
change is possible after that, until the Pod is deleted.**
315+
change is possible after that, until the Pod is deleted.

hack/.notableofcontents

-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,5 @@ docs/os-issues.md
4040
docs/ovs-offload.md
4141
docs/packetcapture-guide.md
4242
docs/prometheus-integration.md
43-
docs/secondary-network.md
4443
docs/security.md
4544
docs/traffic-encryption.md

0 commit comments

Comments
 (0)