etcd执行命令报错Error: context deadline exceeded
报错如下:
[root@xian-01 ~]# etcdctl member list -w table
{"level":"warn","ts":"2023-07-04T02:02:43.589-0700","caller":"clientv3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"endpoint://client-a79 2bc6b-d970-4ef4-bc35-967ec14c794e/127.0.0.1:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: all SubConns are in TransientFailure, latest connection error: connection closed"}
Error: context deadline exceeded
原因:
k8s中etcd现在默认v3,必须提供ca、key、cert,否则会出现Error: context deadline exceeded
不加–endpoint参数时,默认访问的127.0.0.1:2379,而使用–endpoint参数时,必须提供ca,key,cert
[root@xian-01 etcd]# etcdctl --endpoints=127.0.0.1:2379 --cert=/etc/kubernetes/pki/etcd/server.crt --cacert=/etc/kubernetes/pki/etcd/ca.crt --key=/etc/kubernetes/pki/etcd/server.key member list -w table
+------------------+---------+---------+-----------------------------+-----------------------------+------------+
| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER |
+------------------+---------+---------+-----------------------------+-----------------------------+------------+
| 116997aec559b0e6 | started | xian-01 | https://192.168.19.146:2380 | https://192.168.19.146:2379 | false |
+------------------+---------+---------+-----------------------------+-----------------------------+------------+
证书位置:
是用kubeadmin方式安装的证书 etcd相关证书默认存储在/etc/kubernetes/pki/etcd
目录下
[root@xian-01 etcd]# ls
ca.crt ca.key healthcheck-client.crt healthcheck-client.key peer.crt peer.key server.crt server.key