-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user document for Antrea native secondary network support
Signed-off-by: Jianjun Shen <shenj@vmware.com>
- Loading branch information
Showing
3 changed files
with
181 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Antrea Secondary Network Support | ||
|
||
Antrea can work with Multus, in which case Antrea is the primary CNI of the | ||
Kubernetes cluster and provisions the "primary" network interfaces of Pods; | ||
while Multus manages secondary networks and executes other CNIs to create | ||
secondary network interfaces of Pods. The [Antrea + Multus guide](cookbooks/multus) | ||
talks about how to use Antrea with Multus. | ||
|
||
Starting with Antrea v1.15, Antrea can also provision secondary network | ||
interfaces and connect them to VLAN networks. This document describes Antrea's | ||
native support of VLAN secondary networks. | ||
|
||
## Prerequisites | ||
|
||
Native secondary network support is still an alpha feature and is disabled by | ||
default. To use the feature, the `SecondaryNetwork` feature gate must be enabled | ||
in the `antrea-agent` configuration. If you need IPAM for the secondary | ||
interfaces, you should also enable the `AntreaIPAM` feature gate in both | ||
`antrea-agent` and `antrea-controller` configuration. At the moment, Antrea IPAM | ||
is only available IPAM option for secondary networks managed by Antrea. The | ||
`antrea-config` ConfigMap with the two feature gates enables is like the | ||
following: | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: antrea-config | ||
namespace: kube-system | ||
data: | ||
antrea-controller.conf: | | ||
featureGates: | ||
AntreaIPAM: true | ||
antrea-agent.conf: | | ||
featureGates: | ||
AntreaIPAM: true | ||
SecondaryNetwork: true | ||
``` | ||
Antrea leverages the `NetworkAttachmentDefinition` CRD from [Kubernetes Network | ||
Plumbing Working Group](https://github.com/k8snetworkplumbingwg/multi-net-spec) | ||
to define secondary networks. You can import the CRD to your cluster using the | ||
following command: | ||
|
||
```bash | ||
kubectl apply -f https://github.com/k8snetworkplumbingwg/network-attachment-definition-client/raw/master/artifacts/networks-crd.yaml | ||
``` | ||
|
||
## Secondary OVS bridge configuration | ||
|
||
A VLAN secondary interface will be connected to a separate OVS bridge on the | ||
Node. You can specify the secondary OVS bridge configuration in the | ||
`antrea-agent` configuration, and `antrea-agent` will automatically craete the | ||
OVS bridge on based on the configuration. For example, the following | ||
configuration will create an OVS bridge named `br-secondary`, with a physical | ||
interface `eth1`. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: antrea-config | ||
namespace: kube-system | ||
data: | ||
antrea-agent.conf: | | ||
secondaryNetwork: | ||
ovsBridges: [{"bridgeName": "br-secondary", "physicalInterfaces": ["eth1"]}] | ||
``` | ||
|
||
At the moment, Antrea supports only a single OVS bridge for secondary networks, | ||
and supports only a single physical interface on the bridge. The physical | ||
interface cannot be the Node's management interface, otherwise a Node's | ||
management network connectivity can be broken after `antrea-agent` creates the | ||
OVS bridge and moves the management interface to the bridge. | ||
|
||
## Secondary VLAN network configuration | ||
|
||
A secondary VLAN network is defined by a NetworkAttachmentDefinition CR. For | ||
example, the following NetworkAttachmentDefinition defines a VLAN network | ||
`vlan100`. | ||
|
||
```yaml | ||
apiVersion: "k8s.cni.cncf.io/v1" | ||
kind: NetworkAttachmentDefinition | ||
metadata: | ||
name: vlan100 | ||
spec: | ||
config: '{ | ||
"cniVersion": "0.3.0", | ||
"type": "antrea", | ||
"networkType": "vlan", | ||
"mtu": 1500, | ||
"vlan": 100, | ||
"ipam": { | ||
"type": "antrea", | ||
"ippools": ["vlan100-ipv4", "vlan100-ipv6"] | ||
} | ||
}' | ||
``` | ||
|
||
`antrea-agent` will connect a Pod secondary interface of a VLAN network to the | ||
secondary OVS bridge on the Node. If a non-zero VLAN is speficied in the | ||
network's `config`, `antrea-agent` will configure the VLAN ID to the OVS port, | ||
so the interface's traffic will be isolated within the VLAN. And before the | ||
traffic is forwarded out the Node via the secondary bridge's physical interface, | ||
OVS will insert the VLAN tag to the packets. | ||
|
||
A few extra notes about the NetworkAttachmentDefinition `config` fields: | ||
|
||
* `type` - must be set to `antrea`. | ||
* `networkType` - the only supported network type is `VLAN` as of now. | ||
* `mtu` - defaults to 1500 is not set. | ||
* `vlan` - can be set to 0 or a valid VLAN ID (1 - 4094). Defaults to 0. Also | ||
note, VLAN can be speficied in the spec of an IPPool in the `ipam` section too; | ||
but `vlan` in NetworkAttachmentDefinition `config` will override the VLAN in | ||
IPPool(s) if both are set. | ||
* `ipam` - it is optional. If not set, the secondary interfaces created for the | ||
network won't have an IP address allocated. For more information about secondary | ||
network IPAM configuration, please refer to the [Antrea IPAM document](antrea-ipam.md#ipam-for-secondary-network). | ||
|
||
## Pod secondary interface configuration | ||
|
||
You can create a Pod with secondary network interfaces by adding the | ||
`k8s.v1.cni.cncf.io/networks` annotation to the Pod. The following example Pod | ||
includes two secondary interfaces, one in network `vlan100` which should be | ||
created in the same Namespace as the Pod, the other in network `vlan200` which | ||
is created in Namespace `default`. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: sample-pod | ||
labels: | ||
app: antrea-secondary-network-demo | ||
annotations: | ||
k8s.v1.cni.cncf.io/networks: [vlan100, {name: vlan200, namespace: default, interface: eth200"] | ||
spec: | ||
containers: | ||
- name: toolbox | ||
image: antrea/toolbox:latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters