模拟问题点

使用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. Axure 环境进度条

    步骤一:拖拉摆放好相关控件 1.4个半圆环,一个白色上半圆环 (上白),一个白色下半圆环 (下白),一个灰色上半圆环 (上灰),一个灰色下半圆环 (下灰),排放层次为: 下灰<下白<上灰& ...

  2. linux环境编程(2): 使用pipe完成进程间通信

    1. 写在前面 linux系统内核为上层应用程序提供了多种进程间通信(IPC)的手段,适用于不同的场景,有些解决进程间数据传递的问题,另一些则解决进程间的同步问题.对于同样一种IPC机制,又有不同的A ...

  3. @EnableDiscoveryClient和@EnableEurekaClient springboot3.x

    @EnableDiscoveryClient和@EnableEurekaClient 将一个微服务注册到Eureka Server(或其他服务发现组件,例如Zookeeper.Consul等)的步骤 ...

  4. 接口介绍以及postman的基本使用

    集成测试--测试接口 接口测试也是在测试执行阶段做 一.什么是接口 软件的不同模块之间互相发送数据的一个通道 二.接口的组成 1.请求URL--接口地址2.请求类型 get get请求的参数是暴露在U ...

  5. Python+chatGPT编程5分钟快速上手,强烈推荐!!!

    最近一段时间chatGPT火爆出圈!无论是在互联网行业,还是其他各行业都赚足了话题. 俗话说:"外行看笑话,内行看门道",今天从chatGPT个人体验感受以及如何用的角度来分享一下 ...

  6. 使用 DirectSound 播放 WAV 文件

    使用 DirectSound 播放 WAV 文件 本文需要的前置知识可以在之前的这两篇文章找到. WAVE音频文件格式及其64位扩展格式的简要介绍 读写wav格式文件 基于本文介绍的方法,我们也可以用 ...

  7. 学习Java Day22

    今天学习了如何在包中增加类,想要将包放入类中,就必须将包的名字放在源文件的开头,即放在定义这个包中各个类的代码之前

  8. 安卓逆向 HOOK 第一课 XP的安装以及编写

    <meta-data android:name="xposedmodule" android:value="true" /> <meta-da ...

  9. Cesium源码之Label(二)

    我们查看Cesium源码时,有时会发现源码中有大量的includeStart开头的注释,如下图所示. 这里面大多是调试信息,当使用gulp打包时,removePragmas参数设置为true,则会删除 ...

  10. 【Gerald and Giant Chess】

    一道计数类DP例题~~~ ps:P党似乎不多了-- 我这只蒟蒻第一次写题解,而且计数类DP还是早上刚学的,现学现用,或者说是所谓的"浅谈"一番吧!况且这题写题解的人似乎并不多(大佬 ...