How to enable 1GB HugePages on OpenShift 4.x nodes ?
Environment
- Red Hat OpenShift Container Platform (OCP) 4.4
Issue
- Need to enable and use 1GB HugePages on worker nodes
Resolution
For OpenShift 4.5+
A Tuned profile can be used to configure the number of HugePages` in the worker nodes. This is described in the following section of the documentation: Configuring huge pages
For OpenShift 4.4 and lower, the way to configure 1G HugePages is via kernel arguments.
Before proceeding with how to enable 1GB HugePages, please go through the following knowledge base solution How do I enable 1GB size HugePage on X86-64 platform? and make sure the nodes support 1GB HugePages.
- Create a
MachineConfigdefinition file like below to include kernel argument for 1G HugePages:
$ cat > 50-kargs-1g-hugepages.yaml << 'EOF'
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 50-karg-1g-hugepages
spec:
kernelArguments:
- default_hugepagesz=1G
- hugepagesz=1G
EOF
- Create the new
MachineConfig:
$ oc create -f 50-kargs-1g-hugepages.yaml
- List the
MachineConfigobjects to see that the new one was added:
[user@upi-0 ~]$ oc get machineconfig
NAME GENERATEDBYCONTROLLER IGNITIONVERSION AGE
00-master 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
00-worker 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
01-master-container-runtime 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
01-master-kubelet 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
01-worker-container-runtime 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
01-worker-kubelet 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
50-karg-1g-hugepages 3s <------
99-master-0db35ec4-b245-4083-a664-a3321b6f3478-registries 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
99-master-ssh 2.2.0 15d
99-worker-2416c803-0c17-4a09-9573-d6249634c023-kubelet 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 8d
99-worker-2416c803-0c17-4a09-9573-d6249634c023-registries 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
99-worker-ssh 2.2.0 15d
rendered-master-97018ee7bbf8151a1ad368564e8ecfd8 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 15d
rendered-worker-0252be1f29822e0a1fc7f02fbee550f7 8af4f709c4ba9c0afff3408ecc99c8fce61dd314 2.2.0 8d
-
Observe there is a new
MachineConfignamed50-karg-1g-hugepages. -
Check the status of nodes now, the node will reboot and configure the kernel argument. It may take around 15-20 minute depending on the environment before the nodes become
Readyagain.
[quicklab@upi-0 ~]$ oc get nodes
NAME STATUS ROLES AGE VERSION
master-0 Ready master 15d v1.17.1
master-1 Ready master 15d v1.17.1
master-2 Ready master 15d v1.17.1
worker-0 Ready worker 15d v1.17.1
- Login in to the node and check the kernel argument:
# ssh core@worker-0
[core@worker-0 ~]$ cat /proc/cmdline
BOOT_IMAGE=(hd0,gpt1)/ostree/rhcos-e5da40289a28b6f0cc587c812476d495019db137587bc91f6d12faf3df7b6d8c/vmlinuz-4.18.0-147.8.1.el8_1.x86_64 rhcos.root=crypt_rootfs console=tty0 console=ttyS0,115200n8 rd.luks.options=discard ostree=/ostree/boot.1/rhcos/e5da40289a28b6f0cc587c812476d495019db137587bc91f6d12faf3df7b6d8c/0 ignition.platform.id=openstack default_hugepagesz=1G hugepagesz=1G
[core@worker-1 ~]$
- Observe the two arguments in the
/proc/cmdlineoutput:default_hugepagesz=1Gandhugepagesz=1G.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.