Skip to content

Commit 782c5a5

Browse files
authored
Merge pull request #30619 from mikemckiernan/feat-hugepages
(OSDOCS-1808) Hugepages is GA
2 parents b7f0208 + c4022cb commit 782c5a5

File tree

6 files changed

+160
-25
lines changed

6 files changed

+160
-25
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * scalability_and_performance/what-huge-pages-do-and-how-they-are-consumed-by-apps.adoc
4+
5+
:file-name: hugepages-volume-pod.yaml
6+
7+
[id="consuming-huge-pages-resource-using-the-downward-api_{context}"]
8+
= Consuming huge pages resources using the Downward API
9+
10+
You can use the Downward API to inject information about the huge pages resources that are consumed by a container.
11+
12+
You can inject the resource allocation as environment variables, a volume plug-in, or both. Applications that you develop and run in the container can determine the resources that are available by reading the environment variables or files in the specified volumes.
13+
14+
.Procedure
15+
16+
. Create a `{file-name}` file that is similar to the following example:
17+
+
18+
[source,yaml]
19+
----
20+
apiVersion: v1
21+
kind: Pod
22+
metadata:
23+
generateName: hugepages-volume-
24+
labels:
25+
app: hugepages-example
26+
spec:
27+
containers:
28+
- securityContext:
29+
capabilities:
30+
add: [ "IPC_LOCK" ]
31+
image: rhel7:latest
32+
command:
33+
- sleep
34+
- inf
35+
name: example
36+
volumeMounts:
37+
- mountPath: /dev/hugepages
38+
name: hugepage
39+
- mountPath: /etc/podinfo
40+
name: podinfo
41+
resources:
42+
limits:
43+
hugepages-1Gi: 2Gi
44+
memory: "1Gi"
45+
cpu: "1"
46+
requests:
47+
hugepages-1Gi: 2Gi
48+
env:
49+
- name: REQUESTS_HUGEPAGES_1GI <.>
50+
valueFrom:
51+
resourceFieldRef:
52+
containerName: example
53+
resource: requests.hugepages-1Gi
54+
volumes:
55+
- name: hugepage
56+
emptyDir:
57+
medium: HugePages
58+
- name: podinfo
59+
downwardAPI:
60+
items:
61+
- path: "hugepages_1G_request" <.>
62+
resourceFieldRef:
63+
containerName: example
64+
resource: requests.hugepages-1Gi
65+
divisor: 1Gi
66+
----
67+
<.> Specifies to read the resource use from `requests.hugepages-1Gi` and expose the value as the `REQUESTS_HUGEPAGES_1GI` environment variable.
68+
<.> Specifies to read the resource use from `requests.hugepages-1Gi` and expose the value as the file `/etc/podinfo/hugepages_1G_request`.
69+
70+
. Create the pod from the `{file-name}` file:
71+
+
72+
[source,terminal,subs="attributes+"]
73+
----
74+
$ oc create -f {file-name}
75+
----
76+
77+
.Verification
78+
79+
. Check the value of the `REQUESTS_HUGEPAGES_1GI` environment variable:
80+
+
81+
[source,terminal]
82+
----
83+
$ oc exec -it $(oc get pods -l app=hugepages-example -o jsonpath='{.items[0].metadata.name}') \
84+
-- env | grep REQUESTS_HUGEPAGES_1GI
85+
----
86+
+
87+
.Example output
88+
[source,terminal]
89+
----
90+
REQUESTS_HUGEPAGES_1GI=2147483648
91+
----
92+
93+
. Check the value of the `/etc/podinfo/hugepages_1G_request` file:
94+
+
95+
[source,terminal]
96+
----
97+
$ oc exec -it $(oc get pods -l app=hugepages-example -o jsonpath='{.items[0].metadata.name}') \
98+
-- cat /etc/podinfo/hugepages_1G_request
99+
----
100+
+
101+
.Example output
102+
[source,terminal]
103+
----
104+
2
105+
----
106+
107+
:!file-name:

