升级最新版Rancher|升级最新版Rancher 2.2.6
前言:之前采用离线方式部署好了 Rancher 2.2.4(https://www.cnblogs.com/weavepub/p/11053099.html),这次升级到最新版本 Rancher 2.2.6。
一、同步镜像
1.1 安装docker
新启动一台虚拟主机,安装docker(不要用生产环境,免得主机上的镜像太多)
yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install docker-ce -y systemctl restart docker systemctl enable docker systemctl status docker
1.2 下载镜像列表文件
mkdir -p /opt/rancher/upgrade2.2.6 && cd /opt/rancher/upgrade2.2.6 https://github.com/rancher/rancher/releases/tag/v2.2.6/rancher-images.txt
1.3准备镜像脚本
1)镜像下载脚本
vim rancher-save-images.sh
#内容如下:
文章图片
文章图片
#!/bin/bash # 定义日志 workdir=`pwd` log_file=${workdir}/sync_images_$(date +"%Y-%m-%d").loglogger() { log=$1 cur_time='['$(date +"%Y-%m-%d %H:%M:%S")']' echo ${cur_time} ${log} | tee -a ${log_file} }list="rancher-images.txt" #images="rancher-images.tar.gz"POSITIONAL=() while [[ $# -gt 0 ]]; do key="$1" case $key in -i|--images) images="$2" shift # past argument shift # past value ; ; -l|--image-list) list="$2" shift # past argument shift # past value ; ; -h|--help) help="true" shift ; ; esac doneusage () { echo "USAGE: $0 [--image-list rancher-images.txt] [--images rancher-images.tar.gz]" echo "[-l|--images-list path] text file with list of images. 1 per line." echo "[-l|--images path] tar.gz generated by docker save." echo "[-h|--help] Usage message" }if [[ $help ]]; then usage exit 0 fiset -e -xmkdir -p rancher-images-$(date +"%Y-%m-%d") cd rancher-images-$(date +"%Y-%m-%d")for i in $(cat ${list}); do docker pull ${i}if [ $? -ne 0 ]; then logger "${i} pull failed." else logger "${i} pull successfully." fidocker save ${i} | gzip > $(echo $i | sed "s#/#-#g; s#:#-#g").tgzif [ $? -ne 0 ]; then logger "${i} save failed." else logger "${i} save successfully." fi done
View Code 2)镜像上传到私有仓库脚本
vim rancher-push-images.sh #内容如下:
文章图片
文章图片
#!/bin/bash## 镜像上传说明 # 需要先在镜像仓库中创建 rancher 项目 # 根据实际情况更改以下私有仓库地址# 定义日志 workdir=`pwd` log_file=${workdir}/sync_images_$(date +"%Y-%m-%d").loglogger() { log=$1 cur_time='['$(date +"%Y-%m-%d %H:%M:%S")']' echo ${cur_time} ${log} | tee -a ${log_file} }images_hub() {while true; do read -p "输入镜像仓库地址(不加http/https): " registry read -p "输入镜像仓库用户名: " registry_user read -p "输入镜像仓库用户密码: " registry_password echo "您设置的仓库地址为: ${registry},用户名: ${registry_user},密码: xxx" read -p "是否确认(Y/N): " confirmif [ $confirm != Y ] && [ $confirm != y ] && [ $confirm == '' ]; then echo "输入不能为空,重新输入" else break fi done }images_hubecho "镜像仓库 $(docker login -u ${registry_user} -p ${registry_password} ${registry})"images=$(docker images -a | grep -v TAG | awk '{print $1 ":" $2}') namespace=rancherdocker_push() { for imgs in $(echo ${images}); do n=$(echo ${imgs} | awk -F"/" '{print NF-1}') #如果镜像名中没有/,那么此镜像一定是library仓库的镜像; if [ ${n} -eq 0 ]; then img_tag=${imgs} #namespace=rancher #重命名镜像 docker tag ${imgs} ${registry}/${namespace}/${img_tag} #删除原始镜像 #docker rmi ${imgs} #上传镜像 docker push ${registry}/${namespace}/${img_tag} #如果镜像名中有一个/,那么/左侧为项目名,右侧为镜像名和tag elif [ ${n} -eq 1 ]; then img_tag=$(echo ${imgs} | awk -F"/" '{print $2}') #namespace=$(echo ${imgs} | awk -F"/" '{print $1}') #重命名镜像 docker tag ${imgs} ${registry}/${namespace}/${img_tag} #删除旧镜像 #docker rmi ${imgs} #上传镜像 docker push ${registry}/${namespace}/${img_tag} #如果镜像名中有两个/, elif [ ${n} -eq 2 ]; then img_tag=$(echo ${imgs} | awk -F"/" '{print $3}') #namespace=$(echo ${imgs} | awk -F"/" '{print $2}') #重命名镜像 docker tag ${imgs} ${registry}/${namespace}/${img_tag} #删除旧镜像 #docker rmi ${imgs} #上传镜像 docker push ${registry}/${namespace}/${img_tag} else #标准镜像为四层结构,即:仓库地址/项目名/镜像名:tag,如不符合此标准,即为非有效镜像。 echo "No available images" fi done }docker_push
View Code 1.4 同步镜像
1)下载镜像
chmod +x rancher-save-images.sh ./rancher-save-images.sh --image-list /opt/rancher/upgrade2.2.6/rancher-images.txt
【升级最新版Rancher|升级最新版Rancher 2.2.6】2)上传镜像
chmod +x rancher-push-images.sh ./rancher-push-images.sh reg.nexus.wmqe.com admin *******
二、升级Rancher 2.1 下载 Rancher 2.2.6 离线包
登入到当初部署 Rancher 时的 prod-rancher-server-01 主机
1)更新本地helm repo缓存
helm repo update
2)查看Rancher 最新版本
helm search rancher NAMECHART VERSIONAPP VERSIONDESCRIPTION rancher-stable/rancher2.2.6v2.2.6Install Rancher Server to manage Kubernetes clusters acro...
3)获取Rancher Charts离线包
mkdir -p /opt/rancher/upgrade2.2.6 && cd /opt/rancher/upgrade2.2.6 helm fetch rancher-stable/rancher --version v2.2.6
2.2 升级 Rancher
1)升级Rancher
升级参数应该以安装时设置的参数为准。
tar zxvf rancher-2.2.6.tgz kubeconfig=/root/.kube/confighelm --kubeconfig=$kubeconfig upgrade rancher ./rancher \ --set hostname=rancher.wmqe.com \ --set ingress.tls.source=secret \ --set auditLog.level=3 \ --set auditLog.destination=hostPath \ --set auditLog.hostPath=/opt/rancher/auditlogs/ \ --set auditLog.maxAge=20 \ --set auditLog.maxBackups=20 \ --set auditLog.maxSize=100 \ --set rancherImage=reg.nexus.wmqe.com/rancher/rancher
2)查看pod状态
kubectl get pod -A
NAMESPACENAMEREADYSTATUSRESTARTSAGE cattle-systemcattle-cluster-agent-c87688dc5-xzlqg1/1Running027m cattle-systemcattle-node-agent-9tl5c1/1Running026m cattle-systemcattle-node-agent-vrrmr1/1Running027m cattle-systemcattle-node-agent-xrdkq1/1Running026m cattle-systemrancher-5ddf8d4897-lmw5v2/2Running028m cattle-systemrancher-5ddf8d4897-wnfqn2/2Running029m cattle-systemrancher-5ddf8d4897-xcx5s2/2Running028m ingress-nginxdefault-http-backend-6d4b9c4cc7-5qh4c1/1Running041d ingress-nginxnginx-ingress-controller-dll871/1Running041d ingress-nginxnginx-ingress-controller-fnwvb1/1Running041d ingress-nginxnginx-ingress-controller-pzcxb1/1Running041d kube-systemcanal-4qnsr2/2Running041d kube-systemcanal-b7p6v2/2Running041d kube-systemcanal-wv8p52/2Running041d kube-systemkube-dns-7fbcd74695-j7fx73/3Running041d kube-systemkube-dns-autoscaler-6b777db656-58xxz1/1Running041d kube-systemmetrics-server-7c57d997f9-j7lt41/1Running041d kube-systemrke-ingress-controller-deploy-job-nq7sq0/1Completed041d kube-systemrke-kube-dns-addon-deploy-job-5flrd0/1Completed041d kube-systemrke-metrics-addon-deploy-job-8tzcr0/1Completed041d kube-systemrke-network-plugin-deploy-job-vq4gh0/1Completed041d kube-systemtiller-deploy-768c796496-c4cd21/1Running041d
标红的都重新创建后,就可以成功访问Rancher主界面了。
转载于:https://www.cnblogs.com/weavepub/p/11248875.html
推荐阅读
- jhipster|jhipster 升级无效问题
- gitlab|Gitlab升级(12.2.1到14.6.4)
- GIS跨界融合赋能多领域技术升级,江淮大地新应用成果喜人
- 认知升级,向钱一步
- (29)学习《手机成为诱因,家庭矛盾升级,亲子冲突何时结束(》收获)
- 偏向锁、轻量级锁、重量级锁的升级以及区别
- 妇女节,女生节,女神节,配置一度再升级
- mac升级之(xcrun:|mac升级之:xcrun: error: invalid active developer path, missing xcrun)
- 22天,来一次思想行动升级!
- 总裁爹地我们不约|总裁爹地我们不约 第八章 升级秘书长