Kubernetes slave節點升級至1.3版本註冊失敗問題解決

Atlantisfall發表於2016-12-28

最近在之前搭建的1.2版本的Kubernetes叢集中新增3個slave節點,使用之前寫的slave節點安裝指令碼yum install flanneld kubernetes,安裝完成後,修改kubernetes配置,啟動kubelet,卻發現之前的叢集無法看到新新增的節點,在新slave節點檢視kubelet的status,發現如下報錯:

Dec 28 04:37:02 master-54 kubelet[9688]: E1228 04:37:02.738298    9688 kubelet.go:1222] Unable to register node "192.168.6.54" with API server: the body of the request was in an unknown format - accepted media types include: application/json, application/yaml

在新節點上使用kubectl version檢視版本號,發現已經到了1.3版本,因此,懷疑是因為版本號不一致導致的問題。首先,使用yum list檢視所有支援下載的kubernetes版本:

# yum list --show-duplicate|grep kube
kubernetes.x86_64                       1.2.0-0.13.gitec7364b.el7      @extras  
kubernetes-client.x86_64                1.2.0-0.13.gitec7364b.el7      @extras  
kubernetes-master.x86_64                1.2.0-0.13.gitec7364b.el7      @extras  
kubernetes-node.x86_64                  1.2.0-0.13.gitec7364b.el7      @extras  
cockpit-kubernetes.x86_64               0.71-1.el7                     extras   
cockpit-kubernetes.x86_64               0.77-3.1.el7                   extras   
cockpit-kubernetes.x86_64               0.93-3.el7                     extras   
cockpit-kubernetes.x86_64               0.93-3.el7.centos.0.1          extras   
cockpit-kubernetes.x86_64               0.96-2.el7.centos              extras   
cockpit-kubernetes.x86_64               0.103-1.el7.centos             extras   
cockpit-kubernetes.x86_64               0.108-1.el7.centos             extras   
cockpit-kubernetes.x86_64               0.114-2.el7.centos             extras   
cockpit-kubernetes.x86_64               122-3.el7.centos               extras   
kubernetes.x86_64                       1.0.3-0.2.gitb9a88a7.el7       extras   
kubernetes.x86_64                       1.2.0-0.6.alpha1.git8632732.el7
kubernetes.x86_64                       1.2.0-0.9.alpha1.gitb57e8bd.el7
kubernetes.x86_64                       1.2.0-0.11.git738b760.el7      extras   
kubernetes.x86_64                       1.2.0-0.12.gita4463d9.el7      extras   
kubernetes.x86_64                       1.2.0-0.13.gitec7364b.el7      extras   
kubernetes.x86_64                       1.3.0-0.3.git86dc49a.el7       extras   
kubernetes-ansible.noarch               0.6.0-0.1.gitd65ebd5.el7       epel     
kubernetes-client.x86_64                1.0.3-0.2.gitb9a88a7.el7       extras   
kubernetes-client.x86_64                1.2.0-0.6.alpha1.git8632732.el7
kubernetes-client.x86_64                1.2.0-0.9.alpha1.gitb57e8bd.el7
kubernetes-client.x86_64                1.2.0-0.11.git738b760.el7      extras   
kubernetes-client.x86_64                1.2.0-0.12.gita4463d9.el7      extras   
kubernetes-client.x86_64                1.2.0-0.13.gitec7364b.el7      extras   
kubernetes-client.x86_64                1.3.0-0.3.git86dc49a.el7       extras   
kubernetes-master.x86_64                1.0.3-0.2.gitb9a88a7.el7       extras   
kubernetes-master.x86_64                1.2.0-0.6.alpha1.git8632732.el7
kubernetes-master.x86_64                1.2.0-0.9.alpha1.gitb57e8bd.el7
kubernetes-master.x86_64                1.2.0-0.11.git738b760.el7      extras   
kubernetes-master.x86_64                1.2.0-0.12.gita4463d9.el7      extras   
kubernetes-master.x86_64                1.2.0-0.13.gitec7364b.el7      extras   
kubernetes-master.x86_64                1.3.0-0.3.git86dc49a.el7       extras   
kubernetes-node.x86_64                  1.0.3-0.2.gitb9a88a7.el7       extras   
kubernetes-node.x86_64                  1.2.0-0.6.alpha1.git8632732.el7
kubernetes-node.x86_64                  1.2.0-0.9.alpha1.gitb57e8bd.el7
kubernetes-node.x86_64                  1.2.0-0.11.git738b760.el7      extras   
kubernetes-node.x86_64                  1.2.0-0.12.gita4463d9.el7      extras   
kubernetes-node.x86_64                  1.2.0-0.13.gitec7364b.el7      extras   
kubernetes-node.x86_64                  1.3.0-0.3.git86dc49a.el7       extras   
kubernetes-unit-test.x86_64             1.0.3-0.2.gitb9a88a7.el7       extras   
kubernetes-unit-test.x86_64             1.2.0-0.6.alpha1.git8632732.el7
kubernetes-unit-test.x86_64             1.2.0-0.9.alpha1.gitb57e8bd.el7
kubernetes-unit-test.x86_64             1.2.0-0.11.git738b760.el7      extras   
kubernetes-unit-test.x86_64             1.2.0-0.12.gita4463d9.el7      extras   
kubernetes-unit-test.x86_64             1.2.0-0.13.gitec7364b.el7      extras   
kubernetes-unit-test.x86_64             1.3.0-0.3.git86dc49a.el7       extras

其次,在master節點使用rpm命令檢視之前下載的版本:

# rpm -qa |grep kube
kubernetes-master-1.2.0-0.13.gitec7364b.el7.x86_64
kubernetes-1.2.0-0.13.gitec7364b.el7.x86_64
kubernetes-client-1.2.0-0.13.gitec7364b.el7.x86_64
kubernetes-node-1.2.0-0.13.gitec7364b.el7.x86_64

從結果可以看出,master節點安裝的版本為:kubernetes-1.2.0-0.13.gitec7364b.el7,因此,在新節點重新下載指定版本的kubernetes。
a.刪除已安裝的kubernetes:

yum remove -y kube*

b.安裝指定版本的kubernetes:

yum install -y kubernetes-1.2.0-0.13.gitec7364b.el7

安裝完成後,調整kubelet配置,啟動kubelet服務,註冊成功!
結論:Kubernetes 1.3版本slave節點無法註冊到1.2版本master節點。
感謝onlyellow的友情支援。

相關文章