专栏首页院长运维开发Kubeadm多master集群升级k8s版本

Kubeadm多master集群升级k8s版本

版本说明 本次升级版本为从1.15.3升级至1.16.3。另外更高的k8s版本,要注意内核要为4.4以上,尤其是1.18版本。

升级

master节点升级 查看当前集群组件列表

[root@master01 ~]# kubectl get nodes
NAME              STATUS   ROLES    AGE    VERSION
master01.sy.com   Ready    master   3d9h   v1.15.3
master02.sy.com   Ready    master   3d9h   v1.15.3
master03.sy.com   Ready    master   3d9h   v1.15.3
[root@master01 ~]# kubeadm config images list
I0521 20:18:24.336912   23537 version.go:248] remote version is much newer: v1.18.3; falling back to: stable-1.15
W0521 20:18:34.337440   23537 version.go:98] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.15.txt": Get https://storage.googleapis.com/kubernetes-release/release/stable-1.15.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
W0521 20:18:34.337495   23537 version.go:99] falling back to the local client version: v1.15.3
k8s.gcr.io/kube-apiserver:v1.15.3
k8s.gcr.io/kube-controller-manager:v1.15.3
k8s.gcr.io/kube-scheduler:v1.15.3
k8s.gcr.io/kube-proxy:v1.15.3
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.10
k8s.gcr.io/coredns:1.3.1

升级 Kubeadm 工具版本

[root@master01 ~]# yum update -y kubeadm-1.16.3-0

查看待升级的 kubernetes 组件镜像列表

[root@master01 ~]# kubeadm config images list
W0521 20:33:34.091388   32299 version.go:101] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get https://storage.googleapis.com/kubernetes-release/release/stable-1.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
W0521 20:33:34.091559   32299 version.go:102] falling back to the local client version: v1.16.3
k8s.gcr.io/kube-apiserver:v1.16.3
k8s.gcr.io/kube-controller-manager:v1.16.3
k8s.gcr.io/kube-scheduler:v1.16.3
k8s.gcr.io/kube-proxy:v1.16.3
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.15-0
k8s.gcr.io/coredns:1.6.2

创建镜像脚本,并打tag

[root@master01 ~]# cat pull-image.sh 
## 设置镜像仓库地址
MY_REGISTRY=registry.aliyuncs.com/google_containers
## 拉取镜像
docker pull ${MY_REGISTRY}/kube-apiserver:v1.16.3
docker pull ${MY_REGISTRY}/kube-controller-manager:v1.16.3
docker pull ${MY_REGISTRY}/kube-scheduler:v1.16.3
docker pull ${MY_REGISTRY}/kube-proxy:v1.16.3
docker pull ${MY_REGISTRY}/etcd:3.3.15-0
docker pull ${MY_REGISTRY}/pause:3.1
docker pull ${MY_REGISTRY}/coredns:1.6.2
## 设置标签
docker tag ${MY_REGISTRY}/kube-apiserver:v1.16.3          k8s.gcr.io/kube-apiserver:v1.16.3
docker tag ${MY_REGISTRY}/kube-scheduler:v1.16.3          k8s.gcr.io/kube-scheduler:v1.16.3
docker tag ${MY_REGISTRY}/kube-controller-manager:v1.16.3 k8s.gcr.io/kube-controller-manager:v1.16.3
docker tag ${MY_REGISTRY}/kube-proxy:v1.16.3              k8s.gcr.io/kube-proxy:v1.16.3
docker tag ${MY_REGISTRY}/etcd:3.3.15-0                    k8s.gcr.io/etcd:3.3.15-0
docker tag ${MY_REGISTRY}/pause:3.1                       k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/coredns:1.6.2                   k8s.gcr.io/coredns:1.6.2

升级kubeadm

