From 336a038623a2738214199772dae0cb5bd0750c94 Mon Sep 17 00:00:00 2001 From: chaosky Date: Wed, 29 Aug 2018 17:54:31 +0800 Subject: [PATCH 1/2] etcdctl with tls --- guide/using-etcdctl-to-access-kubernetes-data.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/guide/using-etcdctl-to-access-kubernetes-data.md b/guide/using-etcdctl-to-access-kubernetes-data.md index 3f6fb394f..56367255c 100644 --- a/guide/using-etcdctl-to-access-kubernetes-data.md +++ b/guide/using-etcdctl-to-access-kubernetes-data.md @@ -6,6 +6,12 @@ Kubenretes1.6中使用etcd V3版本的API,使用`etcdctl`直接`ls`的话只 ETCDCTL_API=3 etcdctl get /registry/namespaces/default -w=json|python -m json.tool ``` +如果是使用 kubeadm 创建的集群,在 Kubenretes 1.11 中,etcd 默认使用 tls ,这时你可以在 master 节点上使用以下命令来访问 etcd : + +```bash +ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key get /registry/namespaces/default -w=json | jq . +``` + - `-w`指定输出格式 将得到这样的json的结果: @@ -192,4 +198,4 @@ thirdpartyresources ## 参考 - [etcd中文文档](https://github.com/doczhcn/etcd) -- [etcd官方文档](https://coreos.com/etcd/docs/latest/) \ No newline at end of file +- [etcd官方文档](https://coreos.com/etcd/docs/latest/) From 6ce6ea10f0fa5b79d2c6ee374871809a2b029d48 Mon Sep 17 00:00:00 2001 From: chaosky Date: Wed, 29 Aug 2018 18:11:59 +0800 Subject: [PATCH 2/2] format cli --- guide/using-etcdctl-to-access-kubernetes-data.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/guide/using-etcdctl-to-access-kubernetes-data.md b/guide/using-etcdctl-to-access-kubernetes-data.md index 56367255c..5e0d85e06 100644 --- a/guide/using-etcdctl-to-access-kubernetes-data.md +++ b/guide/using-etcdctl-to-access-kubernetes-data.md @@ -9,7 +9,10 @@ ETCDCTL_API=3 etcdctl get /registry/namespaces/default -w=json|python -m json.to 如果是使用 kubeadm 创建的集群,在 Kubenretes 1.11 中,etcd 默认使用 tls ,这时你可以在 master 节点上使用以下命令来访问 etcd : ```bash -ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key get /registry/namespaces/default -w=json | jq . +ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt \ +--cert=/etc/kubernetes/pki/etcd/peer.crt \ +--key=/etc/kubernetes/pki/etcd/peer.key \ +get /registry/namespaces/default -w=json | jq . ``` - `-w`指定输出格式