# Rancher 更新指南 当前版本 2.13.0 最新版本2.13.1 ## 1. 备份当前 Rancher ```bash # 备份 Rancher Deployment 配置 kubectl get deployment rancher -n cattle-system -o yaml > rancher-backup.yaml # 备份重要数据 (如果是 PVC 存储) kubectl get pvc -n cattle-system ``` ## 2. 添加/更新 Rancher Helm 仓库 ```bash # 添加 Rancher Helm 仓库 helm repo add rancher-latest https://releases.rancher.com/server-charts/latest # 更新 Helm 仓库 helm repo update # 查看可用的 Rancher 版本 helm search repo rancher-latest/rancher -l | head -20 ``` ## 3. 执行更新 ```bash # 执行更新 (将 v2.x.x 替换为目标版本) helm upgrade rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname=rancher.xiongxiao.me \ --set replicas=3 \ --set bootstrapPassword="your-secure-password" # 如果有自定义 values.yaml 文件 # helm upgrade rancher rancher-latest/rancher -f values.yaml --namespace cattle-system ``` ## 4. 验证更新状态 ```bash # 监控 Pod 状态 kubectl get pods -n cattle-system -w # 检查 Deployment 滚动更新状态 kubectl rollout status deployment/rancher -n cattle-system # 查看日志确认正常启动 kubectl logs -f deploy/rancher -n cattle-system ``` ## 5. 验证 Rancher 功能 - 访问 https://rancher.xiongxiao.me - 检查集群状态 - 检查用户、角色、设置是否正常 ## 注意事项 - **版本兼容性**: 确保新版本与 Kubernetes 集群版本兼容 - **升级路径**: Rancher 升级需要按版本逐步升级 (如 2.6 → 2.7 → 2.8) - **备份**: 升级前务必备份 Rancher 数据 - **自定义配置**: 使用自定义 values.yaml 时确保包含所有必要配置 - **回滚**: 如遇到问题,可使用 `helm rollback rancher --namespace cattle-system`