配置K8s Topology Manager
配置K8s Topology Manager,需要修改kubelet.service文件和kubelet配置文件。
- 注释外层kubelet.service的ExecStart。若不注释,会提示“存在多个ExeStart”。
- 打开文件。
1
vi /usr/lib/systemd/system/kubelet.service
- 按“i”进入编辑模式,在“ExecStart=/usr/bin/kubelet”前面加上#,将内容注释掉。
1
#ExecStart=/usr/bin/kubelet
- 按“Esc”键退出编辑模式,输入:wq!,按“Enter”键保存并退出文件。
- 打开文件。
- 修改kubelet配置文件,启用拓扑管理策略。
--topology-manager-policy可选:
- single-numa-node
- best-effort
- restricted
- none
- 打开文件。
1
vi /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
1 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
- 修改点一:添加如下两行。
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
- 修改点二:修改如下这行,添加CPU Manager和Topology Manager的配置开关。
1
ExecStart=/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
- 按“Esc”键退出编辑模式,输入:wq!,按“Enter”键保存并退出文件。