Manage HugePages
FEATURE STATE:
- Kubernetes nodes must pre-allocate huge pages in order for the node to report its huge page capacity. A node can pre-allocate huge pages for multiple sizes.
The nodes will automatically discover and report all huge page resources as schedulable resources.
API
A pod may consume multiple huge page sizes in a single pod spec. In this case it must use medium: HugePages-<hugepagesize>
notation for all volume mounts.
apiVersion: v1
kind: Pod
metadata:
name: huge-pages-example
spec:
- name: example
command:
- sleep
- inf
volumeMounts:
- mountPath: /hugepages
name: hugepage
resources:
limits:
hugepages-2Mi: 100Mi
memory: 100Mi
volumes:
- name: hugepage
emptyDir:
medium: HugePages
- Huge page requests must equal the limits. This is the default if limits are specified, but requests are not.
- Huge pages are isolated at a container scope, so each container has own limit on their cgroup sandbox as requested in a container spec.
- EmptyDir volumes backed by huge pages may not consume more huge page memory than the pod request.
- Applications that consume huge pages via
shmget()
withSHM_HUGETLB
must run with a supplemental group that matchesproc/sys/vm/hugetlb_shm_group
. - Huge page usage in a namespace is controllable via ResourceQuota similar to other compute resources like
cpu
ormemory
using the token.