Skip to content

Commit

Permalink
add SR-IOV runtimeConfig doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zshi-redhat committed Nov 13, 2019
1 parent d3d96b7 commit 73c3637
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
95 changes: 95 additions & 0 deletions modules/nw-sriov-add-pod-runtimeconfig.adoc
Original file line number Diff line number Diff line change
@@ -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 SR-IOV additional network

You can configure static MAC and IP addresses on additional SR-IOV network by specifying CNI runtimeConfig data in 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 SriovNetwork CR.

.Procedure

. Create the following SriovNetwork CR, and then save the YAML in the `<name>-sriov-network.yaml` file. Replace `<name>` with a name for this additional network.
+
[source,yaml]
----
apiVersion: sriovnetwork.openshift.io/v1
kind: SriovNetwork
metadata:
name: <name> <1>
namespace: sriov-network-operator <2>
spec:
networkNamespace: <target_namespace> <3>
ipam: '{"type": "static"}' <4>
capabilities: '{"mac": true, "ips": true}' <5>
resourceName: <sriov_resource_name> <6>
----
<1> Replace `<name>` 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 `<target_namespace>` 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 `<sriov_resource_name>` 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 <filename> <1>
----
<1> Replace `<filename>` 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 `<namespace>` with the namespace you specified in the SriovNetwork CR.
+
----
oc get net-attach-def -n <namespace>
----

[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 `<name>-sriov-pod.yaml` file. Replace `<name>` with a name for this pod.
+
[source,yaml]
----
apiVersion: v1
kind: Pod
metadata:
name: sample-pod
annotations:
k8s.v1.cni.cncf.io/networks: '[
{
"name": "<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: <image>
imagePullPolicy: IfNotPresent
command: ["sleep", "infinity"]
----
<1> Replace `<name>` with then name of SR-IOV network attachment definition CR.
<2> Specify the `mac` address for SR-IOV device which is allocated from resource type defined in SR-IOV network attachment definition CR.
<3> Specify the IPv4 and/or IPv6 addresses for SR-IOV device which is allocated from resource type defined in SR-IOV network attachment definition CR.

. Create the sample SR-IOV pod by running the following command:
+
----
$ oc create -f <filename> <1>
----
<1> Replace `<filename>` with the name of the file you created in the previous step.

. Optional: Confirm that `mac` and `ips` addresses are applied to SR-IOV device by running the following command. Replace `<namespace>` with the namespace you specified in the SriovNetwork CR.
+
----
oc exec sample-pod -n <namespace> -- ip addr show
----
1 change: 1 addition & 0 deletions networking/multiple-networks/configuring-sr-iov.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]

1 comment on commit 73c3637

@lamek
Copy link

@lamek lamek commented on 73c3637 Dec 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zshi-redhat LGTM. I made very minor additions. CPed into a PR here - openshift#18487

Please sign in to comment.