Skip to content

Instantly share code, notes, and snippets.

@mowings
Last active January 24, 2020 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mowings/4c3c51a12f40aac77c6558b0496dce32 to your computer and use it in GitHub Desktop.
Save mowings/4c3c51a12f40aac77c6558b0496dce32 to your computer and use it in GitHub Desktop.
Change etcd data dir on running kubernetes master node

This works as of kubernetes 1.16.4

I use a symlink rather than changing the config in /etc/kubernetes/manifests. You can do it either way.

First get the id of the running etcd container:

# docker ps | grep etcd
b006a4f993d0 .... # Your id will be different, obv.

Next stop the kubelet:

# systemctl stop kubelet

Stop etcd

docker stop b006a4f993d0

Copy the old etcd data dir over to the new mount

cp -rp /var/lib/etcd /mnt/fast-ssd

Verify that the contents in the new dir are the same as the old. Then rename the old etcd dir and create the link

mv /var/lib/etcd /var/lib/etcd.old
ln -s /mnt/fast-ssd/etcd /var/lib/etcd

Verify that the link is correct. Then restart the kubelet

systemctl start kubelet

The kubelet will restart etcd automatically, but it will take a minute. Once started, check the docker log for etcd to be sure everything is ok.

If etcd is not starting up, check the kubelet log. Verify that the link poits to the correct place and that the files were copied over correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment