...
Code Block |
---|
language | bash |
---|
title | etcd certificates |
---|
|
# Insert the following lines inside the ".bashrc" file, then use "$ source .bashrc" to apply the changes
export ETCDCTL_CERT=/<path>/cert.pem
export ETCDCTL_CACERT=/<path>/ca.pem
export ETCDCTL_KEY=/<path>/key.pem
ETCDCTL_ENDPOINTS=etcd1:2379,etcd2:2379,etcd3:2379 |
Let's try running some commands, to check the status of the etcd cluster
Code Block |
---|
language | bash |
---|
title | Example commands |
---|
|
$ etcdctl member list --write-out=table
+------------------+---------+-------+------------------------------+------------------------------+------------+
| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER |
+------------------+---------+-------+------------------------------+------------------------------+------------+
| 10d6fab05b506a11 | started | etcd3 | https://192.168.100.180:2380 | https://192.168.100.180:2379 | false |
| 263e9aba708b17f7 | started | etcd1 | https://192.168.100.151:2380 | https://192.168.100.151:2379 | false |
| 74e5f49a4cd290f1 | started | etcd2 | https://192.168.100.88:2380 | https://192.168.100.88:2379 | false |
+------------------+---------+-------+------------------------------+------------------------------+------------+
$ etcdctl endpoint health --write-out=table
+------------+--------+--------------+-------+
| ENDPOINT | HEALTH | TOOK | ERROR |
+------------+--------+--------------+-------+
| etcd2:2379 | true | 10.314162ms | |
| etcd1:2379 | true | 10.775429ms | |
| etcd3:2379 | true | 114.846224ms | |
+------------+--------+--------------+-------+
$ etcdctl endpoint status --write-out=table
+------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| etcd1:2379 | 263e9aba708b17f7 | 3.5.4 | 31 MB | false | false | 5 | 296505 | 296505 | |
| etcd2:2379 | 74e5f49a4cd290f1 | 3.5.4 | 30 MB | true | false | 5 | 296505 | 296505 | |
| etcd3:2379 | 10d6fab05b506a11 | 3.5.4 | 30 MB | false | false | 5 | 296505 | 296505 | |
+------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ |
Save and Restore
Warning |
---|
If you have an etcd cluster, you can select only one node, otherwise you get the error snapshot must be requested to one selected node, not multiple . Then unset the ETCDCTL_ENDPOINTS environment variable, if present. |
Take a snapshot of the etcd datastore using the following command, which generates the <snapshot>
file
...
Code Block |
---|
language | bash |
---|
title | Restore snapshot |
---|
|
# The destination directory must be empty and obviously have write permissions
$ etcdctl [--data-dir <data_dir>] snapshot restore <path>/<snapshot>
$ etcdctl --data-dir /tmp/snap_dir snapshot restore snapshot.db
# Paste the snapshot into the path where the etcd node data are stored
$ cp -r /tmp/snap_dir/member /var/lib/etcd/ |
BackUp CronJob
To make a periodic backup of the etcd node(s), try using this Helm Chart.
Code Block |
---|
language | bash |
---|
title | Helm Chart |
---|
|
# Add and update repository
$ helm repo add adfinis https://charts.adfinis.com
$ helm repo update
# Customize and install chart
$ helm show values adfinis/openshift-etcd-backup > <values.yaml>
$ helm install <chart_name> adfinis/openshift-etcd-backup -n <namespace> [--create-namespace --values <values.yaml>]
# Upgrade or uninstall chart
$ helm upgrade <chart_name> adfinis/openshift-etcd-backup -n <namespace> [--values <values.yaml>]
$ helm uninstall <chart_name> -n <namespace> |