modules/nw-sriov-app-netutil.adoc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,15 @@
77

88
An link:https://github.com/openshift/app-netutil[optional library], `app-netutil`, provides several API methods for gathering network information about a pod from within a container running within that pod.
99

10-
This library is intended to assist with integrating SR-IOV virtual functions (VFs) in Data Plane Development Kit (DPDK) mode into the container.
10+
This library can assist with integrating SR-IOV virtual functions (VFs) in Data Plane Development Kit (DPDK) mode into the container.
1111
The library provides both a Golang API and a C API.
1212

1313
Currently there are three API methods implemented:
1414

15-
`GetCPUInfo()`:: This function determines which CPUs are available to the container and returns the list to the caller.
15+
`GetCPUInfo()`:: This function determines which CPUs are available to the container and returns the list.
1616

17-
`GetHugepages()`:: This function determines the amount of hugepage memory requested in the `Pod` spec for each container and returns the values to the caller.
18-
+
19-
[NOTE]
20-
====
21-
Exposing hugepages via Kubernetes Downward API is an alpha feature in Kubernetes 1.20 and is not enabled in {product-title}. The API can be tested by enabling the feature gate, `FEATURE_GATES="DownwardAPIHugePages=true"` on Kubernetes 1.20 or greater.
22-
====
17+
`GetHugepages()`:: This function determines the amount of huge page memory requested in the `Pod` spec for each container and returns the values.
2318

24-
`GetInterfaces()`:: This function determines the set of interfaces in the container and returns the list, along with the interface type and type specific data.
19+
`GetInterfaces()`:: This function determines the set of interfaces in the container and returns the list. The return value includes the interface type and type-specific data for each interface.
2520

26-
There is also a sample Docker image, `dpdk-app-centos`, which can run one of the following DPDK sample applications based on an environmental variable in the pod-spec: `l2fwd`, `l3wd` or `testpmd`. This Docker image provides an example of integrating the `app-netutil` into the container image itself. The library can also integrate into an `init-container` which collects the required data and passes the data to an existing DPDK workload.
21+
The repository for the library includes a sample Dockerfile to build a container image, `dpdk-app-centos`. The container image can run one of the following DPDK sample applications, depending on an environment variable in the pod specification: `l2fwd`, `l3wd` or `testpmd`. The container image provides an example of integrating the `app-netutil` library into the container image itself. The library can also integrate into an init container. The init container can collect the required data and pass the data to an existing DPDK workload.

modules/nw-sriov-configuring-operator.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ The `SriovOperatorConfig` object provides several fields for configuring the ope
3333
The Network Resources Injector is a Kubernetes Dynamic Admission Controller
3434
application. It provides the following capabilities:
3535

36-
* Mutation of resource requests and limits in `Pod` specification to add an SR-IOV resource name according to an SR-IOV network attachment definition annotation.
37-
* Mutation of `Pod` specifications with downward API volume to expose pod annotations and labels to the running container as files under the `/etc/podnetinfo` path.
36+
* Mutation of resource requests and limits in a pod specification to add an SR-IOV resource name according to an SR-IOV network attachment definition annotation.
37+
* Mutation of a pod specification with a Downward API volume to expose pod annotations, labels, and huge pages requests and limits. Containers that run in the pod can access the exposed information as files under the `/etc/podnetinfo` path.
3838

39-
By default the Network Resources Injector is enabled by the SR-IOV operator and runs as a daemon set on all master nodes. The following is an example of Network Resources Injector pods running in a cluster with three master nodes:
39+
By default, the Network Resources Injector is enabled by the SR-IOV Network Operator and runs as a daemon set on all master nodes. The following is an example of Network Resources Injector pods running in a cluster with three master nodes:
4040

4141
[source,terminal]
4242
----
@@ -53,15 +53,15 @@ network-resources-injector-lktz5 1/1 Running 0 10m
5353
----
5454

