bash
复制代码
1. 先通过上面链接下载gz包
2. 解压
[root@k8s-master ~]# tar xf etcd-v3.5.11-linux-amd64.tar.gz
[root@k8s-master etcd-v3.5.11-linux-amd64]# ls
Documentation etcd etcdctl etcdutl README-etcdctl.md README-etcdutl.md README.md READMEv2-etcdctl.md
3.将etcdctl命令拷贝至/usr/local/bin目录下,这样就可以直接通过命令行工具使用了
[root@k8s-master etcd-v3.5.11-linux-amd64]# cp etcdctl /usr/local/bin/
4.在/etc/profile文件最下面追加以下4行
export ETCDCTL_API=3
export ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt
export ETCDCTL_CERT=/etc/kubernetes/pki/etcd/peer.crt
export ETCDCTL_KEY=/etc/kubernetes/pki/etcd/peer.key
[root@k8s-master etcd-v3.5.11-linux-amd64]# source /etc/profile
5.此时ectdctl命令就可以使用了
#查看版本
[root@k8s-master etcd-v3.5.11-linux-amd64]# etcdctl version
etcdctl version: 3.5.11
API version: 3.5
#获取pods资源
[root@k8s-master etcd-v3.5.11-linux-amd64]# etcdctl get /registry/pods --prefix --keys-only=true
/registry/pods/kube-system/calico-kube-controllers-fc945b5f7-mjgdk
/registry/pods/kube-system/calico-node-2fxpz
/registry/pods/kube-system/calico-node-kmwnp
/registry/pods/kube-system/calico-node-w77xr
/registry/pods/kube-system/coredns-844c6bb88b-k59dn
/registry/pods/kube-system/coredns-844c6bb88b-klwn4
/registry/pods/kube-system/etcd-k8s-master
/registry/pods/kube-system/kube-apiserver-k8s-master
/registry/pods/kube-system/kube-controller-manager-k8s-master
/registry/pods/kube-system/kube-proxy-4tmsx
/registry/pods/kube-system/kube-proxy-br6kf
/registry/pods/kube-system/kube-proxy-vvwnq
/registry/pods/kube-system/kube-scheduler-k8s-master
/registry/pods/mywork/myhttp
/registry/pods/mywork/pod1