背景:
Unable to connect to the server: x509: certificate is valid for 10.96.0.1, 10.0.1.76, not 119.28.78.191
报错原因:
Connection error: Get https://119.28.78.191:6443/api/v1/namespaces/default/pods?limit=500: x509: certificate is valid for 10.96.0.1, 10.0.1.76, not 119.28.78.191
由于我使用的是云主机,k8s证书签名的时候签的是内网ip,并不是eip,外网ip ,所以证书认证失败,跳过证书认证即可
解决办法:
kubectl get po --insecure-skip-tls-verify
% kubectl get po --insecure-skip-tls-verify
NAME READY STATUS RESTARTS AGE
busybox-cd8b7db95-rvn9p 1/1 Running 1 4d4h
demotest-helmtest-5dc8649987-jzgfb 1/1 Running 0 23h
demotest2-helmtest-55585789d5-6cpz6 1/1 Running 0 23h
helmtest-1-7f86dd445b-2htjn 1/1 Running 0 3d17h
helmtest-bcb4854b6-phtbg 1/1 Running 0 3d17h
Kubernetes证书错误与解决:外网IP访问证书不匹配

在尝试连接到Kubernetes集群的API服务器时遇到证书错误,错误显示证书仅适用于内网IP,不适用于外网IP。由于使用的是云主机,证书在签发时未包含外网IP,导致外网访问失败。为解决此问题,可以使用`kubectl get po --insecure-skip-tls-verify`命令临时跳过TLS验证,但这并不安全,长期解决方案应更新或配置证书以包含所有预期IP。
最低0.47元/天 解锁文章
4102

被折叠的 条评论
为什么被折叠?



