一、etcdctl常用命令

1、kg po -n openshift-etcd 
2、k exec -it -n openshift-etcd etcd-hdskbc02m01-002.hdskbc02.paasmgmt.cmbchina.cn /bin/sh
3、查看etcd中的所有key:etcdctl get --keys-only --from-key / 
4、etcdctl get /kubernetes.io/deployments/lt81-05-vela-dev/apiserver-for-cloud
5、etcdctl get /kubernetes.io/core.oam.dev/applications/lt31-04-dev/lt31-04-fourier28-dev-dev
6、删除cr:etcdctl del /kubernetes.io/core.oam.dev/applications/lt31-04-dev/lt31-04-fourier28-dev-dev
7、删除cr:etcdctl del /kubernetes.io/core.oam.dev/resourcetrackers/lt31-04-fourier28-dev-dev-v1-lt31-04-dev
8、删除deployment:etcdctl del /kubernetes.io/deployments/za20-control/springboot20220824
9、删除cr:etcdctl del /kubernetes.io/scaler.oam.cmb/podscalers/lt31-04-dev/lt31-04-fourier28-dev-dev-fourier28-web-270519

10、整理碎片 etcdctl defrag

二、etcd删除k8s资源

etcdctl直接删除application时, deployment、rt等不会被删除,可以通过再次部署appfile把application直接恢复出来;

etcdctl直接删除deployment时,rs和pod会被级联删除;

etcdctl直接删除某种资源会有delete event产生,但是也需要控制器单独处理这种delete event才能做到级联删除。

三、etcd数据备份

备份:etcdctl snapshot save snapshot.db --debug

恢复:etcdctl snapshot restore snapshot.db