使用kubeadm安装k8s集群后,想要查看etcd中关于k8s集群的信息,但是使用kubectl exec xxx -- etcdctl --ca-file xxx --cert-file xxxx --key-file xxx endpoints https:127.0.0.1:2379 member list提示Error: unknown flag: --ca-file,如下
[root@k8s-3 manifests]# kubectl exec -it -n kube-system etcd-k8s-3 \ > -- etcdctl \ > --ca-file=/etc/kubernetes/pki/etcd/ca.crt \ > --cert-file=/etc/kubernetes/pki/etcd/peer.crt \ > --key-file=/etc/kubernetes/pki/etcd/peer.key \ > member list Error: unknown flag: --ca-file NAME: member list - Lists all members in the cluster USAGE: etcdctl member list [flags] DESCRIPTION: When --write-out is set to simple, this command prints out comma-separated member lists for each endpoint. The items in the lists are ID, Status, Name, Peer Addrs, Client Addrs, Is Learner. OPTIONS: -h, --help[=false]help for list GLOBAL OPTIONS: --cacert=""verify certificates of TLS-enabled secure servers using this CA bundle --cert=""identify secure client using this TLS certificate file --command-timeout=5stimeout for short running command (excluding dial timeout) --debug[=false]enable client-side debug logging --dial-timeout=2sdial timeout for client connections -d, --discovery-srv=""domain name to query for SRV records describing cluster endpoints --discovery-srv-name=""service name to query when using DNS discovery --endpoints=[127.0.0.1:2379]gRPC endpoints --hex[=false]print byte strings as hex encoded strings --insecure-discovery[=true]accept insecure SRV records describing cluster endpoints --insecure-skip-tls-verify[=false]skip server certificate verification --insecure-transport[=true]disable transport security for client connections --keepalive-time=2skeepalive time for client connections --keepalive-timeout=6skeepalive timeout for client connections --key=""identify secure client using this TLS key file --password=""password for authentication (if this option is used, --user option shouldn't include password) --user=""username[:password] for authentication (prompt if password is not supplied) -w, --write-out="simple"set the output format (fields, json, protobuf, simple, table) Error: unknown flag: --ca-file command terminated with exit code 1
提示不识别--ca-file,其实以上的信息已经提示到问题的切入点了,但是感觉太依赖百度了,没有仔细的查看提示信息,在网上收搜了很多信息,操作了很多还是一样的报错,最后突然醒悟,查看了etcdctl的帮助,看到了 --cacert="",--cert="",--key=""的选项,这些信息已经在命令执行错误的提示信息中有提示了,没有仔细的查看,哎哎,因为这个问题耽误了许多的时间,真是太不值当的,以后要相信自己,仔细观察日志。
etcdctl的版本为: VERSION:3.4.3 API=3 的环境下
最终执行的信息:
[root@k8s-3 manifests]# kubectl exec -it -n kube-system etcd-k8s-3 -- etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key --endpoints https://127.0.0.1:2379 member list -w table +------------------+---------+-------+-----------------------------+-----------------------------+------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | +------------------+---------+-------+-----------------------------+-----------------------------+------------+ | 74cd7be96f035358 | started | k8s-3 | https://192.168.191.30:2380 | https://192.168.191.30:2379 | false | +------------------+---------+-------+-----------------------------+-----------------------------+------------+
API=2下查看:
kubectl exec -it -n kube-system etcd-k8s-3 -- etcdctl --ca-file=xxxxx --cert-file=/xxx --key-file=xxxxx \