今天对集群节点的操作系统一升级,很多服务都不能用了。
使用 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,服务已经自动恢复。
- 注意,如果没有足够的冗余节点,这一过程会造成服务中断。
参考: