首页 > 其他分享 >kubeadm部署的k8s证书过期问题 k8s问题排查:the existing bootstrap client certificate in /etc/kubernetes/kubelet.co

kubeadm部署的k8s证书过期问题 k8s问题排查:the existing bootstrap client certificate in /etc/kubernetes/kubelet.co

时间:2023-11-10 22:45:07浏览次数:47  
标签:kubernetes certificate etc 22 41564 kubelet master k8s

 

解决问题:

估计跟移动有关,下面那个没解决问题,是因为在原有文件的基础上修改的吧?而这里直接是移走,重新生成了新的。不太清楚是不是这个原因。

$ cd /etc/kubernetes/pki/
$ mv {apiserver.crt,apiserver-etcd-client.key,apiserver-kubelet-client.crt,front-proxy-ca.crt,front-proxy-client.crt,front-proxy-client.key,front-proxy-ca.key,apiserver-kubelet-client.key,apiserver.key,apiserver-etcd-client.crt} ~/
$ kubeadm init phase certs all
$ cd /etc/kubernetes/
$ mv {admin.conf,controller-manager.conf,kubelet.conf,scheduler.conf} ~/
$ kubeadm init phase kubeconfig all
$ reboot
$ cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

 

没解决问题前,执行命令访问不了

[root@mcwk8s-master /etc/kubernetes]$ kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?
[root@mcwk8s-master /etc/kubernetes]$ 

 

可以正常访问了

[root@mcwk8s-master /etc/kubernetes]$ kubectl get nodes
NAME            STATUS   ROLES                  AGE    VERSION
mcwk8s-master   Ready    control-plane,master   658d   v1.23.1
mcwk8s-node1    Ready    <none>                 658d   v1.23.1
mcwk8s-node2    Ready    <none>                 658d   v1.23.1
[root@mcwk8s-master /etc/kubernetes]$ 

 

 即使过期问题解决了,并且kubectl命令执行不报错了,但是kubelet依然状态有错误信息

[root@mcwk8s-master /etc/kubernetes]$ systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Fri 2023-11-10 22:12:49 CST; 10min ago
     Docs: https://kubernetes.io/docs/
 Main PID: 41564 (kubelet)
   Memory: 38.9M
   CGroup: /system.slice/kubelet.service
           └─41564 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --c...

Nov 10 22:12:51 mcwk8s-master kubelet[41564]: I1110 22:12:51.055339   41564 reconciler.go:216] "operationExecutor.VerifyControllerAttachedVolum...
Nov 10 22:12:51 mcwk8s-master kubelet[41564]: I1110 22:12:51.055369   41564 reconciler.go:216] "operationExecutor.VerifyControllerAttachedVolum...
Nov 10 22:12:51 mcwk8s-master kubelet[41564]: I1110 22:12:51.055388   41564 reconciler.go:157] "Reconciler: start to sync state"
Nov 10 22:12:52 mcwk8s-master kubelet[41564]: I1110 22:12:52.164131   41564 request.go:665] Waited for 1.005490743s due to client-side t...y/token
Nov 10 22:12:53 mcwk8s-master kubelet[41564]: E1110 22:12:53.174259   41564 kubelet.go:1711] "Failed creating a mirror pod for" err="pod...master"
Nov 10 22:12:53 mcwk8s-master kubelet[41564]: E1110 22:12:53.380123   41564 kubelet.go:1711] "Failed creating a mirror pod for" err="pod...master"
Nov 10 22:12:53 mcwk8s-master kubelet[41564]: E1110 22:12:53.580643   41564 kubelet.go:1711] "Failed creating a mirror pod for" err="pod...master"
Nov 10 22:12:53 mcwk8s-master kubelet[41564]: E1110 22:12:53.777755   41564 kubelet.go:1711] "Failed creating a mirror pod for" err="pod...master"
Nov 10 22:12:58 mcwk8s-master kubelet[41564]: I1110 22:12:58.422831   41564 prober_manager.go:255] "Failed to trigger a manual run" prob...diness"
Nov 10 22:12:59 mcwk8s-master kubelet[41564]: I1110 22:12:59.838708   41564 prober_manager.go:255] "Failed to trigger a manual run" prob...diness"
Hint: Some lines were ellipsized, use -l to show in full.
[root@mcwk8s-master /etc/kubernetes]$ 

 

 

没解决问题:

 

 

journalctl -u kubelet --no-pager 发现kubelet启动失败

E0728 23:35:23.526561 12500 bootstrap.go:265] part of the existing bootstrap client certificate in /etc/kubernetes/kubelet.conf is expired: 2022-10-05 03:16:49 +0000 UTC
E0728 23:35:23.526583 12500 server.go:292] "Failed to run kubelet" err="failed to run Kubelet: unable to load bootstrap kubeconfig: stat /etc/kubernetes/bootstrap-kubelet.conf: no such file or directory

从日志给出的提示说明是证书过期导致。

统一查看证书是否过期 :
kubeadm certs check-expiration

 

过期,需要重新生成证书

备份并重新生成证书
cp -r /etc/kubernetes/pki /etc/kubernetes/pki.bak20230729
cd /etc/kubernetes/pki
kubeadm certs renew all

备份并重新生成配置文件
cp -r /etc/kubernetes /etc/kubernetes.bak
cd /etc/kubernetes
kubeadm init phase kubeconfig all

重启kubelet
systemctl restart kubelet

用更新后的admin.conf替换/root/.kube/config文件
cp /etc/kubernetes/admin.conf ~/.kube/config

这时候一定要注意是否存在.kube文件夹,有的话一定要先删除,否则永远卡在激活中状态

 

 


执行完删除命令,在执行上面的复制命令

rm -rf $HOME/.kube
cp /etc/kubernetes/admin.conf ~/.kube/config

查看kubelet启动状态
systemctl status kubelet

 


参考资料:kubernetes 坑人的错误!!!Unable to connect to the server: x509: certificate signed by unknown authority

原文链接:https://blog.csdn.net/paopaodog/article/details/131990391

 

 

$ cd /etc/kubernetes/pki/
$ mv {apiserver.crt,apiserver-etcd-client.key,apiserver-kubelet-client.crt,front-proxy-ca.crt,front-proxy-client.crt,front-proxy-client.key,front-proxy-ca.key,apiserver-kubelet-client.key,apiserver.key,apiserver-etcd-client.crt} ~/
$ kubeadm init phase certs all
$ cd /etc/kubernetes/
$ mv {admin.conf,controller-manager.conf,kubelet.conf,scheduler.conf} ~/
$ kubeadm init phase kubeconfig all
$ reboot
$ cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

 

标签:kubernetes,certificate,etc,22,41564,kubelet,master,k8s
From: https://www.cnblogs.com/machangwei-8/p/17825251.html

相关文章

  • 以 Kubernetes 原生方式实现多集群告警
    作者:向军涛、雷万钧来源:2023上海KubeCon分享可观测性来源在Kubernetes集群上,各个维度的可观测性数据,可以让我们及时了解集群上应用的状态,以及集群本身的状态。Metrics指标:监控对象状态的量化信息,通常会以时序数据的形式采集和存储。Events:这里特指的是Kubernetes集群上所......
  • 以 Kubernetes 原生方式实现多集群告警
    作者:向军涛、雷万钧来源:2023上海KubeCon分享可观测性来源在Kubernetes集群上,各个维度的可观测性数据,可以让我们及时了解集群上应用的状态,以及集群本身的状态。Metrics指标:监控对象状态的量化信息,通常会以时序数据的形式采集和存储。Events:这里特指的是Kubernetes......
  • k8s部署业务服务(详细总结篇)
    1.业务部署说明我们是做算法的,每个算法会被封装成一个镜像,比如:image1(入侵算法),image2(安全带识别算) 结合k8s流程:ingress-nginx(做了hostNetwork:true 网络模式,省去了service的一成转发),直接可以访问ingress-nginx的域名和端口——>客户通过ingress发布的host+path+业务......
  • K8S基础:搭建K8S集群(v1.27.6)
    Kubernetes 是一个可移植、可扩展的开源平台,用于管理容器化的工作负载和服务,可促进声明式配置和自动化。Kubernetes拥有一个庞大且快速增长的生态,其服务、支持和工具的使用范围相当广泛。准备节点主机名IP系统&内核配置master01k8s0110.70.5.190Centos7.9,Kernel5.4.259-1.el7.el......
  • 手把手教你在虚拟机中部署Kubernetes集群(K8S)
    我们在上面:VM部署CentOS并且设置网络 部署好了服务器。接下来需要准备三个服务器分别为master节点:master  192.168.171.7node节点:node1  192.168.171.6node节点:node2  192.168.171.4此步骤需要启动三台虚拟机,并且使用xshell进行连接使用执行多个的命令来在每个服务器同步......
  • 使用rancher rke快速安装k8s集群
    概述RancherKubernetesEngine(RKE)是一个用于部署、管理和运行Kubernetes集群的开源工具。旨在简化Kubernetes集群的部署和操作。RKE具有以下特点和功能:简化的部署过程RKE提供了一个简单的命令行界面,使您可以轻松地部署一个完整的Kubernetes集群。您只需提供少量的配置信息,RKE......
  • k8s入门学习
    k8s入门https://kubernetes.io/zh-cn/docs/tutorials/hello-minikube/minikube启动集群minikubestart创建实例kubectlcreatedeploymentgin--image=gin_demo:v1会创建相对应的pod和deployment此时服务端口只能内部集群访问端口暴露使用expose将服务端口暴露进行访......
  • 容器云平台No.8~kubernetes负载均衡之ingress-nginx
    容器云平台No.8~kubernetes负载均衡之ingress-nginxIngress是什么?Ingress公开了从集群外部到集群内服务的HTTP和HTTPS路由。流量路由由Ingress资源上定义的规则控制。可以将Ingress配置为服务提供外部可访问的URL、负载均衡流量、终止SSL/TLS,以及提供基于名称的虚......
  • Kubernetes常用命令及yml文件、集群网络 Kubernetes组件介绍及环境搭建
    Kubernetes常用命令及yml文件、集群网络Kubernetes组件介绍及环境搭建Kubernetes组件介绍及环境搭建一、kubernetes常用命令说明:因为k8s的命令都是通过kubectl组件接收的,这个组件只在master节点有,所以k8s的命令都是在master节点中执行kubectlgetnodes#查看当前集群中......
  • centos7.9安装kubernetes1.27.4版本
    ./etc/os-releasecolor(){RES_COL=60MOVE_TO_COL="echo-en\\033[${RES_COL}G"SETCOLOR_SUCCESS="echo-en\\033[1;32m"SETCOLOR_FAILURE="echo-en\\033[1;31m"SETCOLOR_WARNING="echo-en\\0......