Kubelet Configuration

9/20/2018

I am running into OOM issues on CentOs on some kubernetes nodes. I would like to set it up like they have in the demo:

--kube-reserved is set to cpu=1,memory=2Gi,ephemeral-storage=1Gi
--system-reserved is set to cpu=500m,memory=1Gi,ephemeral-storage=1Gi
--eviction-hard is set to memory.available<500Mi,nodefs.available<10%

Where do I add those params?
Should I add them to /etc/systemd/system/kubelet.service? What format?
Also, do I just set these on the worker nodes?

This is in a live enviroment so I want to get it right on the first go.

[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/

[Service]
ExecStart=/usr/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10

[Install]
WantedBy=multi-user.target
-- Chris
centos
kubelet
kubernetes

1 Answer

9/20/2018

Add them to this file (hopefully, you initiated your cluster with kubeadm):

/var/lib/kubelet/kubeadm-flags.env

For example:

KUBELET_KUBEADM_ARGS=--cgroup-driver=cgroupfs --cni-bin-dir=/opt/cni/bin --cni-conf-dir=/etc/cni/net.d --network-plugin=cni --resolv-conf=/run/systemd/resolve/resolv.conf --kube-reserved=<value> --system-reserved=<value> --eviction-hard=<value>

Run:

systemctl restart kubelet

and configs should take effect. You can check the kubelet is running with the right parameters like this:

ps -Af | grep kubelet

Hope it helps.

-- Rico
Source: StackOverflow