Kubernetes 1.12.1快速升級

Kubernetes 1.12.1快速升級,包括升級kubeadm/kubectl/kubelet版本、拉取鏡像、升級Kubernetes集羣三個主要步驟。linux

一、升級kubeadm/kubectl/kubelet版本

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

查看該版本的容器鏡像版本:git

kubeadm config images list

輸出以下:github

~# kubeadm config images list

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

二、拉取容器鏡像

我給鏡像到了阿里雲的杭州機房的容器倉庫裏,拉取仍是比較快的。docker

echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.12.1 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.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.12.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.12.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.12.1
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.1 k8s.gcr.io/kube-apiserver:v1.12.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.12.1 k8s.gcr.io/kube-scheduler:v1.12.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.12.1 k8s.gcr.io/kube-controller-manager:v1.12.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.12.1 k8s.gcr.io/kube-proxy:v1.12.1
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.1 Images FINISHED."
echo "into registry.cn-hangzhou.aliyuncs.com/openthings, "
echo "           by openthings@https://my.oschina.net/u/2306127."
echo "=========================================================="

echo ""

保存爲shell腳本,而後執行。shell

三、升級Kubernetes集羣

先查看一下須要升級的各個組件的版本。api

使用kubeadm upgrade plan ,輸出的版本升級信息以下:網絡

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

確保上面的容器鏡像已經下載(若是沒有提早下載,可能被網絡阻隔致使掛起),而後執行升級:app

kubeadm upgrade apply v1.12.1

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

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

四、工做節點的升級

每一個工做節點須要拉取上面對應版本的鏡像,以及安裝kubelet的對應版本。阿里雲

Verify

~$ kubectl version

Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.1", 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.1", GitCommit:"4ed3216f3ec431b140b1d899130a69fc671678f4", GitTreeState:"clean", BuildDate:"2018-10-05T16:36:14Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}

 

Get Pod

kubectl get pod --all-namespaces

view list.

相關文章
相關標籤/搜索