Manage HugePages

    FEATURE STATE:

    1. 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.

    1. apiVersion: v1
    2. kind: Pod
    3. metadata:
    4. name: huge-pages-example
    5. spec:
    6. - name: example
    7. command:
    8. - sleep
    9. - inf
    10. volumeMounts:
    11. - mountPath: /hugepages
    12. name: hugepage
    13. resources:
    14. limits:
    15. hugepages-2Mi: 100Mi
    16. memory: 100Mi
    17. volumes:
    18. - name: hugepage
    19. emptyDir:
    20. 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() with SHM_HUGETLB must run with a supplemental group that matches proc/sys/vm/hugetlb_shm_group.
    • Huge page usage in a namespace is controllable via ResourceQuota similar to other compute resources like cpu or memory using the token.