Kind部署的K8s证书过期后的解决方案

dragon72463399

drake

Posted on September 13, 2024

Kind部署的K8s证书过期后的解决方案
  • 证书通常有效期为1年,一年后服务将不可用
  • 解决方案就是更新证书

  • 1. 找到 Kind 集群的控制平面容器名称:
docker ps --filter "name=kind-control-plane"
Enter fullscreen mode Exit fullscreen mode
  • 2. 进入 Kind 控制平面的容器:
docker exec -it kind-control-plane bash

Enter fullscreen mode Exit fullscreen mode
  • 3. 在容器内使用以下命令来更新证书:
kubeadm certs renew all

Enter fullscreen mode Exit fullscreen mode
  • 4. 在控制平面容器内,重启 Kubernetes 控制平面组件,使更新后的证书生效:
pkill kube-apiserver
pkill kube-controller-manager
pkill kube-scheduler

Enter fullscreen mode Exit fullscreen mode
  • 5. 在控制平面容器内,使用以下命令手动生成 admin.conf:
kubeadm init phase kubeconfig admin --kubeconfig-dir=/etc/kubernetes

Enter fullscreen mode Exit fullscreen mode
  • 6. 复制更新后的 admin.conf 到主机(宿主机执行):
docker cp kind-control-plane:/etc/kubernetes/admin.conf ~/.kube/config

Enter fullscreen mode Exit fullscreen mode
  • 7. 重启控制平面容器:‘

重启可能会失败,多试几次就好了

docker restart kind-control-plane
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
dragon72463399
drake

Posted on September 13, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related