From 6a6b80a0f8d8b9767d7e0feb98aa4679eb110d2e Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Tue, 3 May 2022 20:03:38 +1000 Subject: [PATCH] Add etcd --- _sidebar.md | 1 + categories/apps/etcd.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 categories/apps/etcd.md diff --git a/_sidebar.md b/_sidebar.md index e27c1bd..d53646c 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -12,6 +12,7 @@ - [Kafka](categories/apps/kafka.md) - [MQTT](categories/apps/mqtt.md) - [Elasticsearch](categories/apps/elasticsearch.md) + - [etcd](categories/apps/etcd.md) - [Database](categories/database.md) - [Application](categories/application.md) - [Web Scraping](categories/web-scraping.md) diff --git a/categories/apps/etcd.md b/categories/apps/etcd.md new file mode 100644 index 0000000..c1c8aea --- /dev/null +++ b/categories/apps/etcd.md @@ -0,0 +1,23 @@ +# etcd + +etcd is a strongly consistent, distributed key-value store that provides a reliable way to store data that needs to be accessed by a distributed system or cluster of machines. It gracefully handles leader elections during network partitions and can tolerate machine failure, even in the leader node. + +## Tips + + +### Make the k8s embedded single etcd to be a cluster + +Unfortunately, there is no straightfoward way to change the existing embedded etcd to a cluster. +But we can leverage etcd `make-mirror` command to replicate the existing etcd to a new cluster. +The steps are: + +1. Follow the guide to setup a new etcd cluster +2. Run the following command to replicate k8s emmbedded etcd data to the new cluster + +``` +sudo ETCDCTL_API=3 etcdctl make-mirror https://new_etcd_node:2379 --endpoints=https://192.168.1.2:2379 --cacert=/k8s_etcd/ca.crt --cert=/k8s_etcd/server.crt --key=/k8s_etcd/server.key --dest-cacert=/new_etcd/ca.pem --dest-cert=/new_etcd/etcd.pem --dest-key=/new_etcd/etcd-key.pem +``` +3. On one of the new cluster node, to verify the data +``` +sudo ETCDCTL_API=3 etcdctl get --prefix=true "" -w json --endpoints=https://127.0.0.1:2379 --cacert=/new_etcd/ca.pem --cert=/new_etcd/etcd.pem --key=/new_etcd/etcd-key.pem +```