Configuring an SR-IOV Ethernet network attachment

    You can configure an Ethernet network device by defining an object.

    The following YAML describes an SriovNetwork object:

    The IP address management (IPAM) Container Network Interface (CNI) plugin provides IP addresses for other CNI plugins.

    You can use the following IP address assignment types:

    • Static assignment.

    • Dynamic assignment through a DHCP server. The DHCP server you specify must be reachable from the additional network.

    • Dynamic assignment through the Whereabouts IPAM CNI plugin.

    Static IP address assignment configuration

    The following table describes the configuration for static IP address assignment:

    The addresses array requires objects with the following fields:

    Table 2. ipam.addresses[] array
    FieldTypeDescription

    string

    An IP address and network prefix that you specify. For example, if you specify 10.10.21.10/24, then the additional network is assigned an IP address of 10.10.21.10 and the netmask is 255.255.255.0.

    gateway

    The default gateway to route egress network traffic to.

    Table 3. ipam.routes[] array
    FieldTypeDescription

    dst

    string

    The IP address range in CIDR format, such as 192.168.17.0/24 or 0.0.0.0/0 for the default route.

    gw

    string

    The gateway where network traffic is routed.

    Table 4. ipam.dns object
    FieldTypeDescription

    nameservers

    array

    An array of one or more IP addresses for to send DNS queries to.

    domain

    array

    The default domain to append to a hostname. For example, if the domain is set to example.com, a DNS lookup query for example-host is rewritten as example-host.example.com.

    search

    array

    An array of domain names to append to an unqualified hostname, such as example-host, during a DNS lookup query.

    Static IP address assignment configuration example

    1. {
    2. "ipam": {
    3. "type": "static",
    4. "addresses": [
    5. {
    6. }
    7. ]
    8. }
    9. }

    Dynamic IP address (DHCP) assignment configuration

    The following JSON describes the configuration for dynamic IP address address assignment with DHCP.

    Table 5. ipam DHCP configuration object
    FieldTypeDescription

    type

    string

    The IPAM address type. The value dhcp is required.

    Dynamic IP address (DHCP) assignment configuration example

    1. {
    2. "ipam": {
    3. "type": "dhcp"
    4. }
    5. }

    Dynamic IP address assignment configuration with Whereabouts

    The Whereabouts CNI plugin allows the dynamic assignment of an IP address to an additional network without the use of a DHCP server.

    The following table describes the configuration for dynamic IP address assignment with Whereabouts:

    Table 6. whereabouts configuration object
    FieldTypeDescription

    type

    string

    The IPAM address type. The value whereabouts is required.

    range

    string

    An IP address and range in CIDR notation. IP addresses are assigned from within this range of addresses.

    exclude

    array

    Optional: A list of zero or more IP addresses and ranges in CIDR notation. IP addresses within an excluded address range are not assigned.

    Dynamic IP address assignment configuration example that uses Whereabouts

    You can configure an additional network that uses SR-IOV hardware by creating an SriovNetwork object. When you create an SriovNetwork object, the SR-IOV Network Operator automatically creates a NetworkAttachmentDefinition object.

    Do not modify or delete an SriovNetwork 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

    1. Create a SriovNetwork 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:

      1. apiVersion: sriovnetwork.openshift.io/v1
      2. kind: SriovNetwork
      3. metadata:
      4. name: attach1
      5. spec:
      6. resourceName: net1
      7. networkNamespace: project2
      8. ipam: |-
      9. {
      10. "type": "host-local",
      11. "subnet": "10.56.217.0/24",
      12. "rangeStart": "10.56.217.171",
      13. "rangeEnd": "10.56.217.181",
      14. "gateway": "10.56.217.1"
      15. }
    2. To create the object, enter the following command:

    3. Optional: To confirm that the NetworkAttachmentDefinition object that is associated with the SriovNetwork object that you created in the previous step exists, enter the following command. Replace <namespace> with the networkNamespace you specified in the object.

      1. $ oc get net-attach-def -n <namespace>