Rancher/rke2 kubeconfig 错误 x509: certificate signed by unknown authority 解决办法

Rancher/rke2 kubeconfig 错误 x509: certificate signed by unknown authority 解决办法


当部署 Rancher 后直接复制 KubeConfig 文件到本地使用,会出现以下错误:

FATA[01:55:58] Error connecting to k8s cluster: Get "https://rancher.rakour.com:30112/k8s/clusters/local/version": x509: certificate signed by unknown authority (possibly because of "x509: ECDSA verification failure" while trying to verify candidate authority certificate "dynamiclistener-ca@1691948346")

这是因为 KubeConfig 默认使用的是全局的 CA 证书签署的 KubeConfig
只需要替换为 tls-rancher-internal-ca 证书即可。

直接复制然后 Base64 编码后替换即可。