Kubernetes Views 3

Backing up etcd on Kubernetes

Backing up etcd on Kubernetes image 1

Kubernetes uses etcd, and all of the system’s configuration is stored there.

When a Kubernetes cluster is damaged you can recover through etcd, so it is a good idea to back up etcd regularly.

In simple terms, etcd is like a company vault where all kinds of important information is gathered, and it is like keeping copies of that very important information in several vaults.

etcd is a key-value DB that stores and manages the important information needed to run a distributed system. It is designed to be run as a cluster so that it can reasonably tolerate hardware and network partitions.

You might think of it as playing a role similar to Redis, but etcd supports failover and high availability, which is why Kubernetes adopted it as its database.

etcd also persists all stored data to disk, which strengthens reliability and guarantees consistency.


The etcd package has to be installed before you can use it, so installing it is recommended.

Listing members

  • Check the etcd member list
ETCDCTL_API=3 etcdctl -w table member list \
--endpoints=https://127.0.0.1:2379 \
--cacert /etc/kubernetes/pki/etcd/ca.crt \
--cert /etc/kubernetes/pki/etcd/server.crt \
--key /etc/kubernetes/pki/etcd/server.key
Backing up etcd on Kubernetes image 2
  • Check etcd member status
ETCDCTL_API=3 etcdctl endpoint status --cluster -w table \
--endpoints=https://127.0.0.1:2379 \
--cacert /etc/kubernetes/pki/etcd/ca.crt \
--cert /etc/kubernetes/pki/etcd/server.crt \
--key /etc/kubernetes/pki/etcd/server.key
Backing up etcd on Kubernetes image 3

Backing up etcd

  • Backup
ETCDCTL_API=3 etcdctl snapshot save backup.db \
--endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key


The backup is saved under the filename backup.db.

Reactions

Comments 0

A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.

Comments appear after a review. The password is used again to edit or delete.