Chapter 7. Configuring interface-level network sysctl settings and all-multicast mode for SR-IOV networks
As a cluster administrator, you can change interface-level network sysctls and several interface attributes such as promiscuous mode, all-multicast mode, MTU, and MAC address by using the tuning Container Network Interface (CNI) meta plugin for a pod connected to a SR-IOV network device.
Before you perform any tasks in the following documentation, ensure that you installed the SR-IOV Network Operator.
7.1. Labeling nodes with an SR-IOV enabled NIC Copy linkLink copied to clipboard!
If you want to enable SR-IOV on only SR-IOV capable nodes there are a couple of ways to do this.
Procedure
-
Install the Node Feature Discovery (NFD) Operator. NFD detects the presence of SR-IOV enabled NICs and labels the nodes with
node.alpha.kubernetes-incubator.io/nfd-network-sriov.capable = true. Examine the
SriovNetworkNodeStateCR for each node. Theinterfacesstanza includes a list of all of the SR-IOV devices discovered by the SR-IOV Network Operator on the worker node. Label each node withfeature.node.kubernetes.io/network-sriov.capable: "true"by using the following command:$ oc label node <node_name> feature.node.kubernetes.io/network-sriov.capable="true"NoteYou can label the nodes with whatever name you want.
7.2. Setting one sysctl flag Copy linkLink copied to clipboard!
You can set interface-level network sysctl settings for a pod connected to a SR-IOV network device.
In this example, net.ipv4.conf.IFNAME.accept_redirects is set to 1 on the created virtual interfaces.
The sysctl-tuning-test is a namespace used in this example.
Use the following command to create the
sysctl-tuning-testnamespace:$ oc create namespace sysctl-tuning-test
7.2.1. Setting one sysctl flag on nodes with SR-IOV network devices Copy linkLink copied to clipboard!
The SR-IOV Network Operator adds the SriovNetworkNodePolicy.sriovnetwork.openshift.io custom resource definition (CRD) to OpenShift Container Platform. You can configure an SR-IOV network device by creating a SriovNetworkNodePolicy custom resource (CR).
When applying the configuration specified in a SriovNetworkNodePolicy object, the SR-IOV Operator might drain and reboot the nodes.
It can take several minutes for a configuration change to apply.
Follow this procedure to create a SriovNetworkNodePolicy custom resource (CR).
Procedure
Create an
SriovNetworkNodePolicycustom resource (CR). For example, save the following YAML as the filepolicyoneflag-sriov-node-network.yaml:apiVersion: sriovnetwork.openshift.io/v1 kind: SriovNetworkNodePolicy metadata: name: policyoneflag namespace: openshift-sriov-network-operator spec: resourceName: policyoneflag nodeSelector: feature.node.kubernetes.io/network-sriov.capable="true" priority: 10 numVfs: 5 nicSelector: pfNames: ["ens5"] deviceType: "netdevice" isRdma: false-
<name>specifies the name for the custom resource object. -
<namespace>specifies the namespace where the SR-IOV Network Operator is installed. -
<resourceName>specifies the resource name of the SR-IOV network device plugin. You can create multiple SR-IOV network node policies for a resource name. -
<nodeSelector>specifies the node selector for the nodes to configure. Only SR-IOV network devices on the selected nodes are configured. The SR-IOV Container Network Interface (CNI) plugin and device plugin are deployed on selected nodes only. -
<priority>is optional. The priority is an integer value between0and99. A smaller value receives higher priority. For example, a priority of10is a higher priority than99. The default value is99. -
<numVfs>specifies the number of the virtual functions (VFs) to create for the SR-IOV physical network device. For an Intel network interface controller (NIC), the number of VFs cannot be larger than the total VFs supported by the device. For a Mellanox NIC, the number of VFs cannot be larger than127. -
<nicSelector>identifies the device for the Operator to configure. You do not have to specify values for all the parameters. It is recommended to identify the network device with enough precision to avoid selecting a device unintentionally. If you specifyrootDevices, you must also specify a value forvendor,deviceID, orpfNames. If you specify bothpfNamesandrootDevicesat the same time, ensure that they refer to the same device. If you specify a value fornetFilter, then you do not need to specify any other parameter because a network ID is unique. -
<pfNames>is optional. An array of one or more physical function (PF) names for the device. -
<deviceType>is optional. The driver type for the virtual functions. The only allowed value isnetdevice. For a Mellanox NIC to work in DPDK mode on bare-metal nodes, setisRdmatotrue. -
<isRdma>is optional. Configures whether to enable remote direct memory access (RDMA) mode. The default value isfalse. If theisRdmaparameter is set totrue, you can continue to use the RDMA-enabled VF as a normal network device. A device can be used in either mode. SetisRdmatotrueand additionally setneedVhostNettotrueto configure a Mellanox NIC for use with Fast Data Path DPDK applications.
NoteThe
vfio-pcidriver type is not supported.-
Create the
SriovNetworkNodePolicyobject:$ oc create -f policyoneflag-sriov-node-network.yamlAfter applying the configuration update, all the pods in
sriov-network-operatornamespace change to theRunningstatus.To verify that the SR-IOV network device is configured, enter the following command. Replace
<node_name>with the name of a node with the SR-IOV network device that you just configured. Expected output showsSucceeded.$ oc get sriovnetworknodestates -n openshift-sriov-network-operator <node_name> -o jsonpath='{.status.syncStatus}'
7.2.2. Configuring sysctl on a SR-IOV network Copy linkLink copied to clipboard!
You can set interface specific sysctl settings on virtual interfaces created by SR-IOV by adding the tuning configuration to the optional metaPlugins parameter of the SriovNetwork resource.
The SR-IOV Network Operator manages additional network definitions. When you specify an additional SR-IOV network to create, the SR-IOV Network Operator creates the NetworkAttachmentDefinition custom resource (CR) automatically.
Do not edit NetworkAttachmentDefinition custom resources that the SR-IOV Network Operator manages. Doing so might disrupt network traffic on your additional network.
To change the interface-level network net.ipv4.conf.IFNAME.accept_redirects sysctl settings, create an additional SR-IOV network with the Container Network Interface (CNI) tuning plugin.
Prerequisites
- Install the OpenShift Container Platform CLI (oc).
- Log in to the OpenShift Container Platform cluster as a user with cluster-admin privileges.
Procedure
Create the
SriovNetworkcustom resource (CR) for the additional SR-IOV network attachment and insert themetaPluginsconfiguration, as in the following example CR. Save the YAML as the filesriov-network-interface-sysctl.yaml.apiVersion: sriovnetwork.openshift.io/v1 kind: SriovNetwork metadata: name: onevalidflag namespace: openshift-sriov-network-operator spec: resourceName: policyoneflag networkNamespace: sysctl-tuning-test ipam: '{ "type": "static" }' capabilities: '{ "mac": true, "ips": true }' metaPlugins : | { "type": "tuning", "capabilities":{ "mac":true }, "sysctl":{ "net.ipv4.conf.IFNAME.accept_redirects": "1" } }-
<name>specifies a name for the object. The SR-IOV Network Operator creates a NetworkAttachmentDefinition object with same name. -
<namespace>specifies the namespace where the SR-IOV Network Operator is installed. -
<resourceName>specifies the value for thespec.resourceNameparameter from theSriovNetworkNodePolicyobject that defines the SR-IOV hardware for this additional network. -
<networkNamespace>specifies the target namespace for theSriovNetworkobject. Only pods in the target namespace can attach to the additional network. -
<ipam>specifies a configuration object for the IPAM CNI plugin as a YAML block scalar. The plugin manages IP address assignment for the attachment definition. -
<capabilities>specifies optional capabilities for the additional network. You can specify"{ "ips": true }"to enable IP address support or"{ "mac": true }"to enable MAC address support. -
<metaPlugins>specifies optional additional capabilities for the device. In this use case set thetypefield totuning. Specify the interface-level networksysctlyou want to set in thesysctlfield.
-
Create the
SriovNetworkresource:$ oc create -f sriov-network-interface-sysctl.yaml
Verification
Confirm that the SR-IOV Network Operator created the
NetworkAttachmentDefinitionCR by running the following command:$ oc get network-attachment-definitions -n <namespace>-
Replace
<namespace>with the value fornetworkNamespacethat you specified in theSriovNetworkobject. For example,sysctl-tuning-test. The expected output shows the name of the NAD CRD and the creation age in minutes.
NoteThere might be a delay before the SR-IOV Network Operator creates the CR.
Create a
PodCR. Save the following YAML as the fileexamplepod.yaml:apiVersion: v1 kind: Pod metadata: name: tunepod namespace: sysctl-tuning-test annotations: k8s.v1.cni.cncf.io/networks: |- [ { "name": "onevalidflag", "mac": "0a:56:0a:83:04:0c", "ips": ["10.100.100.200/24"] } ] spec: containers: - name: podexample image: centos command: ["/bin/bash", "-c", "sleep INF"] securityContext: runAsUser: 2000 runAsGroup: 3000 allowPrivilegeEscalation: false capabilities: drop: ["ALL"] securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault-
<name>specifies the name of the SR-IOV network attachment definition CR. -
<mac>is optional. The MAC address for the SR-IOV device that is allocated from the resource type defined in the SR-IOV network attachment definition CR. To use this feature, you also must specify{ "mac": true }in the SriovNetwork object. -
<ips>is optional. IP addresses for the SR-IOV device that are allocated from the resource type defined in the SR-IOV network attachment definition CR. Both IPv4 and IPv6 addresses are supported. To use this feature, you also must specify{ "ips": true }in theSriovNetworkobject.
-
Create the
PodCR:$ oc apply -f examplepod.yamlVerify that the pod is created by running the following command:
$ oc get pod -n sysctl-tuning-testThe following is example output:
NAME READY STATUS RESTARTS AGE tunepod 1/1 Running 0 47sLog in to the pod by running the following command:
$ oc rsh -n sysctl-tuning-test tunepodVerify the values of the configured sysctl flag. Find the value
net.ipv4.conf.IFNAME.accept_redirectsby running the following command:$ sysctl net.ipv4.conf.net1.accept_redirects
-
Replace
7.3. Configuring sysctl settings for pods associated with bonded SR-IOV interface flag Copy linkLink copied to clipboard!
You can set interface-level network sysctl settings for a pod connected to a bonded SR-IOV network device.
In this example, the specific network interface-level sysctl settings that can be configured are set on the bonded interface.
The sysctl-tuning-test is a namespace used in this example.
Use the following command to create the
sysctl-tuning-testnamespace:$ oc create namespace sysctl-tuning-test
7.3.1. Setting all sysctl flag on nodes with bonded SR-IOV network devices Copy linkLink copied to clipboard!
The SR-IOV Network Operator adds the SriovNetworkNodePolicy.sriovnetwork.openshift.io custom resource definition (CRD) to OpenShift Container Platform. You can configure an SR-IOV network device by creating a SriovNetworkNodePolicy custom resource (CR).
When applying the configuration specified in a SriovNetworkNodePolicy object, the SR-IOV Operator might drain the nodes, and in some cases, reboot nodes.
It might take several minutes for a configuration change to apply.
Follow this procedure to create a SriovNetworkNodePolicy custom resource (CR).
Procedure
Create an
SriovNetworkNodePolicycustom resource (CR). Save the following YAML as the filepolicyallflags-sriov-node-network.yaml. Replacepolicyallflagswith the name for the configuration.apiVersion: sriovnetwork.openshift.io/v1 kind: SriovNetworkNodePolicy metadata: name: policyallflags namespace: openshift-sriov-network-operator spec: resourceName: policyallflags nodeSelector: node.alpha.kubernetes-incubator.io/nfd-network-sriov.capable = `true` priority: 10 numVfs: 5 nicSelector: pfNames: ["ens1f0"] deviceType: "netdevice" isRdma: false-
<name>specifies the name for the custom resource object. -
<namespace>specifies the namespace where the SR-IOV Network Operator is installed. -
<resourceName>specifies the resource name of the SR-IOV network device plugin. You can create multiple SR-IOV network node policies for a resource name. -
<nodeSelector>specifies the node selector for the nodes to configure. Only SR-IOV network devices on the selected nodes are configured. The SR-IOV Container Network Interface (CNI) plugin and device plugin are deployed on selected nodes only. -
<priority>is optional. The priority is an integer value between0and99. A smaller value receives higher priority. For example, a priority of10is a higher priority than99. The default value is99. -
<numVfs>specifies the number of virtual functions (VFs) to create for the SR-IOV physical network device. For an Intel network interface controller (NIC), the number of VFs cannot be larger than the total VFs supported by the device. For a Mellanox NIC, the number of VFs cannot be larger than127. -
<nicSelector>identifies the device for the Operator to configure. You do not have to specify values for all the parameters. It is recommended to identify the network device with enough precision to avoid selecting a device unintentionally. If you specifyrootDevices, you must also specify a value forvendor,deviceID, orpfNames. If you specify bothpfNamesandrootDevicesat the same time, ensure that they refer to the same device. If you specify a value fornetFilter, then you do not need to specify any other parameter because a network ID is unique. -
<pfNames>is optional. An array of one or more physical function (PF) names for the device. -
<deviceType>is optional. The driver type for the virtual functions. The only allowed value isnetdevice. For a Mellanox NIC to work in DPDK mode on bare-metal nodes, setisRdmatotrue. -
<isRdma>is optional. Configures whether to enable remote direct memory access (RDMA) mode. The default value isfalse. If theisRdmaparameter is set totrue, you can continue to use the RDMA-enabled VF as a normal network device. A device can be used in either mode. SetisRdmatotrueand additionally setneedVhostNettotrueto configure a Mellanox NIC for use with Fast Data Path DPDK applications.
NoteThe
vfio-pcidriver type is not supported.-
Create the
SriovNetworkNodePolicyobject:$ oc create -f policyallflags-sriov-node-network.yamlAfter applying the configuration update, all the pods in sriov-network-operator namespace change to the
Runningstatus.To verify that the SR-IOV network device is configured, enter the following command. Replace
<node_name>with the name of a node with the SR-IOV network device that you just configured. Expected output showsSucceeded$ oc get sriovnetworknodestates -n openshift-sriov-network-operator <node_name> -o jsonpath='{.status.syncStatus}'
7.3.2. Configuring sysctl on a bonded SR-IOV network Copy linkLink copied to clipboard!
You can set interface specific sysctl settings on a bonded interface created from two SR-IOV interfaces. Do this by adding the tuning configuration to the optional Plugins parameter of the bond network attachment definition.
Do not edit NetworkAttachmentDefinition custom resources that the SR-IOV Network Operator manages. Doing so might disrupt network traffic on your additional network.
To change specific interface-level network sysctl settings create the SriovNetwork custom resource (CR) with the Container Network Interface (CNI) tuning plugin by using the following procedure.
Prerequisites
- Install the OpenShift Container Platform CLI (oc).
- Log in to the OpenShift Container Platform cluster as a user with cluster-admin privileges.
Procedure
Create the
SriovNetworkcustom resource (CR) for the bonded interface as in the following example CR. Save the YAML as the filesriov-network-attachment.yaml.apiVersion: sriovnetwork.openshift.io/v1 kind: SriovNetwork metadata: name: allvalidflags namespace: openshift-sriov-network-operator spec: resourceName: policyallflags networkNamespace: sysctl-tuning-test capabilities: '{ "mac": true, "ips": true }'-
<name>: A name for the object. The SR-IOV Network Operator creates a NetworkAttachmentDefinition object with same name. -
<namespace>: The namespace where the SR-IOV Network Operator is installed. -
<resourceName>: The value for thespec.resourceNameparameter from theSriovNetworkNodePolicyobject that defines the SR-IOV hardware for this additional network. -
<networkNamespace>: The target namespace for theSriovNetworkobject. Only pods in the target namespace can attach to the additional network. -
<capabilities>: Optional: The capabilities to configure for this additional network. You can specify"{ "ips": true }"to enable IP address support or"{ "mac": true }"to enable MAC address support.
-
Create the
SriovNetworkresource:$ oc create -f sriov-network-attachment.yamlCreate a bond network attachment definition as in the following example CR. Save the YAML as the file
sriov-bond-network-interface.yaml.apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: bond-sysctl-network namespace: sysctl-tuning-test spec: config: '{ "cniVersion":"0.4.0", "name":"bound-net", "plugins":[ { "type":"bond", "mode": "active-backup", "failOverMac": 1, "linksInContainer": true, "miimon": "100", "links": [ {"name": "net1"}, {"name": "net2"} ], "ipam":{ "type":"static" } }, { "type":"tuning", "capabilities":{ "mac":true }, "sysctl":{ "net.ipv4.conf.IFNAME.accept_redirects": "0", "net.ipv4.conf.IFNAME.accept_source_route": "0", "net.ipv4.conf.IFNAME.disable_policy": "1", "net.ipv4.conf.IFNAME.secure_redirects": "0", "net.ipv4.conf.IFNAME.send_redirects": "0", "net.ipv6.conf.IFNAME.accept_redirects": "0", "net.ipv6.conf.IFNAME.accept_source_route": "1", "net.ipv6.neigh.IFNAME.base_reachable_time_ms": "20000", "net.ipv6.neigh.IFNAME.retrans_time_ms": "2000" } } ] }'-
<type>: The type isbond. -
<mode>: Themodeattribute specifies the bonding mode. The bonding modes supported arebalance-rr- 0,active-backup- 1, andbalance-xor- 2. Forbalance-rrorbalance-xormodes, you must set thetrustmode toonfor the SR-IOV virtual function. -
<failOverMac>: Thefailoverattribute is mandatory for active-backup mode. -
<linksInContainer>: ThelinksInContainer=trueflag informs the Bond CNI that the required interfaces are to be found inside the container. By default, Bond CNI looks for these interfaces on the host which does not work for integration with SRIOV and Multus. -
<links>: Thelinkssection defines which interfaces will be used to create the bond. By default, Multus names the attached interfaces as: "net", plus a consecutive number, starting with one. -
<ipam>: A configuration object for the IPAM CNI plugin as a YAML block scalar. The plugin manages IP address assignment for the attachment definition. In this pod example IP addresses are configured manually, so in this case,ipamis set to static. -
<tuning>: Add additional capabilities to the device. For example, set thetypefield totuning. Specify the interface-level networksysctlyou want to set in the sysctl field. This example sets all interface-level networksysctlsettings that can be set.
-
Create the bond network attachment resource:
$ oc create -f sriov-bond-network-interface.yaml
Verification
Confirm that the SR-IOV Network Operator created the
NetworkAttachmentDefinitionCR by running the following command:$ oc get network-attachment-definitions -n <namespace>-
<namespace>: Replace with the networkNamespace that you specified when configuring the network attachment, for example,sysctl-tuning-test. Expected output shows the names of the NAD CRDs and the creation age in minutes.
NoteThere might be a delay before the SR-IOV Network Operator creates the CR.
-
Create a
PodCR. For example, save the following YAML as the fileexamplepod.yaml:apiVersion: v1 kind: Pod metadata: name: tunepod namespace: sysctl-tuning-test annotations: k8s.v1.cni.cncf.io/networks: |- [ {"name": "allvalidflags"}, {"name": "allvalidflags"}, { "name": "bond-sysctl-network", "interface": "bond0", "mac": "0a:56:0a:83:04:0c", "ips": ["10.100.100.200/24"] } ] spec: containers: - name: podexample image: centos command: ["/bin/bash", "-c", "sleep INF"] securityContext: runAsUser: 2000 runAsGroup: 3000 allowPrivilegeEscalation: false capabilities: drop: ["ALL"] securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault-
<allvalidflags>: The name of the SR-IOV network attachment definition CR. -
<mac>: Optional: The MAC address for the SR-IOV device that is allocated from the resource type defined in the SR-IOV network attachment definition CR. To use this feature, you also must specify{ "mac": true }in the SriovNetwork object. -
<ips>: Optional: IP addresses for the SR-IOV device that are allocated from the resource type defined in the SR-IOV network attachment definition CR. Both IPv4 and IPv6 addresses are supported. To use this feature, you also must specify{ "ips": true }in theSriovNetworkobject.
-
Apply the YAML:
$ oc apply -f examplepod.yamlVerify that the pod is created by running the following command:
$ oc get pod -n sysctl-tuning-testThe following is example output:
NAME READY STATUS RESTARTS AGE tunepod 1/1 Running 0 47sLog in to the pod by running the following command:
$ oc rsh -n sysctl-tuning-test tunepodVerify the values of the configured
sysctlflag. Find the valuenet.ipv6.neigh.IFNAME.base_reachable_time_msby running the following command:$ sysctl net.ipv6.neigh.bond0.base_reachable_time_ms
7.4. About all-multicast mode Copy linkLink copied to clipboard!
Enabling all-multicast mode, particularly in the context of rootless applications, is critical. If you do not enable this mode, you would be required to grant the NET_ADMIN capability to the pod’s Security Context Constraints (SCC). If you were to allow the NET_ADMIN capability to grant the pod privileges to make changes that extend beyond its specific requirements, you could potentially expose security vulnerabilities.
The tuning CNI plugin supports changing several interface attributes, including all-multicast mode. By enabling this mode, you can allow applications running on Virtual Functions (VFs) that are configured on a SR-IOV network device to receive multicast traffic from applications on other VFs, whether attached to the same or different physical functions.
7.4.1. Enabling the all-multicast mode on an SR-IOV network Copy linkLink copied to clipboard!
You can enable the all-multicast mode on an SR-IOV interface by:
-
Adding the tuning configuration to the
metaPluginsparameter of theSriovNetworkresource Setting the
allmultifield totruein the tuning configurationNoteEnsure that you create the virtual function (VF) with trust enabled.
The SR-IOV Network Operator manages additional network definitions. When you specify an additional SR-IOV network to create, the SR-IOV Network Operator creates the NetworkAttachmentDefinition custom resource (CR) automatically.
Do not edit NetworkAttachmentDefinition custom resources that the SR-IOV Network Operator manages. Doing so might disrupt network traffic on your additional network.
Enable the all-multicast mode on a SR-IOV network by following this guidance.
Prerequisites
- You have installed the OpenShift Container Platform CLI (oc).
-
You are logged in to the OpenShift Container Platform cluster as a user with
cluster-adminprivileges. - You have installed the SR-IOV Network Operator.
-
You have configured an appropriate
SriovNetworkNodePolicyobject.
Procedure
Create a YAML file with the following settings that defines a
SriovNetworkNodePolicyobject for a Mellanox ConnectX-5 device. Save the YAML file assriovnetpolicy-mlx.yaml.apiVersion: sriovnetwork.openshift.io/v1 kind: SriovNetworkNodePolicy metadata: name: sriovnetpolicy-mlx namespace: openshift-sriov-network-operator spec: deviceType: netdevice nicSelector: deviceID: "1017" pfNames: - ens8f0np0#0-9 rootDevices: - 0000:d8:00.0 vendor: "15b3" nodeSelector: feature.node.kubernetes.io/network-sriov.capable: "true" numVfs: 10 priority: 99 resourceName: resourcemlx-
Optional: If the SR-IOV capable cluster nodes are not already labeled, add the
SriovNetworkNodePolicy.Spec.NodeSelectorlabel. For more information about labeling nodes, see "Understanding how to update labels on nodes". Create the
SriovNetworkNodePolicyobject by running the following command:$ oc create -f sriovnetpolicy-mlx.yamlAfter applying the configuration update, all the pods in the
sriov-network-operatornamespace automatically move to aRunningstatus.Create the
enable-allmulti-testnamespace by running the following command:$ oc create namespace enable-allmulti-testCreate the
SriovNetworkcustom resource (CR) for the additional SR-IOV network attachment and insert themetaPluginsconfiguration, as in the following example CR YAML, and save the file assriov-enable-all-multicast.yaml.apiVersion: sriovnetwork.openshift.io/v1 kind: SriovNetwork metadata: name: enableallmulti namespace: openshift-sriov-network-operator spec: resourceName: enableallmulti networkNamespace: enable-allmulti-test ipam: '{ "type": "static" }' capabilities: '{ "mac": true, "ips": true }' trust: "on" metaPlugins : | { "type": "tuning", "capabilities":{ "mac":true }, "allmulti": true } }-
Replace
<name>with a name for the object. The SR-IOV Network Operator creates aNetworkAttachmentDefinitionobject with the same name. -
Replace
<namespace>with the namespace where the SR-IOV Network Operator is installed. -
Replace
<resourceName>with a value for thespec.resourceNameparameter from theSriovNetworkNodePolicyobject that defines the SR-IOV hardware for this additional network. -
Replace
<networkNamespace>with the target namespace for theSriovNetworkobject. Only pods in the target namespace can attach to the additional network. -
Replace
<ipam>with a configuration object for the IPAM CNI plugin as a YAML block scalar. The plugin manages IP address assignment for the attachment definition. -
Optional: Set capabilities for the additional network. You can specify
"{ "ips": true }"to enable IP address support or"{ "mac": true }"to enable MAC address support. - Specify the trust mode of the virtual function. This must be set to "on".
-
Add more capabilities to the device by using the
metaPluginsparameter. In this use case, set thetypefield totuning, and add theallmultifield and set it totrue.
-
Replace
Create the
SriovNetworkresource by running the following command:$ oc create -f sriov-enable-all-multicast.yaml
Verification
Confirm that the SR-IOV Network Operator created the
NetworkAttachmentDefinitionCR by running the following command:$ oc get network-attachment-definitions -n <namespace>-
Replace
<namespace>with the value fornetworkNamespacethat you specified in theSriovNetworkobject. For this example, that isenable-allmulti-test. The expected output shows the name of the NAD CR and the creation age in minutes.
NoteThere might be a delay before the SR-IOV Network Operator creates the CR.
-
Replace
Display information about the SR-IOV network resources by running the following command:
$ oc get sriovnetwork -n openshift-sriov-network-operatorTo verify that the tuning CNI is correctly configured and that the additional SR-IOV network attachment is attached, create a
PodCR. Save the following sample YAML in a file namedexamplepod.yaml:apiVersion: v1 kind: Pod metadata: name: samplepod namespace: enable-allmulti-test annotations: k8s.v1.cni.cncf.io/networks: |- [ { "name": "enableallmulti", "mac": "0a:56:0a:83:04:0c", "ips": ["10.100.100.200/24"] } ] spec: containers: - name: podexample image: centos command: ["/bin/bash", "-c", "sleep INF"] securityContext: runAsUser: 2000 runAsGroup: 3000 allowPrivilegeEscalation: false capabilities: drop: ["ALL"] securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault-
Replace
<name>with the name of the SR-IOV network attachment definition CR. -
Optional: Specify the MAC address for the SR-IOV device that is allocated from the resource type defined in the SR-IOV network attachment definition CR. To use this feature, you also must specify
{"mac": true}in the SriovNetwork object. -
Optional: Specify the IP addresses for the SR-IOV device that are allocated from the resource type defined in the SR-IOV network attachment definition CR. Both IPv4 and IPv6 addresses are supported. To use this feature, you also must specify
{ "ips": true }in theSriovNetworkobject.
-
Replace
Create the
PodCR by running the following command:$ oc apply -f examplepod.yamlVerify that the pod is created by running the following command:
$ oc get pod -n enable-allmulti-testThe following is example output:
NAME READY STATUS RESTARTS AGE samplepod 1/1 Running 0 47sLog in to the pod by running the following command:
$ oc rsh -n enable-allmulti-test samplepodList all the interfaces associated with the pod by running the following command:
sh-4.4# ip linkThe following is example output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0@if22: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8901 qdisc noqueue state UP mode DEFAULT group default link/ether 0a:58:0a:83:00:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0 3: net1@if24: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default link/ether ee:9b:66:a4:ec:1d brd ff:ff:ff:ff:ff:ff link-netnsid 0-
eth0@if22is the primary interface. -
net1@if24is the secondary interface configured with the network-attachment-definition that supports the all-multicast mode (ALLMULTIflag).
-