Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 5. Configuring namespaced SR-IOV resources
Namespaced SriovNetwork Resources allow application owners to create and manage their own SriovNetwork resources directly within their namespaces, rather than relying on a cluster administrator to do it in a shared operator namespace. This method simplifies permissions, improves security, and provides better separation between applications.
5.1. An introduction to namespaced SriovNetwork resources Copier lienLien copié sur presse-papiers!
SR-IOV networks can be created and managed directly within application namespaces. This capability provides application owners with fine-grained control over network configurations, simplifying their workflow.
This approach offers several key advantages that enhance the user experience:
-
Increased Autonomy and Control: Application owners gain direct control over their network configurations, eliminating the need for a cluster administrator to create
SriovNetwork
objects on their behalf. - Enhanced Security: By allowing users to manage resources within their own namespaces, the feature improves security and provides better separation between applications. This also helps avoid the unintentional misconfiguration of other applications' NetworkAttachmentDefinition objects.
-
Simplified Permissions: Managing
SriovNetwork
resources directly in their own namespaces simplifies user permissions. This streamlines the workflow and reduces the operational overhead for developers.
5.1.1. Configuring SriovNetwork in application namespaces Copier lienLien copié sur presse-papiers!
When an SriovNetwork custom resource (CR) is deployed in an application namespace, do not define or populate the spec.networkNamespace
field. In this scenario, the NetworkAttachmentDefinition will be created in the same namespace as the SriovNetwork CR.
The SR-IOV Network Operator webhook rejects the creation of an SriovNetwork
resource in an application namespace if the spec.networkNamespace
field is defined.
Follow this procedure to create an SriovNetwork
resource in an application namespace and attach a pod to the additional network.
Prerequisites
The following steps must be completed by a cluster administrator before an application owner can configure a namespaced SriovNetwork resource:
-
The SR-IOV Network Operator is installed in the
openshift-sriov-network-operator
namespace. - Nodes with SR-IOV hardware are labeled for the operator to identify the nodes.
As an application owner you need to have administrator privileges on the application namespace.
Procedure
Specify the SR-IOV network device configuration for a node by creating an SR-IOV network node policy. The
SriovNetworkNodePolicy
object is created in theopenshift-sriov-network-operator
namespace to define the SR-IOV network device configuration for nodes. Example configuration for Intel DPK is as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an application namespace. For example, create a namespace named
sriov-app
by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a YAML file, for example,
sriovnetwork.yaml
, to define theSriovNetwork
object in the application namespace.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
namespace
: The value must match the name of the application namespace, for example,sriov-app
. -
resourceName
: This value must match thespec.resourceName
defined in theSriovNetworkNodePolicy
created by the cluster administrator, which in the example isintelnics
.
-
Apply the YAML file to create the
SriovNetwork
object in the application namespace.oc create -f sriovnetwork.yaml
$ oc create -f sriovnetwork.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After an application owner has created the SriovNetwork resource, they can create a pod that uses the newly defined network. You attach a pod to the additional network by adding a specific annotation to the pod’s YAML manifest.
Create a YAML file, for example,
test-pod.yaml
, to define a pod that uses the new network attachment:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
namespace
: The namespace where the pod is created. This must be the same namespace where theSriovNetwork
object is created. -
annotations
:k8s.v1.cni.cncf.io/networks
specifies the additional network that the pod connects to. The value must match themetadata.name
of theSriovNetwork
object.
-
Apply the YAML file to create the pod in the application namespace by running the following command:
oc create -f test-pod.yaml
$ oc create -f test-pod.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the NetworkAttachmentDefinition has been created in the same namespace by running the following command:
oc get net-attach-def -n sriov-app
$ oc get net-attach-def -n sriov-app
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where
sriov-app
is the application namespace where theSriovNetwork
object is created.Example output
NAME AGE test-network 2m
NAME AGE test-network 2m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the pod is running and get its network status by describing the pod with the following command:
oc describe pod test-pod -n sriov-app
$ oc describe pod test-pod -n sriov-app
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where
sriov-app
is the application namespace where the pod is created.In the output, look for the
k8s.v1.cni.cncf.io/network-status
annotation. This shows the name of the network and the IP assigned to the pod on that interface.Check that the pod has the additional network interface by running the following command:
oc exec -it test-pod -n sriov-app -- ip a
$ oc exec -it test-pod -n sriov-app -- ip a
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Look for a secondary network interface, for example
net1
oreth1
, in addition to the default eth0 interface. Thenet1
interface should have an IP address from the subnet you defined in the SriovNetwork object, for example10.0.0.0/24
. This confirms the pod is using the new network attachment definition.