Unable to connect to the server: x509: certificate is valid for kubernetes, kubernetes.default, kube...

k8s部署问题简记

Unable to connect to the server: x509: certificate is valid for kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster, kubernetes.default.svc.cluster.local., not kube-master

看到这个错误,请注意最后not后的参数,我这里是 kube-master,请将这个值添加到 kubernetes-csr.json 中,举例:

cat > kubernetes-csr.json <

重新生成 kubernets证书和密钥,举例

cfssl gencert -ca=/opt/k8s/work/ca.pem \
  -ca-key=/opt/k8s/work/ca-key.pem \
  -config=/opt/k8s/work/ca-config.json \
  -profile=kubernetes kubernetes-csr.json | cfssljson -bare kubernetes
ls kubernetes*pem
cp kubernetes*pem /etc/kubernetes/cert

重启 kube-apiserver

systemctl restart kube-apiserver

测试

kubectl cluster-info

出现下图说明正常了

引用书籍:https://s.itho.me/day/2017/k8s/1020-1100 All The Troubles You Get Into When Setting Up a Production-ready Kubernetes Cluster.pdf

你可能感兴趣的:(问题解决,#,Kubernetes,kubernetes,etcd,json,docker,java)