Questo contenuto non è disponibile nella lingua selezionata.
Chapter 4. Configuring an SR-IOV InfiniBand network attachment
You can configure an InfiniBand (IB) network attachment for an Single Root I/O Virtualization (SR-IOV) device in the cluster.
Before you perform any tasks in the following documentation, ensure that you installed the SR-IOV Network Operator.
4.1. InfiniBand device configuration object Copia collegamentoCollegamento copiato negli appunti!
You can configure an InfiniBand (IB) network device by defining an SriovIBNetwork
object.
The following YAML describes an SriovIBNetwork
object:
- 1
- A name for the object. The SR-IOV Network Operator creates a
NetworkAttachmentDefinition
object with same name. - 2
- The namespace where the SR-IOV Operator is installed.
- 3
- The value for the
spec.resourceName
parameter from theSriovNetworkNodePolicy
object that defines the SR-IOV hardware for this additional network. - 4
- The target namespace for the
SriovIBNetwork
object. Only pods in the target namespace can attach to the network device. - 5
- Optional: A configuration object for the IPAM CNI plugin as a YAML block scalar. The plugin manages IP address assignment for the attachment definition.
- 6
- Optional: The link state of virtual function (VF). Allowed values are
enable
,disable
andauto
. - 7
- Optional: The capabilities to configure for this network. You can specify
'{ "ips": true }'
to enable IP address support or'{ "infinibandGUID": true }'
to enable IB Global Unique Identifier (GUID) support.
4.1.1. Creating a configuration for assignment of dual-stack IP addresses dynamically Copia collegamentoCollegamento copiato negli appunti!
Dual-stack IP address assignment can be configured with the ipRanges
parameter for:
- IPv4 addresses
- IPv6 addresses
- multiple IP address assignment
Procedure
-
Set
type
towhereabouts
. Use
ipRanges
to allocate IP addresses as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Attach network to a pod. For more information, see "Adding a pod to a secondary network".
- Verify that all IP addresses are assigned.
Run the following command to ensure the IP addresses are assigned as metadata.
$ oc exec -it mypod -- ip a
$ oc exec -it mypod -- ip a
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.1.2. Configuration of IP address assignment for a network attachment Copia collegamentoCollegamento copiato negli appunti!
For secondary networks, you can assign IP addresses by using an IP Address Management (IPAM) CNI plugin, which supports various assignment methods, including Dynamic Host Configuration Protocol (DHCP) and static assignment.
The DHCP IPAM CNI plugin responsible for dynamic assignment of IP addresses operates with two distinct components:
- CNI Plugin: Responsible for integrating with the Kubernetes networking stack to request and release IP addresses.
- DHCP IPAM CNI Daemon: A listener for DHCP events that coordinates with existing DHCP servers in the environment to handle IP address assignment requests. This daemon is not a DHCP server itself.
For networks requiring type: dhcp
in their IPAM configuration, ensure the following:
- A DHCP server is available and running in the environment.
- The DHCP server is external to the cluster and you expect the server to form part of the existing network infrastructure for the customer.
- The DHCP server is appropriately configured to serve IP addresses to the nodes.
In cases where a DHCP server is unavailable in the environment, consider using the Whereabouts IPAM CNI plugin instead. The Whereabouts CNI provides similar IP address management capabilities without the need for an external DHCP server.
Use the Whereabouts CNI plugin when no external DHCP server exists or where static IP address management is preferred. The Whereabouts plugin includes a reconciler daemon to manage stale IP address allocations.
Ensure the periodic renewal of a DHCP lease throughout the lifetime of a container by including a separate daemon, the DHCP IPAM CNI Daemon. To deploy the DHCP IPAM CNI daemon, change the Cluster Network Operator (CNO) configuration to trigger the deployment of this daemon as part of the secondary network setup.
4.1.2.1. Static IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following table describes the configuration for static IP address assignment:
Field | Type | Description |
---|---|---|
|
|
The IPAM address type. The value |
|
| An array of objects specifying IP addresses to assign to the virtual interface. Both IPv4 and IPv6 IP addresses are supported. |
|
| An array of objects specifying routes to configure inside the pod. |
|
| Optional: An array of objects specifying the DNS configuration. |
The addresses
array requires objects with the following fields:
Field | Type | Description |
---|---|---|
|
|
An IP address and network prefix that you specify. For example, if you specify |
|
| The default gateway to route egress network traffic to. |
Field | Type | Description |
---|---|---|
|
|
The IP address range in CIDR format, such as |
|
| The gateway that routes network traffic. |
Field | Type | Description |
---|---|---|
|
| An array of one or more IP addresses where DNS queries get sent. |
|
|
The default domain to append to a hostname. For example, if the domain is set to |
|
|
An array of domain names to append to an unqualified hostname, such as |
Static IP address assignment configuration example
4.1.2.2. Dynamic IP address (DHCP) assignment configuration Copia collegamentoCollegamento copiato negli appunti!
A pod obtains its original DHCP lease when it is created. The lease must be periodically renewed by a minimal DHCP server deployment running on the cluster.
For an Ethernet network attachment, the SR-IOV Network Operator does not create a DHCP server deployment; the Cluster Network Operator is responsible for creating the minimal DHCP server deployment.
To trigger the deployment of the DHCP server, you must create a shim network attachment by editing the Cluster Network Operator configuration, as in the following example:
Example shim network attachment definition
- 1
- Specifies dynamic IP address (DHCP) assignment for the cluster.
The following table describes the configuration parameters for dynamic IP address address assignment with DHCP.
Field | Type | Description |
---|---|---|
|
|
The IPAM address type. The value |
The following JSON example describes the configuration p for dynamic IP address address assignment with DHCP.
Dynamic IP address (DHCP) assignment configuration example
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
4.1.2.3. Dynamic IP address assignment configuration with Whereabouts Copia collegamentoCollegamento copiato negli appunti!
The Whereabouts CNI plugin allows the dynamic assignment of an IP address to a secondary network without the use of a DHCP server.
The Whereabouts CNI plugin also supports overlapping IP address ranges and configuration of the same CIDR range multiple times within separate NetworkAttachmentDefinition
CRDs. This provides greater flexibility and management capabilities in multi-tenant environments.
4.1.2.3.1. Dynamic IP address configuration objects Copia collegamentoCollegamento copiato negli appunti!
The following table describes the configuration objects for dynamic IP address assignment with Whereabouts:
Field | Type | Description |
---|---|---|
|
|
The IPAM address type. The value |
|
| An IP address and range in CIDR notation. IP addresses are assigned from within this range of addresses. |
|
| Optional: A list of zero or more IP addresses and ranges in CIDR notation. IP addresses within an excluded address range are not assigned. |
|
| Optional: Helps ensure that each group or domain of pods gets its own set of IP addresses, even if they share the same range of IP addresses. Setting this field is important for keeping networks separate and organized, notably in multi-tenant environments. |
4.1.2.3.2. Dynamic IP address assignment configuration that uses Whereabouts Copia collegamentoCollegamento copiato negli appunti!
The following example shows a dynamic address assignment configuration that uses Whereabouts:
Whereabouts dynamic IP address assignment
4.1.2.3.3. Dynamic IP address assignment that uses Whereabouts with overlapping IP address ranges Copia collegamentoCollegamento copiato negli appunti!
The following example shows a dynamic IP address assignment that uses overlapping IP address ranges for multi-tenant networks.
NetworkAttachmentDefinition 1
- 1
- Optional. If set, must match the
network_name
ofNetworkAttachmentDefinition 2
.
NetworkAttachmentDefinition 2
- 1
- Optional. If set, must match the
network_name
ofNetworkAttachmentDefinition 1
.
4.2. Configuring SR-IOV additional network Copia collegamentoCollegamento copiato negli appunti!
You can configure an additional network that uses SR-IOV hardware by creating an SriovIBNetwork
object. When you create an SriovIBNetwork
object, the SR-IOV Network Operator automatically creates a NetworkAttachmentDefinition
object.
Do not modify or delete an SriovIBNetwork
object if it is attached to any pods in a running
state.
Prerequisites
-
Install the OpenShift CLI (
oc
). -
Log in as a user with
cluster-admin
privileges.
Procedure
Create a
SriovIBNetwork
object, and then save the YAML in the<name>.yaml
file, where<name>
is a name for this additional network. The object specification might resemble the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow To create the object, enter the following command:
oc create -f <name>.yaml
$ oc create -f <name>.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where
<name>
specifies the name of the additional network.Optional: To confirm that the
NetworkAttachmentDefinition
object that is associated with theSriovIBNetwork
object that you created in the previous step exists, enter the following command. Replace<namespace>
with the networkNamespace you specified in theSriovIBNetwork
object.oc get net-attach-def -n <namespace>
$ oc get net-attach-def -n <namespace>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3. Runtime configuration for an InfiniBand-based SR-IOV attachment Copia collegamentoCollegamento copiato negli appunti!
When attaching a pod to an additional network, you can specify a runtime configuration to make specific customizations for the pod. For example, you can request a specific MAC hardware address.
You specify the runtime configuration by setting an annotation in the pod specification. The annotation key is k8s.v1.cni.cncf.io/networks
, and it accepts a JSON object that describes the runtime configuration.
The following JSON describes the runtime configuration options for an InfiniBand-based SR-IOV network attachment.
- 1
- The name of the SR-IOV network attachment definition CR.
- 2
- The InfiniBand GUID for the SR-IOV device. To use this feature, you also must specify
{ "infinibandGUID": true }
in theSriovIBNetwork
object. - 3
- The IP addresses for the SR-IOV device that is 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 theSriovIBNetwork
object.
Example runtime configuration
4.4. Adding a pod to a secondary network Copia collegamentoCollegamento copiato negli appunti!
You can add a pod to a secondary network. The pod continues to send normal cluster-related network traffic over the default network.
When a pod is created, a secondary networks is attached to the pod. However, if a pod already exists, you cannot attach a secondary network to it.
The pod must be in the same namespace as the secondary network.
Prerequisites
-
Install the OpenShift CLI (
oc
). - Log in to the cluster.
Procedure
Add an annotation to the
Pod
object. Only one of the following annotation formats can be used:To attach a secondary network without any customization, add an annotation with the following format. Replace
<network>
with the name of the secondary network to associate with the pod:metadata: annotations: k8s.v1.cni.cncf.io/networks: <network>[,<network>,...]
metadata: annotations: k8s.v1.cni.cncf.io/networks: <network>[,<network>,...]
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- To specify more than one secondary network, separate each network with a comma. Do not include whitespace between the comma. If you specify the same secondary network multiple times, that pod will have multiple network interfaces attached to that network.
To attach a secondary network with customizations, add an annotation with the following format:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To create the pod, enter the following command. Replace
<name>
with the name of the pod.oc create -f <name>.yaml
$ oc create -f <name>.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: To Confirm that the annotation exists in the
Pod
CR, enter the following command, replacing<name>
with the name of the pod.oc get pod <name> -o yaml
$ oc get pod <name> -o yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the following example, the
example-pod
pod is attached to thenet1
secondary network:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
k8s.v1.cni.cncf.io/network-status
parameter is a JSON array of objects. Each object describes the status of a secondary network attached to the pod. The annotation value is stored as a plain text value.
4.4.1. Exposing MTU for vfio-pci SR-IOV devices to pod Copia collegamentoCollegamento copiato negli appunti!
After adding a pod to an additional network, you can check that the MTU is available for the SR-IOV network.
Procedure
Check that the pod annotation includes MTU by running the following command:
oc describe pod example-pod
$ oc describe pod example-pod
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following example shows the sample output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the MTU is available in
/etc/podnetinfo/
inside the pod by running the following command:oc exec example-pod -n sriov-tests -- cat /etc/podnetinfo/annotations | grep mtu
$ oc exec example-pod -n sriov-tests -- cat /etc/podnetinfo/annotations | grep mtu
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following example shows the sample output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow