首页 > 其他分享 >k8s常见异常

k8s常见异常

时间:2023-04-24 18:34:14浏览次数:40  
标签:certificate ca 常见 apiserver client etcd kubeadm k8s 异常

1、证书过期

[root@kube-master01 kubernetes]# kubectl get node
Unable to connect to the server: x509: certificate has expired or is not yet valid: current time 2023-03-19T09:30:10+08:00 is after 2023-01-24T09:34:35Z

[root@kube-master01 log]# kubeadm certs check-expiration
[check-expiration] Reading configuration from the cluster...
[check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'

[check-expiration] Error reading configuration from the Cluster. Falling back to default configuration

CERTIFICATE                EXPIRES                  RESIDUAL TIME   CERTIFICATE AUTHORITY   EXTERNALLY MANAGED
admin.conf                 Jan 24, 2023 09:34 UTC   <invalid>       ca                      no
apiserver                  Jan 24, 2023 09:34 UTC   <invalid>       ca                      no
apiserver-etcd-client      Jan 24, 2023 09:34 UTC   <invalid>       etcd-ca                 no
apiserver-kubelet-client   Jan 24, 2023 09:34 UTC   <invalid>       ca                      no
controller-manager.conf    Jan 24, 2023 09:34 UTC   <invalid>       ca                      no
etcd-healthcheck-client    Jan 24, 2023 09:34 UTC   <invalid>       etcd-ca                 no
etcd-peer                  Jan 24, 2023 09:34 UTC   <invalid>       etcd-ca                 no
etcd-server                Jan 24, 2023 09:34 UTC   <invalid>       etcd-ca                 no
front-proxy-client         Jan 24, 2023 09:34 UTC   <invalid>       front-proxy-ca          no
scheduler.conf             Jan 24, 2023 09:34 UTC   <invalid>       ca                      no

CERTIFICATE AUTHORITY   EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
ca                      Jan 22, 2032 09:34 UTC   8y              no
etcd-ca                 Jan 22, 2032 09:34 UTC   8y              no
front-proxy-ca          Jan 22, 2032 09:34 UTC   8y              no

[root@kube-master01 log]# date
Sun Mar 19 09:00:21 CST 2023

可以通过 kubeadm certs renew 证书名,更新对应证书,

[root@kube-master01 log]# kubeadm certs renew --help
This command is not meant to be run on its own. See list of available subcommands.

Usage:
  kubeadm certs renew [flags]
  kubeadm certs renew [command]

Available Commands:
  admin.conf               Renew the certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself
  all                      Renew all available certificates
  apiserver                Renew the certificate for serving the Kubernetes API
  apiserver-etcd-client    Renew the certificate the apiserver uses to access etcd
  apiserver-kubelet-client Renew the certificate for the API server to connect to kubelet
  controller-manager.conf  Renew the certificate embedded in the kubeconfig file for the controller manager to use
  etcd-healthcheck-client  Renew the certificate for liveness probes to healthcheck etcd
  etcd-peer                Renew the certificate for etcd nodes to communicate with each other
  etcd-server              Renew the certificate for serving etcd
  front-proxy-client       Renew the certificate for the front proxy client
  scheduler.conf           Renew the certificate embedded in the kubeconfig file for the scheduler manager to use

由于上述过期证书太多,使用命令:kubeadm certs renew all,更新所有证书

更新前最好备份/etc/kubernetes/*.conf 文件

[root@kube-master01 log]# kubeadm certs renew all
[renew] Reading configuration from the cluster...
[renew] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[renew] Error reading configuration from the Cluster. Falling back to default configuration

certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed
certificate for serving the Kubernetes API renewed
certificate the apiserver uses to access etcd renewed
certificate for the API server to connect to kubelet renewed
certificate embedded in the kubeconfig file for the controller manager to use renewed
certificate for liveness probes to healthcheck etcd renewed
certificate for etcd nodes to communicate with each other renewed
certificate for serving etcd renewed
certificate for the front proxy client renewed
certificate embedded in the kubeconfig file for the scheduler manager to use renewed

Done renewing certificates. You must restart the kube-apiserver, kube-controller-manager, kube-scheduler and etcd, so that they can use the new certificates.

 

2、在 kubernetes control plane 服务器上运行 kubeadm certs renew all 命令更新证书后,kubelet 无法正常启动,syslog 在报错信息如下:

"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"

$ 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

对于高可用集群,需要加上 control-plane-endpoint 参数

$ kubeadm init phase certs all --control-plane-endpoint "k8s-api:6443"
$ kubeadm init phase kubeconfig all --control-plane-endpoint "k8s-api:6443"

标签:certificate,ca,常见,apiserver,client,etcd,kubeadm,k8s,异常
From: https://www.cnblogs.com/cnblo/p/17232494.html

相关文章

  • 常见的服务器种类是哪些
    常见的服务器种类是哪些网页服务器 网页服务器主要是指在互联网中存放各种网站的服务器,主要用于企业或个人网站在互联网上的发布、应用,可以说是我们现在使用各种应用及看到的资讯的基础硬件服务器。网页服务器能响应大量IP用户的连接请求。 FTP服务器 FTP服务器是在互联网......
  • TypeScript 学习笔记 — 数组常见的类型转换操作记录(十四)
    获取长度lengthtypeLengthOfTuple<Textendsany[]>=T["length"];typeA=LengthOfTuple<["B","F","E"]>;//3typeB=LengthOfTuple<[]>;//0取第一项FirstItemtypeFirstItem<Textendsany[]>......
  • 00绪论----什么是燃烧?常见的燃烧设备?燃料?
    绪论什么是燃烧?燃烧是燃料和氧气发生剧烈化学反应并伴随着发光发热的现象。燃烧将化学能转化为热能常见的燃烧设备煤粉炉、链条炉、内燃机、燃气轮机、火箭发动机燃气轮机工作原理:压气机将空气吸入并经过逐级压缩送至燃烧器内,在此过程中,空气温度提高,将燃料喷入燃烧器,燃料......
  • k8s 能做到限制pod在节点的指定cpu核心上运行吗?用--cpuset 方式实现,请给出一个具体案
    在Kubernetes中,可以使用--cpuset方式来限制Pod在节点的指定CPU核心上运行。这可以通过在Pod的yaml文件中设置容器启动命令来实现。具体地,我们可以在容器的启动命令中使用--cpuset选项来指定需要运行的CPU核心。下面是一个典型的使用--cpuset选项的Pod的yaml文件示例:apiVersion:......
  • 在项目中遇到的异常问题
    Causedby:java.lang.IllegalStateException产生原因:在接口中使用的时候,没有添加相应的泛型,只需要在对应的接口添加相应的方向就可以了,如下:......
  • grafana面板上出现“Only queries that return single…”异常
    问题现象:数据读取不上,如下图问题根因:启动停止了很多次postgresexport并且这个数据库环境进行恢复快照过,导致Prometheusserver中存在相同实例不同的数据,进而导致通过语法无法确定唯一的数据出现报错。解决方案:通过Prometheus的api对实例的数据进行清空,让export重新获取新的数......
  • 在docker中查看对应k8s容器日志
    个人博客地址:https://note.raokun.top拥抱ChatGPT,国内访问网站:https://www.playchat.top最近遇到在不知道k8s环境只知道k8s部署的docker地址时,需要查看服务日志。dockerinspect容器id|greplog可查看对应的log地址......
  • Java-Day-15( 异常 )
    Java-Day-15异常引出异常(Exception)如:零成分母时,会抛出ArithmeticException异常,然后程序就会崩溃退出,下面的代码也就不执行了但这种不出现致命错误就使得系统崩溃就不合理了所以设计者提供了异常处理机制来解决此问题解决方式—异常捕获如果程序员认为一段......
  • ceph的常见命令
    1、ceph设置回填速度foriin{0..125}docephtellosd.$iinjectargs"--osd_max_backfills1";doneforiin{0..125}docephtellosd.$iinjectargs"--osd_recovery_max_active1";doneforiin{0..125}docephtellosd.$iinjectar......
  • filebeat篇章——QuitStart in K8S
    QuitStartinK8S---apiVersion:v1kind:ConfigMapmetadata:name:filebeat-script-confignamespace:ops-departmentlabels:k8s-app:filebeatdata:set-kafka-topic.js:|functionprocess(event){if(event.Get("kubernetes.name......