在etcd中看不到kubernetes的数据

查看:433
本文介绍了在etcd中看不到kubernetes的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

k8s中的数据(如namespace)是保存在etcd中的吧?如果不是的话请告诉我,然后不用看下面的了 :)

说明:我是etcd新手,之前没用过,它的一些概念不了解

我通过命令hack/local-up-cluster.sh启动的k8s
启动后查看apiserver和etcd如下:

root@ming:/tmp# ps aux|grep apiserver
root      96196 18.0  5.3 379444 108668 pts/1   Sl+  19:33   0:01 /home/ming/project/golang/src/k8s.io/kubernetes/_output/bin/hyperkube apiserver --v=3 --cert-dir=/var/run/kubernetes --client-ca-file=/var/run/kubernetes/client-ca.crt --service-account-key-file=/tmp/kube-serviceaccount.key --service-account-lookup=false --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,SecurityContextDeny,ResourceQuota,DefaultStorageClass --bind-address=0.0.0.0 --secure-port=6443 --tls-ca-file=/var/run/kubernetes/apiserver.crt --insecure-bind-address=127.0.0.1 --insecure-port=8080 --etcd-servers=http://127.0.0.1:2379 --service-cluster-ip-range=10.0.0.0/24 --feature-gates=AllAlpha=true --cloud-provider= --cloud-config= --requestheader-username-headers=X-Remote-User --requestheader-group-headers=X-Remote-Group --requestheader-extra-headers-prefix=X-Remote-Extra- --requestheader-client-ca-file=/var/run/kubernetes/request-header-ca.crt --requestheader-allowed-names=system:auth-proxy --cors-allowed-origins=/127.0.0.1(:[0-9]+)?$,/localhost(:[0-9]+)?$

root@ming:/tmp# ps aux|grep etcd
root      96079  2.8  1.0 10518408 22272 pts/1  Sl+  19:33   0:01 etcd --advertise-client-urls http://127.0.0.1:2379 --listen-client-urls http://127.0.0.1:2379 --debug

根据上面的输出k8s是连接到http://127.0.0.1:2379上的etcd并且我的机器上只启动了一个etcd

查看namespace发现是有数据的:

root@ming:/tmp# kubectl get ns
NAME          STATUS    AGE
default       Active    4m
kube-system   Active    4m

然后在etcd中看不到k8s的数据:

root@ming:/tmp# etcdctl --endpoints=http://127.0.0.1:2379 ls
root@ming:/tmp# 

开始以为etcd像redis那样有多个数据库,没查到相关说明,应该是没有。
后来看到etcd有user的概念,试了一下(也可能是我试的有问题),user a的数据user b也能看到

root@ming:/tmp# etcdctl -u a:a set aaa aaa
aaa
root@ming:/tmp# etcdctl -u a:a ls
/aaa
root@ming:/tmp# etcdctl -u b:b ls
/aaa

所以现在请求帮助,为什么通过etcdctl查不到k8s在etcd中的数据,谢谢。

解决方案

自己找到了原因
使用hack/local-up-cluster.sh启动的k8s会使用etcd v3版本的API记录数据。而默认etcdctl是使用v2版本的API,查看不到v3的数据。设置环境变量ETCDCTL_API=3后就OK了

这篇关于在etcd中看不到kubernetes的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