4

rancher~升级v2.6.3之后业务集群无法连rancher的解决方法

 2 years ago
source link: https://www.cnblogs.com/lori/p/15923363.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

rancher~升级v2.6.3之后业务集群无法连rancher的解决方法

参考:https://docs.rancher.cn/docs/rancher2.5/faq/upgrade/_index/

当我们升级自签名证书安装的 Rancher Server 到 2.5.10 以上,或 2.6.x 后,cluster-agent/node-agent 有可能会报下面的错,导致 cluster-agent/node-agent 无法启动:
x509: certificate relies on legacy Common Name field, use SANs or temporarily enable Common Name matching with GODEBUG=x509ignoreCN=0"
这是因为 Rancher 把 v2.5.10 以上,或 2.6.x 之后将 go 版本从 1.14 提升到了 1.16。而且,go 1.15 版本开始废弃 CommonName,推荐使用 SAN 证书,参考:https://golang.org/doc/go1.15#commonname 。 如果你的自签名证书中不包含 SANs,就会出现下面的报错。

x509: certificate relies on legacy Common Name field, use SANs or temporarily enable Common Name matching with GODEBUG=x509ignoreCN=0"#
  • 替换 Rancher HA 证书#
  • 使用一键生成 ssl 自签名证书脚本 重新生成证书,然后参考无需重新搭建集群,轻松替换证书替换 Rancher HA 的证书。

添加环境变量 GODEBUG=x509ignoreCN=0#
更新 Rancher Server ,添加环境变量GODEBUG=x509ignoreCN=0
升级 Rancher 通过extraEnv设置环境变量GODEBUG=x509ignoreCN=0,例如:

helm upgrade rancher rancher-latest/rancher \
  --namespace cattle-system \
  ...
  --set 'extraEnv[0].name=GODEBUG'\
  --set 'extraEnv[0].value=x509ignoreCN=0' \
  ...

或者,来添加环境变量

kubectl edit deployment rancher --namespace cattle-system 

更新业务集群的 Rancher Agent,添加环境变量GODEBUG=x509ignoreCN=0
编辑下游集群,点击 Add Environmenet Variable,设置环境变量,如下:

 kubectl edit deployment cattle-cluster-agent -n cattle-system
 kubectl edit deployment cattle-node-agent -n cattle-system

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK