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

相关推荐
mengge.cloud4 天前
1022小白入门教程(番外筑基)— nerdctl 容器基本功 + K8s 资源编写
linux·网络·云原生·容器·kubernetes·云计算·k8s
上火的金鱼妹5 天前
节点调度优化 + redis 现有问题优化
k8s
fengkai45455 天前
3、Kubernetes的Namespace&Contexts&Pod&YAML格式
运维·容器·kubernetes·k8s·namespace·yaml·pod
meijinmeng6 天前
Karpenter + Keda 让Kuberntes实现动态扩缩容机制方案指南
k8s
.冰块.7 天前
VMware+Ubuntu24.04 kubeadm 部署 K8s 1.30.2 三节点集群
运维·云原生·容器·kubernetes·k8s·容器编排
我不会起名字3228 天前
K8s Ingress 返回 502 但后端日志正常:4 类上游断连与排查链
kubernetes·k8s·ingress·502·keepalive
Eminem899 天前
18、k8s配置管理中心Secret
k8s
我不会起名字3229 天前
K8s 服务 DNS 解析偶发 5 秒超时:conntrack 与 ndots 的 3 个坑
kubernetes·k8s·dns·conntrack·coredns
KIDULT°10 天前
Kubeadm 部署 Kubernetes v1.30.2 实战:Ubuntu24.04 三节点集群 + 排坑记录
ubuntu·云原生·容器·kubernetes·k8s
Eminem8910 天前
15、k8s控制器Statefulset
k8s