Kubernetes 版本鎖定到1.12.3

今天對集羣節點的操作系統一升級,很多服務都不能用了。

使用 kubectl version檢查,發現是kubeadm自動升級到1.13.0了,但是kubelet服務還是1.12.3 。因爲kubernetes 1.13的變化比較大,尤其是etcd使用了版本3的接口,必須對所有集羣數據升級才能用,問題就出在這兒了。

目前升級整個集羣到1.13 工作量比較大,暫時沒有時間,還是需要繼續使用1.12系列。準備將所有節點降級到原來的1.12.3版本,並且阻止以後的自動升級。

ansible 命令如下:

echo "Install Kubernetes 1.12.3 & Hold the version."

ansible all -f 8 -i hosts_ansible -m shell -a " \ 
apt install kubeadm=1.12.3-00 kubectl=1.12.3-00 kubelet=1.12.3-00 -y --allow-downgrades --allow-change-held-packages && \ 
echo 'kubeadm hold' | dpkg --set-selections && \
echo 'kubectl hold' | dpkg --set-selections && \
echo 'kubelet hold' | dpkg --set-selections \
" --ask-sudo-pass --become --become-method=sudo

其中,hosts_ansible爲宿主機的定義清單文件,參考下面的格式:

[local]
10.1.1.201 ansible_ssh_port=22 ansible_ssh_host=10.1.1.201 ansible_ssh_user=supermap ansible_ssh_pass=SuperMap
10.1.1.202 ansible_ssh_port=22 ansible_ssh_host=10.1.1.202 ansible_ssh_user=supermap ansible_ssh_pass=SuperMap
10.1.1.203 ansible_ssh_port=22 ansible_ssh_host=10.1.1.203 ansible_ssh_user=supermap ansible_ssh_pass=SuperMap
10.1.1.142 ansible_ssh_port=22 ansible_ssh_host=10.1.1.142 ansible_ssh_user=supermap ansible_ssh_pass=SuperMap

運行之後,整個集羣的版本被鎖定爲1.12.3,服務已經自動恢復。

  • 注意,如果沒有足夠的冗餘節點,這一過程會造成服務中斷

參考:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章