在Kubernetes中更改CPU管理器策略 [英] Changing the CPU Manager Policy in Kubernetes
问题描述
我正在尝试更改我管理的Kubernetes集群的CPU管理器策略,如此处,但是在这样做时,我遇到了很多问题.
I'm trying to change the CPU Manager Policy for a Kubernetes cluster that I manage, as described here however, I've run into numerous issues while doing so.
集群正在DigitalOcean中运行,这是到目前为止我尝试过的.
The cluster is running in DigitalOcean and here is what I've tried so far.
- 1. .由于本文提到
-cpu-manager-policy
是kubelet选项,因此我假设无法通过以下方式进行更改API服务器,并且必须在每个节点上手动进行更改.(这个假设是顺便说一句吗?) - 2. 我将
ssh
放入其中一个节点(DigitalOcean语言中的液滴),然后运行kubelet --cpu-manager-policy = static
命令,如 kubelet CLI所述在这里参考.它给我的消息是Flag --cpu-manager-policy已被弃用,该参数应通过Kubelet的--config标志指定的配置文件进行设置.有关更多信息,请参见https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/.
- 3. .因此,我通过运行
ps aux |检查--config标志指向的文件.grep kubelet
并找到其/etc/kubernetes/kubelet.conf
. - 4. .我编辑文件,并在其中添加一行
cpuManagerPolicy:static
以及kubeReserved
和systemReserved
,因为如果指定cpuManagerPolicy
,它们将成为必填字段. - 5. .然后,我杀死正在运行该进程的进程并重新启动它.我可以通过其他几件事(删除此文件并耗尽节点等),最终能够重新启动kubelet
- 1. Since the article mentions that
--cpu-manager-policy
is a kubelet option I assume that I cannot change it via the API Server and have to change it manually on each node. (Is this assumption BTW?) - 2. I
ssh
into one of the nodes (droplets in DigitalOcean lingo) and runkubelet --cpu-manager-policy=static
command as described in the kubelet CLI reference here. It gives me the messageFlag --cpu-manager-policy has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
- 3. So I check the file pointed at by the --config flag by running
ps aux | grep kubelet
and find that its/etc/kubernetes/kubelet.conf
. - 4. I edit the file and add a line
cpuManagerPolicy: static
to it, and alsokubeReserved
andsystemReserved
because they become required fields if specifyingcpuManagerPolicy
. - 5. Then I kill the process that was running the process and restart it. A couple other things showed up (delete this file and drain the node etc) that I was able to get through and was able to restart the kubelet ultimately
我对以下事情有些迷茫
- 如何为所有节点执行此操作?我的集群中有12个,对每个集群执行所有这些步骤似乎效率很低.
- 有什么方法可以在全局范围内(即群集范围内)设置这些参数,而不是逐个节点地进行设置吗?
- 我什至如何确认我确实更改了CPU Manager策略?
推荐答案
动态配置的一个问题是,如果节点无法重启,则API不会给出合理的响应,告诉您做错了什么,您必须将 ssh
插入节点并尾随kubelet日志.另外,您必须 ssh
进入每个节点,并始终设置-dynamic-config-dir
标志.
One issue with Dynamic Configuration is that in case the node fails to restart, the API does not give a reasonable response back that tells you what you did wrong, you'll have to ssh
into the node and tail the kubelet logs. Plus, you have to ssh
into every node and set the --dynamic-config-dir
flag anyways.
以下人员最适合我
- SSH进入节点.修改
vim /etc/systemd/system/kubelet.service
- 添加以下几行
--cpu-manager-policy=static \
--kube-reserved=cpu=1,memory=2Gi,ephemeral-storage=1Gi \
--system-reserved=cpu=1,memory=2Gi,ephemeral-storage=1Gi \
我们需要设置-kube-reserved
和-system-reserved
标志,因为它们是设置-cpu-manager的先决条件-policy
标志
We need to set the --kube-reserved
and --system-reserved
flags because they're prerequisties to setting the --cpu-manager-policy
flag
- 然后清空节点并删除以下文件夹
rm -rf /var/lib/kubelet/cpu_manager_state
- 重新启动kubelet
sudo systemctl daemon-reload
sudo systemctl stop kubelet
sudo systemctl start kubelet
- 取消该节点的连接并检查策略.假设您正在端口8001上运行
kubectl代理
.
curl -sSL "http://localhost:8001/api/v1/nodes/${NODE_NAME}/proxy/configz" | grep cpuManager
这篇关于在Kubernetes中更改CPU管理器策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!