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.
The cluster is running in DigitalOcean and here is what I've tried so far.
--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?)ssh
into one of the nodes (droplets in DigitalOcean lingo) and run kubelet --cpu-manager-policy=static
command as described in the kubelet CLI reference here. It gives me the message Flag --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.
ps aux | grep kubelet
and find that its /etc/kubernetes/kubelet.conf
.cpuManagerPolicy: static
to it, and also kubeReserved
and systemReserved
because they become required fields if specifying cpuManagerPolicy
.I'm a little lost about the following things
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.
The folllowing worked best for me
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 \
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
sudo systemctl daemon-reload
sudo systemctl stop kubelet
sudo systemctl start kubelet
kubectl proxy
on port 8001.curl -sSL "http://localhost:8001/api/v1/nodes/${NODE_NAME}/proxy/configz" | grep cpuManager
If you use a newer k8s version and kubelet is configured by a kubelet configuration file, eg:config.yml. you can just follow the same steps of @satnam mentioned above. but instead of adding --kube-reserved
--system-reserved
--cpu-manager-policy
, you need to add kubeReserved
systemReserved
cpuManagerPolicy
in your config.yml. for example:
systemReserved:
cpu: "1"
memory: "100m"
kubeReserved:
cpu: "1"
memory: "100m"
cpuManagerPolicy: "static"
Meanwhile, be sure your CPUManager
is enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With