k8s证书到期处理

#1、查看证书到期时间:

kubeadm certs check-expiration

root@k8s-master $ 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'

CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED

admin.conf Apr 28, 2027 08:00 UTC 364d ca no

apiserver Apr 28, 2027 08:00 UTC 364d ca no

apiserver-etcd-client Apr 28, 2027 08:00 UTC 364d etcd-ca no

apiserver-kubelet-client Apr 28, 2027 08:00 UTC 364d ca no

controller-manager.conf Apr 28, 2027 08:00 UTC 364d ca no

etcd-healthcheck-client Apr 28, 2027 08:00 UTC 364d etcd-ca no

etcd-peer Apr 28, 2027 08:00 UTC 364d etcd-ca no

etcd-server Apr 28, 2027 08:00 UTC 364d etcd-ca no

front-proxy-client Apr 28, 2027 08:00 UTC 364d front-proxy-ca no

scheduler.conf Apr 28, 2027 08:00 UTC 364d ca no

CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED

ca Apr 22, 2034 07:26 UTC 7y no

etcd-ca Apr 22, 2034 07:26 UTC 7y no

front-proxy-ca Apr 22, 2034 07:26 UTC 7y no

#2、更新所有证书有效期

kubeadm certs renew all

#3、重启控制平面组件

方法一:临时移动静态Pod的清单文件(适用于所有环境)

将这些Pod的YAML文件(通常位于 /etc/kubernetes/manifests/)移出该目录,稍后移回即可触发重启。

例如,重启 kube-apiserver:

sudo mv /etc/kubernetes/manifests/kube-apiserver.yaml /tmp/

sleep 30

sudo mv /tmp/kube-apiserver.yaml /etc/kubernetes/manifests/

方法二:直接删除Pod(前提是Pod由kubelet管理,kubelet会自动重建)

执行以下命令,删除后,kubelet会自动重启它们:

sudo kubectl delete pod -n kube-system -l 'component in (kube-apiserver, etcd, kube-scheduler, kube-controller-manager)'

#4、更新本地kubeconfig

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

确保当前用户对该文件有读取权限

sudo chown (id -u):(id -g) $HOME/.kube/config

相关推荐
菜地里的小菜鸟1 天前
kubectl debug
k8s·kubectldebug
腾飞开源3 天前
01_K8s干货笔记之认识K8s
运维·笔记·云原生·容器·kubernetes·k8s·容器化部署
小匠石钧知6 天前
02_在多个RockyLinux10虚拟机上安装k8s集群
云原生·容器·kubernetes·k8s
ShirleyWang01212 天前
让headlamp控制台能访问
linux·服务器·python·k8s·k3s
spider_xcxc12 天前
K8s 部署学习笔记
docker·容器·kubernetes·云计算·k8s
ShirleyWang01212 天前
Day02 K3s NGF(Nginx Gateway Fabric)单 Worker 环境网关更新与故障处置 SOP
linux·服务器·python·k8s·k3s
ShirleyWang01212 天前
DAY01 K3s 私有化部署排障复盘与 SOP
linux·服务器·k8s·k3s·企业部署
XUHUOJUN16 天前
AKS 不是安装在 Windows Server 上,而是运行在 Windows Server 之上的 Azure 平台能力
windows·架构·k8s·azure local·azure stack
Geek-Chow16 天前
Connecting kubectl to a Private EKS Cluster Over an Internal Domain
kubernetes·k8s·aws
spider_xcxc18 天前
Docker Compose 容器通信详解:同一个 Compose 文件才能互通吗?
docker·容器·k8s·容器化·容器网络