Create a NetworkAttachmentDefinition for an additional network
You can create a NetworkAttachmentDefinition configuration file for an additional network in order to use other CNI plugins.
In this example, a bridge-type interface is used. You can also use the example workflow here that uses host-local IP address management (IPAM) to configure other supported additional network types.
|
|
If you use |
-
The MicroShift Multus CNI is installed.
-
The OpenShift CLI (
oc) is installed. -
MicroShift is running.
-
Optional: Verify that the MicroShift node is running with the Multus CNI by running the following command:
$ oc get pods -n openshift-multusExample outputNAME READY STATUS RESTARTS AGE dhcp-daemon-dfbzw 1/1 Running 0 5h multus-rz8xc 1/1 Running 0 5h -
Create a
NetworkAttachmentDefinitionconfiguration file by running the following command and using the following example file for reference:$ oc apply -f network-attachment-definition.yamlExampleNetworkAttachmentDefinitionfileapiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: bridge-conf spec: config: '{ "cniVersion": "0.4.0", "type": "bridge", "bridge": "br-test", "mode": "bridge", "ipam": { "type": "host-local", "ranges": [ [ { "subnet": "10.10.0.0/24", "rangeStart": "10.10.0.20", "rangeEnd": "10.10.0.50", "gateway": "10.10.0.254" } ], [ { "subnet": "fd00:IJKL:MNOP:10::0/64", "rangeStart": "fd00:IJKL:MNOP:10::1", "rangeEnd": "fd00:IJKL:MNOP:10::9" "dataDir": "/var/lib/cni/br-test" } }'where:
type-
Specifies a name of the CNI plugin. This example uses the
bridgetype. bridge-
Specifies the name of the bridge on the MicroShift host that is used. The additional interface of the pod is connected to that bridge. If the interface does not exist on the host, the Bridge CNI creates it. If the interface already exists, it is reused. In this example, the name of the interface is
br-test. ipam-
Specifies the IPAM type.
ipam.ranges.-
Specifies the IP address range for the additional network. IPv6 addresses can be added to the secondary interface.
Using the name of the bridge is specific to the
bridgetype of plugin. Other plugins use different fields in theirNetworkAttachmentDefinitions. For example, themacvlanandipvlanconfigurations usemasterto specify the host interface to attach.