如何在 etcd 中访问 kubernetes 密钥 [英] How to access kubernetes keys in etcd

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

问题描述

如何从 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创建集群

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屋!

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