kube-apiserver: Error: --etcd-servers must be specified
启动 kube-apiserver 失败,
查看状态:
systemctl status kube-apiserver
cat /var/log/messages|grep kube-apiserver|grep -i error
提示:Error: --etcd-servers must be specified
kube-apiserver.conf 也有配置 --etcd-servers 服务器列表, 可能kube-apiserver.conf格式有问题:
查看配置:
cat /usr/local/kubernetes/cfg/kube-apiserver.conf
KUBE_APISERVER_OPTS="--logtostderr=false \
--v=2 \
--log-dir=/usr/local/kubernetes/logs \
--etcd-servers=https://192.168.153.22:2379,https://192.168.153.20:2379,https://192.168.153.21:2379 \
--bind-address=192.168.153.22 \
--secure-port=6443 \
--advertise-address=192.168.153.22 \
--allow-privileged=true \
--service-cluster-ip-range=10.0.0.0/24 \
--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota,NodeRestriction \
--authorization-mode=RBAC,Node \
--enable-bootstrap-token-auth=true \
--token-auth-file=/usr/local/kubernetes/cfg/token.csv \
--service-node-port-range=30000-32767 \
--kubelet-client-certificate=/usr/local/kubernetes/ssl/server.pem \
--kubelet-client-key=/usr/local/kubernetes/ssl/server-key.pem \
--tls-cert-file=/usr/local/kubernetes/ssl/server.pem \
--tls-private-key-file=/usr/local/kubernetes/ssl/server-key.pem \
--client-ca-file=/usr/local/kubernetes/ssl/ca.pem \
--service-account-key-file=/usr/local/kubernetes/ssl/ca-key.pem \
--etcd-cafile=/usr/local/etcd/ssl/ca.pem \
--etcd-certfile=/usr/local/etcd/ssl/server.pem \
--etcd-keyfile=/usr/local/etcd/ssl/server-key.pem \
--audit-log-maxage=30 \
--audit-log-maxbackup=3 \
--audit-log-maxsize=100 \
--audit-log-path=/usr/local/kubernetes/logs/k8s-audit.log"
多次尝试之后发现问题,kube-apiserver.conf 文件的每一行后面多个了空格,去掉就可以了:(注:必须每一行的末尾空格都要去掉,有一个都会报上面的错误)
去除空格之后重新启动,状态如图: