1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00

Merge pull request #18489 from openshift-cherrypick-robot/cherry-pick-18487-to-enterprise-4.3

[enterprise-4.3] add SR-IOV runtimeConfig doc
This commit is contained in:
Kevin Lamenzo
2019-12-06 14:26:04 -05:00
committed by GitHub
2 changed files with 96 additions and 0 deletions

View File

@@ -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 `<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 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 <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 the 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
----

View File

@@ -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]