How to modify the docker and kubelet working directory

Background

This article describes the contents to docker-ce = 18.03.1 ~ ce-0 ~ ubuntu version and kubernetes = 1.14.2-00 example to introduce other versions should be similar.

We know that the default working directory docker-ce is / var / lib / docker, image files will be stored docker, container and log file is written to a temporary directory and other containers.

Kubelet default working directory is / var / lib / kubelet, the file will be stored volume (including emptyDir volume), plugin files.

That there is a real risk: a large number of image files such as logs or container, may be the operating system root partition capacity is full, and then cause the system to crash or k8s pod are frequently deported and other abnormalities occur.

We in the production environment, and often need to change the docker kubelet working directory, it will be diverted to another piece of data on a disk file system, such as hereinafter "/ mnt / data" directory.

Modify docker working directory

1. Modify the configuration file /etc/docker/daemon.json 

{
  "graph": "/mnt/data/docker"
}

2 Restart docker service

sudo systemctl daemon-reload
sudo systemctl restart docker

3 to confirm the change to take effect

sudo docker info

See "Docker Root Dir: / mnt / data / docker", explained modified successfully.

Modify kubelet working directory

1 modify the configuration file / etc / default / kubelet (the default file does not exist, you need to create a new)

KUBELET_EXTRA_ARGS = - root you = / mnt / data / kubelet

2 Restart kubelet service

Sudo systemctl restart kubelet

3 confirm the changes to take effect

ps aux | grep kubelet

See "--root-dir = / mnt / data / kubelet", described modified successfully.

Guess you like

Origin www.cnblogs.com/abcdef/p/12046236.html