模拟问题点

使用kubernetes时错误提示

yang@master:~$ kubectl get nodes

Unable to connect to the server: x509: certificate has expired or is not yet valid: current time 2022-10-25T09:04:19+08:00 is after 2022-09-25T08:17:20Z

解决办法:

一、查看证书过期时间

yang@master:~$ sudo kubeadm certs check-expiration
[sudo] password for yang:
[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'
W1027 09:27:32.225497 46147 utils.go:69] The recommended value for "clusterDNS" in "KubeletConfiguration" is: [10.233.0.10]; the provided value is: [169.254.25.10] CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Oct 25, 2023 08:17 UTC 363d ca no
apiserver Oct 25, 2023 08:17 UTC 363d ca no
apiserver-kubelet-client Oct 25, 2023 08:17 UTC 363d ca no
controller-manager.conf Oct 25, 2023 08:17 UTC 363d ca no
front-proxy-client Oct 25, 2023 08:17 UTC 363d front-proxy-ca no
scheduler.conf Oct 25, 2023 08:17 UTC 363d ca no CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Oct 22, 2032 08:17 UTC 9y no
front-proxy-ca Oct 22, 2032 08:17 UTC 9y no

二、备份现有证书和重新生成新证书

1.备份现有证书

yang@master:~$ ll /etc/kubernetes/
total 292
drwxr-xr-x 5 kube root 4096 Oct 25 16:18 ./
drwxr-xr-x 101 root root 4096 Oct 26 10:38 ../
drwxrwxr-x 2 kube root 4096 Oct 25 16:18 addons/
-rw------- 1 kube root 5659 Oct 25 16:17 admin.conf
-rw------- 1 kube root 5681 Oct 25 16:17 controller-manager.conf
-rw-r--r-- 1 kube root 925 Oct 25 16:18 coredns-svc.yaml
-rw-r--r-- 1 kube root 2670 Oct 25 16:17 kubeadm-config.yaml
-rw------- 1 kube root 1979 Oct 25 16:18 kubelet.conf
drwxr-xr-x 2 kube root 4096 Oct 25 16:17 manifests/
-rw-r--r-- 1 kube root 230001 Oct 25 16:18 network-plugin.yaml
-rw-r--r-- 1 kube root 1040 Oct 25 16:18 nodelocaldnsConfigmap.yaml
-rw-r--r-- 1 kube root 2775 Oct 25 16:18 nodelocaldns.yaml
drwxr-xr-x 2 kube root 4096 Oct 25 16:17 pki/
-rw------- 1 kube root 5633 Oct 25 16:17 scheduler.conf
yang@master:/home$ sudo mkdir config-back
yang@master:/home$ sudo cp -a /etc/kubenetes/ /home/config-back/
yang@master:~$ ll /home/config-back/kubernetes/
total 292
drwxr-xr-x 5 kube root 4096 Oct 25 16:18 ./
drwxr-xr-x 3 root root 4096 Oct 27 09:29 ../
drwxrwxr-x 2 kube root 4096 Oct 25 16:18 addons/
-rw------- 1 kube root 5659 Oct 25 16:17 admin.conf
-rw------- 1 kube root 5681 Oct 25 16:17 controller-manager.conf
-rw-r--r-- 1 kube root 925 Oct 25 16:18 coredns-svc.yaml
-rw-r--r-- 1 kube root 2670 Oct 25 16:17 kubeadm-config.yaml
-rw------- 1 kube root 1979 Oct 25 16:18 kubelet.conf
drwxr-xr-x 2 kube root 4096 Oct 25 16:17 manifests/
-rw-r--r-- 1 kube root 230001 Oct 25 16:18 network-plugin.yaml
-rw-r--r-- 1 kube root 1040 Oct 25 16:18 nodelocaldnsConfigmap.yaml
-rw-r--r-- 1 kube root 2775 Oct 25 16:18 nodelocaldns.yaml
drwxr-xr-x 2 kube root 4096 Oct 25 16:17 pki/
-rw------- 1 kube root 5633 Oct 25 16:17 scheduler.conf

2.生成新证书

yang@master:~$ sudo  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'
W1027 09:29:53.913902 49108 utils.go:69] The recommended value for "clusterDNS" in "KubeletConfiguration" is: [10.233.0.10]; the provided value is: [169.254.25.10] certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed
certificate for serving the Kubernetes API 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 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.

三、查看证书有效期

yang@master:~$ sudo 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'
W1027 09:31:31.191076 51350 utils.go:69] The recommended value for "clusterDNS" in "KubeletConfiguration" is: [10.233.0.10]; the provided value is: [169.254.25.10] CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Oct 27, 2023 01:29 UTC 364d ca no
apiserver Oct 27, 2023 01:29 UTC 364d ca no
apiserver-kubelet-client Oct 27, 2023 01:29 UTC 364d ca no
controller-manager.conf Oct 27, 2023 01:29 UTC 364d ca no
front-proxy-client Oct 27, 2023 01:29 UTC 364d front-proxy-ca no
scheduler.conf Oct 27, 2023 01:29 UTC 364d ca no CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Oct 22, 2032 08:17 UTC 9y no
front-proxy-ca Oct 22, 2032 08:17 UTC 9y no

四、新证书替换老的证书凭证

yang@master:~$ sudo cp -a ~/.kube/config /home/config-back/
yang@master:~$ sudo cp /etc/kubernetes/admin.conf ~/.kube/config

五、查看集群状态 

