diff --git a/modules/nw-sriov-add-pod-runtimeconfig.adoc b/modules/nw-sriov-add-pod-runtimeconfig.adoc new file mode 100644 index 0000000000..9eb8da894c --- /dev/null +++ b/modules/nw-sriov-add-pod-runtimeconfig.adoc @@ -0,0 +1,95 @@ +// Module included in the following assemblies: +// +// * networking/multiple-networks/configuring-sr-iov.adoc + +[id="nw-sriov-add-pod-runtimeconfig_{context}"] += Configuring static MAC and IP addresses on additional SR-IOV networks + +You can configure static MAC and IP addresses on additional an SR-IOV network by specifying CNI runtimeConfig data in a pod annotation. + +.Prerequisites + +* Install the OpenShift Command-line Interface (CLI), commonly known as `oc`. +* Log in as a user with `cluster-admin` privileges when creating the SriovNetwork CR. + +.Procedure + +. Create the following SriovNetwork CR, and then save the YAML in the `-sriov-network.yaml` file. Replace `` with a name for this additional network. ++ +[source,yaml] +---- +apiVersion: sriovnetwork.openshift.io/v1 +kind: SriovNetwork +metadata: + name: <1> + namespace: sriov-network-operator <2> +spec: + networkNamespace: <3> + ipam: '{"type": "static"}' <4> + capabilities: '{"mac": true, "ips": true}' <5> + resourceName: <6> +---- +<1> Replace `` with a name for the CR. The Operator will create a NetworkAttachmentDefinition CR with same name. +<2> Specify the namespace where the SR-IOV Operator is installed. +<3> Replace `` with the namespace where the NetworkAttachmentDefinition CR will be created. +<4> Specify static type for the ipam CNI plug-in as a YAML block scalar. +<5> Specify `mac` and `ips` `capabilities` to `true`. +<6> Replace `` with the value for the `.spec.resourceName` parameter from the SriovNetworkNodePolicy CR that defines the SR-IOV hardware for this additional network. + +. Create the CR by running the following command: ++ +---- +$ oc create -f <1> +---- +<1> Replace `` with the name of the file you created in the previous step. + +. Optional: Confirm that the NetworkAttachmentDefinition CR associated with the SriovNetwork CR that you created in the previous step exists by running the following command. Replace `` with the namespace you specified in the SriovNetwork CR. ++ +---- +oc get net-attach-def -n +---- + +[NOTE] +===== +Do not modify or delete a SriovNetwork Custom Resource (CR) if it is attached to any Pods in the `running` state. +===== + +. Create the following SR-IOV pod spec, and then save the YAML in the `-sriov-pod.yaml` file. Replace `` with a name for this pod. ++ +[source,yaml] +---- +apiVersion: v1 +kind: Pod +metadata: + name: sample-pod + annotations: + k8s.v1.cni.cncf.io/networks: '[ + { + "name": "", <1> + "mac": "20:04:0f:f1:88:01", <2> + "ips": ["192.168.10.1/24", "2001::1/64"] <3> + } +]' +spec: + containers: + - name: sample-container + image: + imagePullPolicy: IfNotPresent + command: ["sleep", "infinity"] +---- +<1> Replace `` with then name of the SR-IOV network attachment definition CR. +<2> Specify the `mac` address for the SR-IOV device which is allocated from the resource type defined in the SR-IOV network attachment definition CR. +<3> Specify the IPv4 and/or IPv6 addresses for the SR-IOV device which is allocated from the resource type defined in the SR-IOV network attachment definition CR. + +. Create the sample SR-IOV pod by running the following command: ++ +---- +$ oc create -f <1> +---- +<1> Replace `` with the name of the file you created in the previous step. + +. Optional: Confirm that `mac` and `ips` addresses are applied to the SR-IOV device by running the following command. Replace `` with the namespace you specified in the SriovNetwork CR. ++ +---- +oc exec sample-pod -n -- ip addr show +---- diff --git a/networking/multiple-networks/configuring-sr-iov.adoc b/networking/multiple-networks/configuring-sr-iov.adoc index 1d129c2f83..7735b2e8e2 100644 --- a/networking/multiple-networks/configuring-sr-iov.adoc +++ b/networking/multiple-networks/configuring-sr-iov.adoc @@ -122,3 +122,4 @@ include::modules/nw-multus-ipam-object.adoc[leveloffset=+2] include::modules/nw-multus-add-pod.adoc[leveloffset=+1] +include::modules/nw-sriov-add-pod-runtimeconfig.adoc[leveloffset=+1]