k8s升級,此次升級是1.12.0–>1.13.0
阿新 • • 發佈:2018-12-06
nap cor -c emctl ont 進行 doc dem latest
準備
1、首先升級master節點的基礎組件kubeadm、kubelet、kubectl
apt-get update && apt-get upgrade kubeadm
更新到1.13.0後,在master執行,執行一次
kubeadm upgrade plan
[upgrade/versions] Latest version in the v1.12 series: v1.13.0
External components that should be upgraded manually before you upgrade the control plane with 'kubeadm upgrade apply':
COMPONENT CURRENT AVAILABLE
Etcd 3.2.22 3.2.24
Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT CURRENT AVAILABLE
Kubelet 1 x v1.12.0 v1.13.0
2 x v1.13.0 v1.13.0
Upgrade to the latest version in the v1.12 series:
COMPONENT CURRENT AVAILABLE
API Server v1.12.0 v1.13.0
Controller Manager v1.12.0 v1.13.0
Scheduler v1.12.0 v1.13.0
Kube Proxy v1.12.0 v1.13.0
CoreDNS 1.2.2 1.2.6
You can now apply the upgrade by executing the following command:
kubeadm upgrade apply v1.13.0
需要先升級etcd服務,我們的版本是3.2.22,需要升級到3.2.24
2、備份etcd數據(以防萬一)
etcdctl snapshot save backup.db
查看備份的狀態
etcdctl --write-out=table snapshot status backup.db
3、下載新的etcd,這裏我們部署1.13.0的kubernetes需要的是3.2.24
[](https://github.com/etcd-io/etcd/releases/download/v3.2.24/etcd-v3.2.24-linux-amd64.tar.gz)
wget https://github.com/etcd-io/etcd/releases/download/v3.2.24/etcd-v3.2.24-linux-amd64.tar.gz
由於之前部署的是三節點的etcd集群,所以可以做到無縫升級,一個節點一個節點進行升級,每個節點恢復正常後在升級下一個節點;
1)停掉當前節點
systemctl stop etcd
2)將下載好的文件解壓,然後替換之前的etcd和etcdctl,替換完成後啟動etcd
systemctl start etcd
3)每個節點替換完成後檢查服務狀態
etcdctl endpoint health
Upgrade master and node packages
kubectl drain node_name --ignore-daemonsets
master節點需要加上--ignore-daemonsets,node節點不用
更新
apt-get update
apt-get upgrade -y kubeadm
更新過程中要保證服務不中斷,輪詢替換更新
Upgrade kubelet on each node
1)On each node except the master node, upgrade the kubelet config:
kubeadm upgrade node config --kubelet-version \$(kubelet --version | cut -d ' ' -f 2)
2)Restart the kubelet process:
systemctl restart kubelet
3)Verify that the new version of the kubelet is running on the node:
systemctl status kubelet
4)Bring the node back online by marking it schedulable:
kubectl uncordon \$NODE
5)verify that all nodes are available again by running the following command from anywhere kubectl can access the cluster:
kubectl get nodes
The STATUS column should show Ready for all your nodes, and the version number should be updated.
Rolling update
如果升級失敗了,一般會自動回滾到之前的版本,如果出現異常沒有回退到之前的版本,可以再次執行kubeadm upgrade
kubeadm upgrade apply v1.12.0 --force
參考:https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade-1-13/
k8s升級,此次升級是1.12.0–>1.13.0