Skip to content

Instantly share code, notes, and snippets.

@keyan
Last active October 16, 2019 06:17
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 keyan/212c0f00dc0ec32fdef28d0995289e85 to your computer and use it in GitHub Desktop.
Save keyan/212c0f00dc0ec32fdef28d0995289e85 to your computer and use it in GitHub Desktop.
Upgrading etcd cluster from APIv2 data storage to APIv3 data storage for Kubernetes

Checklist for offline etcd v2 API -> v3 API

Adapted from https://coreos.com/etcd/docs/latest/op-guide/v2-migration.html#migrate-data

Note that this strategy results in kube-apiserver downtime, but this should not affect the state of the cluster, it will only prevent changes during the migration

  • Ensure there is no v3 data in etcd as this will be overwritten during the migration, verify that the output of the following command is 0:
ETCDCTL_API=3 etcdctl get "" --from-key --keys-only --limit 1 | wc -l
  • Stop Chef on the kube-apiservers: sudo service chef-client stop
  • Stop apiserver on the kube-apiservers to prevent writing new data during the migration: $ systemctl stop kube-apiserver.service
  • Wait for ~1 minute for all state on all etcd nodes to converge
  • Verify that node state has convered using by checking that the raft index of all members is the same (or off by 1) beta:
$ ETCDCTL_API=3 etcdctl --endpoints "http://172.20.240.5:2379,http://172.20.240.6:2379,http://172.20.240.7:2379" -w table endpoint status

prod:

$ ETCDCTL_API=3 etcdctl --endpoints "http://172.31.0.96:2379,http://172.31.0.135:2379,http://172.31.0.219:2379" -w table endpoint status
  • Stop etcd on every member in the cluster: $ sudo systemctl stop etcd-etcd<#>.service
  • Migrate all etcd v2 keys into v3 by executing the following command on every member in the cluster: $ ETCDCTL_API=3 etcdctl migrate --data-dir /var/lib/etcd
  • Confirm that keys have been migrated the following command should return a non-zero value:
$ ETCDCTL_API=3 etcdctl get "" --from-key --keys-only --limit 1 | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment