高可用Rancher升级

一、官方文档

高可用升级指南(Helm 3)
https://docs.rancher.cn/docs/rancher2/installation_new/install-rancher-on-k8s/upgrades/ha/_index/

二、注意事项

请根据官文档进行升级,升级过程中注意事项:
1、在安装有helm主机执行,只需执行一次不需要每台都执行。
2、

三、操作记录

1、备份集群

K3S可以采用外置数据库,所以,先备份数据库。
RKE部署的环境,先以rancher用户登录有安装rke的服务器,再进行etcd备份
修改rancher-cluster.yml

2、更新helm chart仓库

helm repo update

3、获取用于安装 Rancher 的仓库名称

helm repo list
NAME              URL                                              
rancher-stable    https://releases.rancher.com/server-charts/stable

4、从 Helm chart 仓库中获取最新的 chart ,安装 Rancher。

helm fetch rancher-stable/rancher

5、从已安装的当前 Rancher Helm chart 中获取通过 —set 传递的值。

helm get values rancher -n cattle-system
USER-SUPPLIED VALUES:
hostname: rancher.zyrox.com
ingress:
  tls:
    source: secret
privateCA: true

执行上述命令报错:

helm get values rancher -n cattle-system
Error: Kubernetes cluster unreachable: Get "https://rancher.zyrox:6443/version?timeout=32s": dial tcp: lookup rancher.zyrox on 202.101.172.35:53: no such host

报错原因: helm v3版本不再需要Tiller,而是直接访问ApiServer来与k8s交互,通过环境变量KUBECONFIG来读取存有ApiServre的地址与token的配置文件地址,默认地址为~/.kube/config
解决方法:
手动配置 KUBECONFIG环境变量
临时解决: export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
永久解决:
执行: vi /etc/profile
写入内容: export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
执行: source /etc/profile
来源:https://www.cnblogs.com/varyuan/p/14223553.html

5、高可用Rancher升级

helm upgrade rancher rancher-stable/rancher \
--namespace cattle-system \
--set hostname=rancher.zyrox.com \
--reuse-values \
--version=2.5.5
Release "rancher" has been upgraded. Happy Helming!
NAME: rancher
LAST DEPLOYED: Wed Feb 24 09:37:55 2021
NAMESPACE: cattle-system
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
Rancher Server has been installed.

NOTE: Rancher may take several minutes to fully initialize. Please standby while Certificates are being issued and Ingress comes up.

Check out our docs at https://rancher.com/docs/rancher/v2.x/en/

Browse to https://rancher.zyrox.com

Happy Containering!

注意:需要等待约5分钟左右可以登录racncher,其它包括用户集群等需要更久时间,请耐心等待。