背景

k8s中的网络配置和对象状态信息都会保存到etcd中,所以我们可以通过etcdctl查看保存在数据库中的信息

常用操作

  • 查看etcd的各个节点的状态
[root@master3 ~]# etcdctl --endpoints="10.197.115.27:2379,10.197.115.25:2379,10.197.115.26:2379" --cacert=/etc/ssl/etcd/ssl/ca.pem  --cert=/etc/ssl/etcd/ssl/member-master3.pem --key=/etc/ssl/etcd/ssl/member-master3-key.pem  endpoint health
10.197.115.25:2379 is healthy: successfully committed proposal: took = 11.379015ms
10.197.115.26:2379 is healthy: successfully committed proposal: took = 19.969601ms
10.197.115.27:2379 is healthy: successfully committed proposal: took = 27.590939ms
  • k8s所有的资源信息都保存在/registry中
[root@master3 ~]# etcdctl --endpoints="10.197.115.27:2379,10.197.115.25:2379,10.197.115.26:2379" --cacert=/etc/ssl/etcd/ssl/ca.pem  --cert=/etc/ssl/etcd/ssl/member-master3.pem --key=/etc/ssl/etcd/ssl/member-master3-key.pem  --prefix --keys-only=true  get /registry
/registry/apiextensions.k8s.io/customresourcedefinitions/apiservices.management.cattle.io
/registry/apiextensions.k8s.io/customresourcedefinitions/applications.argoproj.io
/registry/apiextensions.k8s.io/customresourcedefinitions/applicationsets.argoproj.io
/registry/apiextensions.k8s.io/customresourcedefinitions/appprojects.argoproj.io
/registry/apiextensions.k8s.io/customresourcedefinitions/apps.catalog.cattle.io
/registry/apiextensions.k8s.io/customresourcedefinitions/authconfigs.management.cattle.io
/registry/apiextensions.k8s.io/customresourcedefinitions/bgpconfigurations.crd.projectcalico.org
/registry/apiextensions.k8s.io/customresourcedefinitions/bgppeers.crd.projectcalico.org
/registry/apiextensions.k8s.io/customresourcedefinitions/blockaffinities.crd.projectcalico.org
/registry/apiextensions.k8s.io/customresourcedefinitions/caliconodestatuses.crd.projectcalico.org
/registry/apiextensions.k8s.io/customresourcedefinitions/clusterinformations.crd.projectcalico.org
/registry/apiextensions.k8s.io/customresourcedefinitions/clusterregistrationtokens.management.cattle.io

  • 查看保存在registry中的信息,这里以/registry/clusterroles/system:kube-dns为例
[root@master3 ~]# etcdctl --endpoints="10.197.115.27:2379,10.197.115.25:2379,10.197.115.26:2379" --cacert=/etc/ssl/etcd/ssl/ca.pem  --cert=/etc/ssl/etcd/ssl/member-master3.pem --key=/etc/ssl/etcd/ssl/member-master3-key.pem  --prefix --keys-only=false  get /registry/clusterroles/system:kube-dns

在这里插入图片描述

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