5555
[id="about-sr-iov-operator-admission-control-webhook_{context}"]
56-
== About the SR-IOV Operator admission controller webhook
56+
== About the SR-IOV Network Operator admission controller webhook
5757

58-
The SR-IOV Operator Admission Controller webhook is a Kubernetes Dynamic
58+
The SR-IOV Network Operator Admission Controller webhook is a Kubernetes Dynamic
5959
Admission Controller application. It provides the following capabilities:
6060

6161
* Validation of the `SriovNetworkNodePolicy` CR when it is created or updated.
6262
* Mutation of the `SriovNetworkNodePolicy` CR by setting the default value for the `priority` and `deviceType` fields when the CR is created or updated.
6363

64-
By default the SR-IOV Operator Admission Controller webhook is enabled by the operator and runs as a daemon set on all master nodes.
64+
By default the SR-IOV Network Operator Admission Controller webhook is enabled by the Operator and runs as a daemon set on all master nodes.
6565
The following is an example of the Operator Admission Controller webhook pods running in a cluster with three master nodes:
6666

6767
[source,terminal]
@@ -94,7 +94,7 @@ To disable or enable the Network Resources Injector, which is enabled by default
9494

9595
* Install the OpenShift CLI (`oc`).
9696
* Log in as a user with `cluster-admin` privileges.
97-
* You must have installed the SR-IOV Operator.
97+
* You must have installed the SR-IOV Network Operator.
9898

9999
.Procedure
100100

@@ -108,15 +108,15 @@ $ oc patch sriovoperatorconfig default \
108108
----
109109

110110
[id="disable-enable-sr-iov-operator-admission-control-webhook_{context}"]
111-
== Disabling or enabling the SR-IOV Operator admission controller webhook
111+
== Disabling or enabling the SR-IOV Network Operator admission controller webhook
112112

113113
To disable or enable the admission controller webhook, which is enabled by default, complete the following procedure.
114114

115115
.Prerequisites
116116

117117
* Install the OpenShift CLI (`oc`).
118118
* Log in as a user with `cluster-admin` privileges.
119-
* You must have installed the SR-IOV Operator.
119+
* You must have installed the SR-IOV Network Operator.
120120

121121
.Procedure
122122

modules/nw-sriov-huge-pages.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * networking/hardware_networks/about-sriov.adoc
4+
5+
[id="nw-sriov-hugepages_{context}"]
6+
= Huge pages resource injection for Downward API
7+
8+
When a pod specification includes a resource request or limit for huge pages, the Network Resources Injector automatically adds Downward API fields to the pod specification to provide the huge pages information to the container.
9+
10+
The Network Resources Injector adds a volume that is named `podnetinfo` and is mounted at `/etc/podnetinfo` for each container in the pod. The volume uses the Downward API and includes a file for huge pages requests and limits. The file naming convention is as follows:
11+
12+
* `/etc/podnetinfo/hugepages_1G_request_<container-name>`
13+
* `/etc/podnetinfo/hugepages_1G_limit_<container-name>`
14+
* `/etc/podnetinfo/hugepages_2M_request_<container-name>`
15+
* `/etc/podnetinfo/hugepages_2M_limit_<container-name>`
16+
17+
The paths specified in the previous list are compatible with the `app-netutil` library. By default, the library is configured to search for resource information in the `/etc/podnetinfo` directory. If you choose to specify the Downward API path items yourself manually, the `app-netutil` library searches for the following paths in addition to the paths in the previous list.
18+
19+
* `/etc/podnetinfo/hugepages_request`
20+
* `/etc/podnetinfo/hugepages_limit`
21+
* `/etc/podnetinfo/hugepages_1G_request`
22+
* `/etc/podnetinfo/hugepages_1G_limit`
23+
* `/etc/podnetinfo/hugepages_2M_request`
24+
* `/etc/podnetinfo/hugepages_2M_limit`
25+
26+
As with the paths that the Network Resources Injector can create, the paths in the preceding list can optionally end with a `_<container-name>` suffix.

