检查集群状态
NODE_IPS="10.0.7.18 10.0.7.19 10.0.7.20"
fr ip in {ip}:2379 --cacert=/etc/kubernetes/ssl/ca.pem --cert=/etc/kubernetes/ssl/etcd.pem --key=/etc/kubernetes/ssl/etcd-key.pem endpoint health;done
检查ETCD数据库性能
for ip in {ip}:2379 --cacert=/etc/kubernetes/ssl/ca.pem --cert=/etc/kubernetes/ssl/etcd.pem --key=/etc/kubernetes/ssl/etcd-key.pem check perf;done
检查节点信息
for ip in {ip}:2379 --cacert=/etc/kubernetes/ssl/ca.pem --cert=/etc/kubernetes/ssl/etcd.pem --key=/etc/kubernetes/ssl/etcd-key.pem endpoint status;done
检查成员信息
for ip in {ip}:2379 --cacert=/etc/kubernetes/ssl/ca.pem --cert=/etc/kubernetes/ssl/etcd.pem --key=/etc/kubernetes/ssl/etcd-key.pem member list;done
查看所有的key
etcdctl get / --keys-only --prefix
etcdctl get / --keys-only --prefix | grep calico
添加数据
etcdctl put /node "172.0.7.21"
查询数据
etcdctl get /node
删除数据
etcdctl del /node
监控key
etcdctl watch /node
etcd数据备份
etcdctl snapshot save /opt/test.db
etcd数据还原,备份目录需要为空,不存在会自动创建
etcdctl snapshot restore /opt/test.db --data-dir="/opt/restore"
自动备份数据
cat >script.sh <<eof
#!/bin/bash
DATE=`date +%Y-%m-%d_%H-%M-%S`
etcdctl snapshot save /data/etcd-backup-dir/etcd-snapshot-;db
eof
通过kubeasz备份etcd
./ezctl backup k8s-cluster1
通过kubeasz还原etcd
需要先关掉k8s-master和k8s-node禁止通过apiserver往etcd写入数据
./ezctl restore k8s-cluster1