k3s 报错 the server has asked for the client to provide credentials 解决
2025/9/10小于 1 分钟
k3s 报错 the server has asked for the client to provide credentials
解决
在 k3s 服务运行一年以上, 在使用 kubectl 管理服务时会报这个错误
Unhandled Error" err="couldn't get current server API group list: the server has asked for the client to provide credentials
原因
原因是 Kubectl 连接 k3s 的证书到期了,导致无法连接,解决方案是重新生成证书并复制到本地 kubectl 的配置文件中
解决方法
- 执行重新生成证书命令
sudo k3s certificate rotate
- 更新本地证书
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
- 重启 k3s
sudo systemctl start k3s