作者信息
Author:Vincent
E-Mail:46603415@qq.com
Master 升级
CentOS 7 切换 阿里云源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum makecache
yum repolist
清理Kubernetes 官方源
if [ -f /etc/yum.repos.d/kubernetes.repo ];then
rm -rf /etc/yum.repos.d/kubernetes.repo
fi
导入阿里云源
cat << EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
enabled=1
EOF
刷新缓存
yum makecache
列出可升级的 kubeadm 版本
yum list kubeadm.x86_64 --showduplicates |sort -r
最新版本
kubeadm.x86_64 1.20.0-0 kubernetes
安装 kubeadm 1.20.0
yum install -y kubeadm-1.20.0-0 --disableexcludes=kubernetes
验证 kubeadm 版本
kubeadm version
测试升级计划
sudo kubeadm upgrade plan
对控制面节点的保护
kubectl drain kubernetes-master-01 --delete-local-data --ignore-daemonsets
升级节点到 1.20.0.0
sudo kubeadm upgrade apply v1.20.0
取消对控制面节点的保护
kubectl uncordon kubernetes-master-01
查看kubelet 版本
kubelet --version
如果 kubelet 版本 大于 1.20.0 则卸载降级再安装 1.20.0
yum remove kubelet.x86_64 -y
yum install -y kubelet-1.20.0-0 --disableexcludes=kubernetes
重启 kubelet
systemctl daemon-reload
systemctl restart kubelet
Worker 升级
CentOS 7 切换 阿里云源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum makecache
yum repolist
清理Kubernetes 官方源
if [ -f /etc/yum.repos.d/kubernetes.repo ];then
rm -rf /etc/yum.repos.d/kubernetes.repo
fi
导入阿里云源
cat << EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
enabled=1
EOF
刷新缓存
yum makecache
列出可升级的 kubeadm 版本
yum list kubeadm.x86_64 --showduplicates |sort -r
最新版本
kubeadm.x86_64 1.20.0-0 kubernetes
安装最新版的 kubeadm
yum install -y kubeadm-1.20.0-0 --disableexcludes=kubernetes
验证 kubeadm 版本
kubeadm version
对控制面节点的保护 在Master上执行
kubectl drain kubernetes-worker-01 --delete-local-data --ignore-daemonsets
升级 kubelet 配置
kubeadm upgrade node
查看kubelet 版本
kubelet --version
如果 kubelet 版本 大于 1.20.0 则写在降级
yum remove kubelet.x86_64 -y
yum install -y kubelet-1.20.0-0 --disableexcludes=kubernetes
重启 kubelet
systemctl daemon-reload
systemctl restart kubelet
取消对控制面节点的保护 在 Master 执行
kubectl uncordon kubernetes-worker-01
一些必要的处理
如果用了kuboard
cp /etc/kubernetes/manifests/kube-apiserver.yaml /home/data/backup/kube-apiserver
vi /etc/kubernetes/manifests/kube-apiserver.yaml
参数最后增加
- --oidc-issuer-url=https://dex地址
- --oidc-client-id=kuboard-dex-client
- --oidc-username-claim=preferred_username
- --oidc-username-prefix=-
- --oidc-groups-claim=groups
- --oidc-groups-prefix=
必要处理
如果不做 kubectl get cs 会 unhealth
cp /etc/kubernetes/manifests/kube-controller-manager.yaml /home/data/backup/kube-apiserver
vi /etc/kubernetes/manifests/kube-controller-manager.yaml
# - --port=0
cp /etc/kubernetes/manifests/kube-scheduler.yaml /home/data/backup/kube-apiserver
vi /etc/kubernetes/manifests/kube-scheduler.yaml
# - --port=0
完成
Enjoy