【k8s】dial tcp 192.168.132.11:6443: connect: connection refused

今天博主登陆了好久没登陆的自己在家搭建的k8s集群,突然发现master节点执行以下命令产生了报错,以为是api-server没起来,重启了好几次没起来,一通百度还是没有解决问题。

kubectl get node
# 报错内容提示无法连接本地6443端口

突然想到了证书的问题,一查,已经过期两个多月了

# 查看各个组件证书过期时间
kubeadm certs check-expiration
CERTIFICATE                EXPIRES                  RESIDUAL TIME   CERTIFICATE AUTHORITY   EXTERNALLY MANAGED
admin.conf                 Dec 20, 2022 15:21 UTC   364d                                    no      
apiserver                  Dec 20, 2022 15:21 UTC   364d            ca                      no      
apiserver-etcd-client      Dec 20, 2022 15:21 UTC   364d            etcd-ca                 no      
apiserver-kubelet-client   Dec 20, 2022 15:21 UTC   364d            ca                      no      
controller-manager.conf    Dec 20, 2022 15:21 UTC   364d                                    no      
etcd-healthcheck-client    Dec 20, 2022 15:21 UTC   364d            etcd-ca                 no      
etcd-peer                  Dec 20, 2022 15:21 UTC   364d            etcd-ca                 no      
etcd-server                Dec 20, 2022 15:21 UTC   364d            etcd-ca                 no      
front-proxy-client         Dec 20, 2022 15:21 UTC   364d            front-proxy-ca          no      
scheduler.conf             Dec 20, 2022 15:21 UTC   364d                                    no      

CERTIFICATE AUTHORITY   EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
ca                      Nov 10, 2030 10:01 UTC   8y              no      
etcd-ca                 Nov 10, 2030 10:01 UTC   8y              no      
front-proxy-ca          Nov 10, 2030 10:01 UTC   8y              no

只要是通过kubeadm安装的k8s集群,可以通过以下命令来进行证书的续签

# 续签证书
kubeadm certs renew all

随后执行以下命令,将更新配置文件,就可以正常执行kubectl命令了。

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

你可能感兴趣的:(linux,k8s)