如何在etcd中访问kubernetes密钥 [英] How to access kubernetes keys in etcd
问题描述
如何从etcd获取与Kubernetes相关的密钥?试图列出etcd中的键,但看不到相关的键.还在哪里安装etcdctl?
How to get the Kubernetes related keys from etcd? Tried to list keys in etcd but could not see related keys. Also where is etcdctl installed?
$ etcdctl
bash: etcdctl: command not found..
$ sudo netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:2379 0.0.0.0:* LISTEN 386/etcd
tcp 0 0 127.0.0.1:2380 0.0.0.0:* LISTEN 386/etcd
$ curl -s http://localhost:2379/v2/keys | python -m json.tool
{
"action": "get",
"node": {
"dir": true
}
}
背景
通过遵循使用kubeadm创建集群来安装Kubernetes 1.8.5 在CentOS 7上.当我查看开始使用etcd ,v2/键似乎是终点.
Background
Installed Kubernetes 1.8.5 by following Using kubeadm to Create a Cluster on CentOS 7. When I looked at Getting started with etcd, v2/keys looks to be the end point.
推荐答案
通常,您需要自己获取etcdctl
.只需从 etcd版本页面下载最新的etcdctl
存档.
Usually you need to get etcdctl
by yourself. Just download the latest etcdctl
archive from etcd releases page.
此外,从Kubernetes 1.6版开始,它使用etcd版本3,因此要获取所有键的列表是:
Also, starting from Kubernetes version 1.6 it uses etcd version 3, so to get a list of all keys is:
ETCDCTL_API=3 etcdctl --endpoints=<etcd_ip>:2379 get / --prefix --keys-only
您可以使用以下方法找到所有etcdctl v3
操作:
You can find all etcdctl v3
actions using:
ETCDCTL_API=3 etcdctl --endpoints=<etcd_ip>:2379 --help
编辑(感谢@leodotcloud):
EDIT (thanks to @leodotcloud):
如果ETCD配置了TLS证书支持:
In case ETCD is configured with TLS certificates support:
ETCDCTL_API=3 etcdctl --endpoints <etcd_ip>:2379 --cacert <ca_cert_path> --cert <cert_path> --key <cert_key_path> get / --prefix --keys-only
这篇关于如何在etcd中访问kubernetes密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!