|
| 1 | +--- |
| 2 | +approvers: |
| 3 | +- derekwaynecarr |
| 4 | +title: Manage HugePages |
| 5 | +--- |
| 6 | + |
| 7 | +{% capture overview %} |
| 8 | +{% include feature-state-alpha.md %} |
| 9 | + |
| 10 | +Kubernetes supports the allocation and consumption of pre-allocated huge pages |
| 11 | +by applications in a Pod as an **alpha** feature. This page describes how users |
| 12 | +can consume huge pages and the current limitations. |
| 13 | + |
| 14 | +{% endcapture %} |
| 15 | + |
| 16 | +{% capture prerequisites %} |
| 17 | + |
| 18 | +1. Kubernetes nodes must pre-allocate huge pages in order for the node to report |
| 19 | + its huge page capacity. A node may only pre-allocate huge pages for a single |
| 20 | + size. |
| 21 | +1. A special **alpha** feature gate `HugePages` has to be set to true across the |
| 22 | + system: `--feature-gates="HugePages=true"`. |
| 23 | + |
| 24 | +The nodes will automatically discover and report all huge page resources as a |
| 25 | +schedulable resource. |
| 26 | + |
| 27 | +{% endcapture %} |
| 28 | + |
| 29 | +{% capture steps %} |
| 30 | + |
| 31 | +## API |
| 32 | + |
| 33 | +Huge pages can be consumed via container level resource requirements using the |
| 34 | +resource name `hugepages-<size>`, where size is the most compact binary notation |
| 35 | +using integer values supported on a particular node. For example, if a node |
| 36 | +supports 2048KiB page sizes, it will expose a schedulable resource |
| 37 | +`hugepages-2Mi`. Unlike CPU or memory, huge pages do not support overcommit. |
| 38 | + |
| 39 | +```yaml |
| 40 | +apiVersion: v1 |
| 41 | +kind: Pod |
| 42 | +metadata: |
| 43 | + generateName: hugepages-volume- |
| 44 | +spec: |
| 45 | + containers: |
| 46 | + - image: fedora:latest |
| 47 | + command: |
| 48 | + - sleep |
| 49 | + - inf |
| 50 | + name: example |
| 51 | + volumeMounts: |
| 52 | + - mountPath: /hugepages |
| 53 | + name: hugepage |
| 54 | + resources: |
| 55 | + limits: |
| 56 | + hugepages-2Mi: 100Mi |
| 57 | + volumes: |
| 58 | + - name: hugepage |
| 59 | + emptyDir: |
| 60 | + medium: HugePages |
| 61 | +``` |
| 62 | +
|
| 63 | +- Huge page requests must equal the limits. This is the default if limits are |
| 64 | + specified, but requests are not. |
| 65 | +- Huge pages are isolated at a pod scope, container isolation is planned in a |
| 66 | + future iteration. |
| 67 | +- EmptyDir volumes backed by huge pages may not consume more huge page memory |
| 68 | + than the pod request. |
| 69 | +- Applications that consume huge pages via `shmget()` with `SHM_HUGETLB` must |
| 70 | + run with a supplemental group that matches `proc/sys/vm/hugetlb_shm_group` |
| 71 | + |
| 72 | +## Future |
| 73 | + |
| 74 | +- Support container isolation of huge pages in addition to pod isolation. |
| 75 | +- NUMA locality guarnatees as a feature of quality of service. |
| 76 | +- ResourceQuota support. |
| 77 | +- LimitRange support. |
| 78 | + |
| 79 | +{% endcapture %} |
| 80 | + |
| 81 | +{% include templates/task.md %} |
0 commit comments