yang@master:~$ kubectl  get nodes
NAME STATUS ROLES AGE VERSION
master Ready control-plane,master,worker 41h v1.22.10
node Ready worker 39h v1.22.10

kubeSphere+kubernetes 集群更新证书的更多相关文章

  1. Centos7部署kubernetes集群CA证书创建和分发(二)

    1.解压软件包 [root@linux-node1 ~]# cd /usr/local/src/ [root@linux-node1 src]# ls k8s-v1.10.1-manual.zip [ ...

  2. 监控Kubernetes集群证书过期时间的三种方案

    前言 Kubernetes 中大量用到了证书, 比如 ca证书.以及 kubelet.apiserver.proxy.etcd等组件,还有 kubeconfig 文件. 如果证书过期,轻则无法登录 K ...

  3. 使用Kubeadm搭建高可用Kubernetes集群

    1.概述 Kubenetes集群的控制平面节点(即Master节点)由数据库服务(Etcd)+其他组件服务(Apiserver.Controller-manager.Scheduler...)组成. ...

  4. 基于TLS证书手动部署kubernetes集群(下)

    一.master节点组件部署 承接上篇文章--基于TLS证书手动部署kubernetes集群(上),我们已经部署好了etcd集群.flannel网络以及每个节点的docker,接下来部署master节 ...

  5. Kubernetes集群中Service的滚动更新

    Kubernetes集群中Service的滚动更新 二月 9, 2017 0 条评论 在移动互联网时代,消费者的消费行为已经“全天候化”,为此,商家的业务系统也要保持7×24小时不间断地提供服务以满足 ...

  6. Kubernetes 集群部署(1) -- 自签 TLS 证书

    集群功能各模块功能描述: Master节点:主要由四个模块组成,APIServer,schedule, controller-manager, etcd APIServer: APIServer负责对 ...

  7. 在 Kubernetes 集群快速部署 KubeSphere 容器平台

    KubeSphere 不仅支持部署在 Linux 之上,还支持在已有 Kubernetes 集群之上部署 KubeSphere,自动纳管 Kubernetes 集群的已有资源与容器. 前提条件 Kub ...

  8. 在 Linux 部署多节点 Kubernetes 集群与 KubeSphere 容器平台

    KubeSphere 是在 Kubernetes 之上构建的以应用为中心的企业级容器平台,所有供为用户提供简单易用的操作界面以及向导式操作方式.同时,KubeSphere Installer 提供了 ...

  9. (转)基于TLS证书手动部署kubernetes集群(下)

    转:https://www.cnblogs.com/wdliu/p/9152347.html 一.master节点组件部署 承接上篇文章--基于TLS证书手动部署kubernetes集群(上),我们已 ...

  10. Kubernetes集群搭建 ver1.20.5

    目录 部署方式 1. 基础环境准备 1.1 基础初始化 1.2 安装docker 2. 部署harbor及haproxy高可用反向代理 2.1 镜像加速配置 2.2 高可用master可配置 3. 初 ...

随机推荐

  1. js节流防抖 减少服务器请求

  2. JSP第十一次作业

    1.第十二周上机作业(邮件功能)的控制层代码改用为servlet实现.2.学习通发布了考试,截止到本周六.  com.gd.dao  BaseDao 1 package com.gd.dao; 2 3 ...

  3. ARM启动顺序

    iROM(也叫BL0)的作用:   初始化系统时钟,设置看门狗,初始化栈和堆   加载BL1 BL1的作用:   初始化RAM , 关闭Cache , 设置栈   加载BL2 BL2的作用:   初始 ...

  4. (一) MdbCluster分布式内存数据库——基础架构介绍

    (一) MdbCluster分布式内存数据库--基础架构介绍   这个项目是怎么开始的我已经有些记不清楚了,大概是原来的内存数据库很不好用,一次次地让我们踩坑,我又自以为是地觉得可以做一个更好的出来. ...

  5. Android IO 框架 Okio 的实现原理,如何检测超时?

    本文已收录到  AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 提问. 前言 大家好,我是小彭. 在上一篇文章里,我们聊到了 Square 开源的 I/O 框架 Okio 的三个 ...

  6. zookeeper03-集群搭建

    1.前言 在前面的文章中讲了单机版zookeeper的搭建,现在在单机版的基础上搭建集群.默认单机版的搭建好了.我这里只有一台服务器,所以在单机上搭建的为集群 2.将单机安装好的zookeeper复制 ...

  7. mysql19-锁

    1.什么是锁 锁是计算机协调多个进程或线程并发访问某一资源的机制.在数据库中,除传统的计算资源(如CPU.RAM.I/O等)的争用以外,数据也是一种供许多用户共享的资源.如何保证数据并发访问的一致性. ...

  8. .net core 阿里云接口之将指定的OSS文件下载到流

    紧接上文,.net core 阿里云接口之获取临时访问凭证_SunshineGGB的博客-CSDN博客 本文继续阿里云接口调用,将指定的OSS文件下载到流. 直接上代码: /// <summar ...

  9. 三:Mybatis

    三.MyBatis 主流的ORM 支持java .NET Ruby三种语言,MyBatis是对JDBC的封装 ORM框架Hibernate 区别: 1)sql 优化方面 Hibernate 使用 HQ ...

  10. 微信小程序wx.navigateTo跳转参数大小超出限制问题

    微信小程序的跳转方式 wx.navigateTo(Object):保留当前页面,跳转到应用内的某个页面,使用 wx.navigateBack 可以返回到原页(新页面入栈) wx.redirectTo( ...