forked from openshift/openshift-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3d96b7
commit 73c3637
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73c3637
There was a problem hiding this comment.
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