模拟问题点

使用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. BFC是什么?有什么作用

    Block formatting context:块级格式化上下文1.前言官方文档解释为:一个BFC区域包含创建该上下文元素的所有子元素,但是不包括创建了新的BFC的子元素的内部元素,BFC是一块块独 ...

  2. IOS(XCode)嵌入Unity模块

    今天下午明明要弄明白Android Studio出AAR给Unity用的,结果发现好多问题,小黑心里苦啊,整不明白了呀,让我做Unity吧... 好了,废话不给大家多说了,今天小黑给大家带来,如何在I ...

  3. Unity_UIWidgets - 组件Drawer

    Unity_UIWidgets - 组件Drawer 组件Drawer Drawer 构造 代码 效果 Drawer使用完毕 结语 图标Icon QQ 今日无推荐 组件Drawer 各位伙伴,周日愉快 ...

  4. Jvm--MinorGC过程

    第一次GC: 在不断创建对象的过程中,当Eden区域被占满,此时会开始做Young GC也叫Minor GC 1)第一次GC时Survivous中S0区和S1区都为空,将其中一个作为To Surviv ...

  5. Vue+Element-Ui设置收货地址,省市区三级联动,详细地址信息调用腾讯地图关键词输入提示api

    省市区三级联动的数据 我这里找了一个json格式的数据,直接放在前端项目的文件夹下,这里粘贴出来 pca.json文件内容 { "北京市": { "市辖区": ...

  6. 顺手写的redis分布式锁

    /** * 锁定一个key,***一定要手工释放锁 * * @param key * @return */ public boolean lockKey(String key) { return re ...

  7. dotnet 8 preview 1 即将发布

    .Net 8 preview 1 即将到来,让我们来提前看看都要发布什么吧. .Net 8 preview 1 即将到来 .NET 8 的第一个预览版将在几周内发布,微软的 David Ortinau ...

  8. Html音频播放代码

    页面代码: <html> <head> <script src="https://code.jquery.com/jquery-3.1.1.min.js&quo ...

  9. Nacos入门

    1.介绍 ①概要 官网:home (nacos.io) Nacos:Dynamic Naming and Configuration Service(动态命名和配置服务) 你可以看为:Eureka(注 ...

  10. Educational Codeforces Round 143 (Rated for Div. 2) A-E

    比赛链接 A 题意 有两座塔由红蓝方块组成,分别有 \(n,m\) 个方块,一次操作可以把一座塔塔顶的方块移动到另一座塔的塔顶,问通过操作是否能使每座塔中没有颜色相同的相邻方块. 题解 知识点:贪心. ...