etcdctl查看k8s资源信息

背景

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

相关推荐
阿里云云原生2 天前
研发视角的新突破:当 AI Coding 工具集成全域运维诊断,排查线上故障只需 3 分钟
云原生
小猿姐2 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
阿里云云原生3 天前
AgentTeams 和 Claude Tag 都进入群聊模式,是新范式还是新叙事?
云原生·agent
阿里云云原生4 天前
Higress v2.2.3 发布:正式入驻 CNCF Sandbox,AI Gateway 与 Ingress 迁移能力双向加固
云原生
lichenyang4534 天前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4534 天前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4534 天前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
阿里云云原生5 天前
香港站【企业 AI Agent 工程化实战专场】来啦,邀您7月9日见!
云原生·agent
阿里云云原生5 天前
研发域与运维域的“数字握手”:通过 Agentic Skills 实现 DevOps 全链路自动化
云原生
运维开发故事7 天前
基于 Arthas 的多集群在线诊断系统设计与实现
kubernetes