Configuring the Kubernetes Topology Manager
To configure the Kubernetes Topology Manager, modify kubelet.service and the kubelet configuration file.
- Comment out ExecStart of kubelet.service. If ExecStart is not commented out, a message is displayed indicating that multiple ExecStarts exist.
- Open the file.
1vi /usr/lib/systemd/system/kubelet.service - Press i to enter the insert mode. Add # before ExecStart=/usr/bin/kubelet to comment out the content.
1#ExecStart=/usr/bin/kubelet - Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Open the file.
- Modify the kubelet configuration file to enable the topology management policy.
--topology-manager-policy options:
- single-numa-node
- best-effort
- restricted
- none
- Open the file.
1vi /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf1 2 3 4 5 6 7 8 9
# Note: This dropin only works with kubeadm and kubelet v1.11+ [Service] Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. EnvironmentFile=-/etc/sysconfig/kubelet
- Add the two lines:
1 2
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/cpuset/system.slice/kubelet.service ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/hugetlb/system.slice/kubelet.service
- Add the configuration switches of CPU Manager and Topology Manager:
1ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS --kube-reserved=cpu=2,memory=250Mi --cpu-manager-policy=static --feature-gates=CPUManager=true,TopologyManager=true --topology-manager-policy=single-numa-node
- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.