networking/hardware_networks/about-sriov.adoc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ toc::[]
77

88
The Single Root I/O Virtualization (SR-IOV) specification is a standard for a type of PCI device assignment that can share a single device with multiple pods.
99

10-
SR-IOV enables you to segment a compliant network device, recognized on the host node as a physical function (PF), into multiple virtual functions (VFs).
10+
SR-IOV can segment a compliant network device, recognized on the host node as a physical function (PF), into multiple virtual functions (VFs).
1111
The VF is used like any other network device.
12-
The SR-IOV device driver for the device determines how the VF is exposed in the container:
12+
The SR-IOV network device driver for the device determines how the VF is exposed in the container:
1313

1414
* `netdevice` driver: A regular kernel network device in the `netns` of the container
1515
* `vfio-pci` driver: A character device mounted in the container
@@ -31,9 +31,9 @@ It performs the following functions:
3131
The Operator provisions the following components:
3232

3333
SR-IOV network configuration daemon::
34-
A DaemonSet that is deployed on worker nodes when the SR-IOV Operator starts. The daemon is responsible for discovering and initializing SR-IOV network devices in the cluster.
34+
A daemon set that is deployed on worker nodes when the SR-IOV Network Operator starts. The daemon is responsible for discovering and initializing SR-IOV network devices in the cluster.
3535

36-
SR-IOV Operator webhook::
36+
SR-IOV Network Operator webhook::
3737
A dynamic admission controller webhook that validates the Operator custom resource and sets appropriate default values for unset fields.
3838

3939
SR-IOV Network resources injector::
@@ -43,10 +43,10 @@ SR-IOV network device plug-in::
4343
A device plug-in that discovers, advertises, and allocates SR-IOV network virtual function (VF) resources. Device plug-ins are used in Kubernetes to enable the use of limited resources, typically in physical devices. Device plug-ins give the Kubernetes scheduler awareness of resource availability, so that the scheduler can schedule pods on nodes with sufficient resources.
4444

4545
SR-IOV CNI plug-in::
46-
A CNI plug-in that attaches VF interfaces allocated from the SR-IOV device plug-in directly into a pod.
46+
A CNI plug-in that attaches VF interfaces allocated from the SR-IOV network device plug-in directly into a pod.
4747

4848
SR-IOV InfiniBand CNI plug-in::
49-
A CNI plug-in that attaches InfiniBand (IB) VF interfaces allocated from the SR-IOV device plug-in directly into a pod.
49+
A CNI plug-in that attaches InfiniBand (IB) VF interfaces allocated from the SR-IOV network device plug-in directly into a pod.
5050

5151
[NOTE]
5252
====
@@ -57,6 +57,7 @@ include::modules/nw-sriov-supported-devices.adoc[leveloffset=+2]
5757
include::modules/nw-sriov-device-discovery.adoc[leveloffset=+2]
5858
include::modules/nw-sriov-example-vf-function-in-pod.adoc[leveloffset=+2]
5959
include::modules/nw-sriov-app-netutil.adoc[leveloffset=+2]
60+
include::modules/nw-sriov-huge-pages.adoc[leveloffset=+2]
6061

6162
[id="about-sriov-next-steps"]
6263
== Next steps

scalability_and_performance/what-huge-pages-do-and-how-they-are-consumed-by-apps.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ include::modules/what-huge-pages-do.adoc[leveloffset=+1]
99

1010
include::modules/how-huge-pages-are-consumed-by-apps.adoc[leveloffset=+1]
1111

12+
include::modules/consuming-huge-pages-resource-using-the-downward-api.adoc[leveloffset=+1]
13+
14+
.Additional resources
15+
16+
* xref:../nodes/containers/nodes-containers-downward-api.adoc#nodes-containers-downward-api[Allowing containers to consume Downward API objects]
17+
1218
include::modules/configuring-huge-pages.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)