高可用Rancher升级
<h1>一、官方文档</h1>
<p>高可用升级指南(Helm 3)
<a href="https://docs.rancher.cn/docs/rancher2/installation_new/install-rancher-on-k8s/upgrades/ha/_index/">https://docs.rancher.cn/docs/rancher2/installation_new/install-rancher-on-k8s/upgrades/ha/_index/</a></p>
<h1>二、注意事项</h1>
<p>请根据官文档进行升级,升级过程中注意事项:
1、在安装有helm主机执行,只需执行一次不需要每台都执行。
2、</p>
<h1>三、操作记录</h1>
<h2>1、备份集群</h2>
<p>K3S可以采用外置数据库,所以,先备份数据库。
RKE部署的环境,先以rancher用户登录有安装rke的服务器,再进行etcd备份
修改rancher-cluster.yml</p>
<h2>2、更新helm chart仓库</h2>
<pre><code class="language-bash">helm repo update</code></pre>
<h2>3、获取用于安装 Rancher 的仓库名称</h2>
<pre><code class="language-bash">helm repo list
NAME URL
rancher-stable https://releases.rancher.com/server-charts/stable</code></pre>
<h2>4、从 Helm chart 仓库中获取最新的 chart ,安装 Rancher。</h2>
<pre><code class="language-bash">helm fetch rancher-stable/rancher</code></pre>
<h2>5、从已安装的当前 Rancher Helm chart 中获取通过 --set 传递的值。</h2>
<pre><code class="language-bash">helm get values rancher -n cattle-system
USER-SUPPLIED VALUES:
hostname: rancher.zyrox.com
ingress:
tls:
source: secret
privateCA: true</code></pre>
<p>执行上述命令报错:</p>
<pre><code class="language-bash">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</code></pre>
<p>报错原因: 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
来源:<a href="https://www.cnblogs.com/varyuan/p/14223553.html">https://www.cnblogs.com/varyuan/p/14223553.html</a></p>
<h2>5、高可用Rancher升级</h2>
<pre><code class="language-bash">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!</code></pre>
<p><code>注意:需要等待约5分钟左右可以登录racncher,其它包括用户集群等需要更久时间,请耐心等待。</code></p>