how to change kubelet working dir to somewhere else

[亡魂溺海] 提交于 2019-12-31 01:53:14

问题


kubernetes 1.7.x

kubelet store some data in /var/lib/kubelet, how can I change it to somewhere else ?

Because my /var is every small.


回答1:


Ok. I figured it out. On centos.

/etc/systemd/system/kubelet.service.d/10-kubeadm.conf

you can add

Environment="KUBELET_EXTRA_ARGS=$KUBELET_EXTRA_ARGS --root-dir=/data/k8s/kubelet"

then

systemctl daemon-reload
systemctl restart kubelet



回答2:


if your /etc/systemd/system/kubelet.service.d/10-kubeadm.conf is loading environment from /etc/sysconfig/kubelet, as does mine, you can update it to include your extra args.

# /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS=--root-dir=/data/k8s/kubelet

Entire 10-kubeadm.conf, for reference:

# /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# 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
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS



回答3:


If it should go fast and without any problems, just create a simlink to a other location with sufficent space.

As kubelet's root-directory is located at /var/lib/kubelet, copy the /var/lib/kubelet content to the new desired location, for example /data/k8s/kubelet and after rename the /var/lib/kubelet directory to kubelet-bup for backup purpose.

Create a SymbolicLink from documentation: $ln -s /path/to/dir /path/to/symlink

In this example, use: $ln -s /data/k8s/kubelet /var/lib/kubelet

this should work immediatly, otherwise use

systemctl daemon-reload
systemctl restart kubelet

Tested on Ubuntu 18.04

for reference: https://devdojo.com/tutorials/what-is-a-symlink



来源:https://stackoverflow.com/questions/46045943/how-to-change-kubelet-working-dir-to-somewhere-else

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!