[root@master01 ~]# kubectl drain master01.sy.com --ignore-daemonsets
[root@master01 ~]# kubeadm upgrade apply v1.16.3
[upgrade/config] Making sure the configuration is correct:
[upgrade/config] Reading configuration from the cluster...
[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[preflight] Running pre-flight checks.
[upgrade] Making sure the cluster is healthy:
[upgrade/version] You have chosen to change the cluster version to "v1.16.3"
[upgrade/versions] Cluster version: v1.15.3
[upgrade/versions] kubeadm version: v1.16.3
[upgrade/confirm] Are you sure you want to proceed with the upgrade? [y/N]: y
.........
[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.16.3". Enjoy!
[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.

升级 Kubelet

[root@master01 ~]# yum update -y kubelet-1.16.3-0
[root@master01 ~]# systemctl daemon-reload && systemctl restart kubelet

看日志发现kubelet有报错

cni.go:237] Unable to update cni config: no valid networks found in /etc/cni/net.d

解决

在v1.16中,kubelet将验证cni配置文件
在cbr0 这一行上面新增一行:
cni-conf.json: |
    {
      "cniVersion":"0.2.0",
      "name": "cbr0",
         
flannal镜像改成quay.io/coreos/flannel:v0.11.0-amd64

在看node状态

[root@master01 ~]# kubectl uncordon master01.sy.com
node/master01.sy.com uncordoned
[root@master01 ~]# kubectl get nodes
NAME              STATUS   ROLES    AGE    VERSION
master01.sy.com   Ready    master   4d3h   v1.16.3
master02.sy.com   Ready    master   4d3h   v1.15.3
master03.sy.com   Ready    master   4d2h   v1.15.3

其他master节点升级也一样操作,不过命令替换一下

[root@master02 ~]# kubeadm upgrade node experimental-control-plane

[root@master01 ~]# kubectl get nodes
NAME              STATUS   ROLES    AGE    VERSION
master01.sy.com   Ready    master   4d3h   v1.16.3
master02.sy.com   Ready    master   4d3h   v1.16.3
master03.sy.com   Ready    master   4d3h   v1.16.3

node节点升级

kubectl drain [节点名称] --ignore-daemonsets
yum update -y kubeadm-1.16.3-0
yum update -y kubelet-1.16.3-0
systemctl daemon-reload && systemctl restart kubelet

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 查看该虚机的详细信息

    查看该虚机的详细信息,如虚机名,镜像模板,启动时间等等。如果要查看所在物理点,需在执行该命令前,先source 管理员openrc文件

    院长技术
  • OpenStack查看该虚机的详细信息,如虚机名,镜像模板,启动时间等等。

    如果要查看所在物理点,需在执行该命令前,先source 管理员openrc文件 [root@controller ~]# . admin-openrc

    院长技术
  • K8s二进制升级从1.14.2至1.16.2

    升级前准备 master节点组件: kubectl,kube-apiserver,kube-controller-manager,kube-scheduler

    院长技术
  • kubeadm多master集群升级k8s版本

    本次升级版本为从1.15.3升级至1.16.3。另外更高的k8s版本,要注意内核要为4.4以上,尤其是1.18版本。

    SY小站
  • 基于Aptana3+Django开发blog的示例

    3、选择django的版本号,先查看当前系统中的django版本号(IDE默认选择1.2 or later)

    meteoric
  • 性能调优之redo切换频率(47天)

    生产系统的一个库(负责容错处理的),目前遇到了严重的性能问题,数据量也大的出奇,一个分区表一百多个分区,blob字段达到了800多G.查看 AWR 系统负载倒不...

    jeanron100
  • webpack打包原理入门探究(七)模板处理

    起初为什么会想要学习 webpack 打包原理,只是因为好奇心发作,由于在工作中,我有处理过项目的首屏加载速度优化的过程,虽然但是是解决了加载问题,也对那些 l...

    公众号---志学Python
  • Django学习_简易博客(二)

    zx钟
  • ​Tungsten Fabric入门宝典丨关于安装的那些事(上)2

    由于MP-BGP支持两个集群之间的缝合(stitching),因此这些集群很容易扩展到多集群环境。

    Tungsten Fabric
  • 深度解析ug1292(6)

    当设计出现布线拥塞时,通常会导致布线延迟增大,从而影响时序收敛。布线拥塞程度可通过如下两种方式获取:

    Lauren的FPGA

扫码关注云+社区

领取腾讯云代金券