Kubernetes 1.12.3快速升级

Kubernetes 1.12.3已经正式发布,快速升级(含国内镜像快速下载连接)包括升级kubeadm/kubectl/kubelet版本、拉取镜像、升级Kubernetes集群三个主要步骤。注意Kubernetes 1.12.3版本暂时不支持最新的Docker 18.09,只能用Docker 18.06及如下版本,参考《Ubuntu上软件锁定版本不更新》安装特定DockerCE版本。linux

一、升级kubeadm/kubectl/kubelet版本

sudo apt install kubeadm=1.12.3-00 kubectl=1.12.3-00 kubelet=1.12.3-00

查看该版本的容器镜像版本:ios

kubeadm config images list

输出以下:git

~# kubeadm config images list

k8s.gcr.io/kube-apiserver:v1.12.3
k8s.gcr.io/kube-controller-manager:v1.12.3
k8s.gcr.io/kube-scheduler:v1.12.3
k8s.gcr.io/kube-proxy:v1.12.3
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.2.24
k8s.gcr.io/coredns:1.2.2

二、拉取容器镜像

原始的kubernetes镜像文件在gcr上,不能直接下载。我给镜像到了阿里云的杭州机房的容器仓库里,拉取仍是比较快的。github

echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.12.2 Images from aliyuncs.com ......"
echo "=========================================================="
echo ""

MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings

## 拉取镜像
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.12.3
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.12.3
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.12.3
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.12.3
docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd:3.2.24
docker pull ${MY_REGISTRY}/k8s-gcr-io-pause:3.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.2.2


## 添加Tag
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.12.3 k8s.gcr.io/kube-apiserver:v1.12.3
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.12.3 k8s.gcr.io/kube-scheduler:v1.12.3
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.12.3 k8s.gcr.io/kube-controller-manager:v1.12.3
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.12.3 k8s.gcr.io/kube-proxy:v1.12.3
docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd:3.2.24 k8s.gcr.io/etcd:3.2.24
docker tag ${MY_REGISTRY}/k8s-gcr-io-pause:3.1 k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-coredns:1.2.2 k8s.gcr.io/coredns:1.2.2

echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.12.3 Images FINISHED."
echo "into registry.cn-hangzhou.aliyuncs.com/openthings, "
echo "           by openthings@https://my.oschina.net/u/2306127."
echo "=========================================================="

echo ""

保存为shell脚本,而后执行。docker

三、升级Kubernetes集群

先查看一下须要升级的各个组件的版本。shell

使用kubeadm upgrade plan ,输出的版本升级信息以下:api

COMPONENT            CURRENT   AVAILABLE
API Server           v1.11.2   v1.12.3
Controller Manager   v1.11.2   v1.12.3
Scheduler            v1.11.2   v1.12.3
Kube Proxy           v1.11.2   v1.12.3
CoreDNS              1.1.3     1.2.2
Etcd                 3.2.18    3.2.24

确保上面的容器镜像已经下载(若是没有提早下载,可能被网络阻隔致使挂起),而后执行升级:网络

kubeadm upgrade -y apply v1.12.3

看到下面信息,就OK了。app

[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.12.3". Enjoy!

四、工做节点的升级

每一个工做节点须要拉取上面对应版本的镜像,以及安装kubelet的对应版本。ui

检查版本:

~$ kubectl version

Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.3", GitCommit:"4ed3216f3ec431b140b1d899130a69fc671678f4", GitTreeState:"clean", BuildDate:"2018-10-05T16:46:06Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.3", GitCommit:"4ed3216f3ec431b140b1d899130a69fc671678f4", GitTreeState:"clean", BuildDate:"2018-10-05T16:36:14Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}

查看Pod信息:

kubectl get pod --all-namespaces

完成。

更多参考:

相关文章
相关标签/搜索