您好,登錄后才能下訂單哦!
kubernetes中如何修改節點名稱,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
一.修改系統主機名
[root@host1 ~]# hostname master
二.修改kubelet節點主機名
修改kubelet啟動參數--hostname-override=master
重啟kubelet服務
[root@master ~]# systemctl restart kubelet
這時查看kubelet運行日志
[root@master ~]# journalctl -xe -u kubelet
會看到如下報錯
Mar 23 13:15:27 master kubelet[13508]: E0323 13:15:27.320556 13508 kubelet_node_status.go:106] Unable to register node "master" with API server: nodes "master" is forbidden: node "host1" cannot modify node "master"
停止kubelet服務并刪除當前節點
[root@master ~]# systemctl stop kubelet [root@master ~]# kubectl delete node host1
刪除kubelet.kubeconfig,kubelet.key,kubelet.crt,kubelet-client.key和kubelet-client.crt
[root@master ~]# rm -f /etc/kubernetes/kubelet.kubeconfig [root@master ~]# rm -f /etc/kubernetes/ssl/kubelet*
再重啟kubelet
[root@master ~]# systemctl restart kubelet
查看證書狀態
[root@master ~]# kubectl get csr NAME AGE REQUESTOR CONDITION node-csr-GIAqC5LBI_7c6TlMW8wugv_TlHfs1CShZhnEyLgxvSI 1m kubelet-bootstrap Pending
允許證書
[root@master ~]# kubectl certificate approve node-csr-GIAqC5LBI_7c6TlMW8wugv_TlHfs1CShZhnEyLgxvSI
再次查看證書狀態
[root@master ~]# kubectl get csr NAME AGE REQUESTOR CONDITION node-csr-GIAqC5LBI_7c6TlMW8wugv_TlHfs1CShZhnEyLgxvSI 1m kubelet-bootstrap Approved,Issued
查看節點狀態
[root@master ~]# kubectl get node NAME STATUS ROLES AGE VERSION host2 Ready <none> 34m v1.9.5 host3 Ready <none> 34m v1.9.5 master Ready <none> 18s v1.9.5
三.修改calico節點主機名
這時候查看calico運行狀態
[root@master ~]# calicoctl node status Calico process is not running.
calico服務會輸出如下錯誤日志
[WARNING][9] startup.go 757: calico node 'host1' is already using the IPv4 address 10.233.119.0
切換到其他節點上查看,如host2
[root@host2 ~]# calicoctl get node NAME host1 host2 host3 [root@host2 ~]# calicoctl node status Calico process is running. IPv4 BGP status +--------------+-------------------+-------+----------+--------------------------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +--------------+-------------------+-------+----------+--------------------------------+ | 10.21.21.254 | node-to-node mesh | start | 05:16:47 | Active Socket: Connection | | | | | | refused | | 10.21.21.245 | node-to-node mesh | up | 04:44:35 | Established | +--------------+-------------------+-------+----------+--------------------------------+ IPv6 BGP status No IPv6 peers found.
獲取host1節點配置,保存輸出內容到文件master.yaml中
[root@host2 ~]# calicoctl get node host1 -o yaml apiVersion: projectcalico.org/v3 kind: Node metadata: creationTimestamp: 2018-03-23T04:44:29Z name: host1 resourceVersion: "485" uid: dfb352cf-2e54-11e8-82e7-52540000361b spec: bgp: ipv4Address: 10.21.21.254/16 ipv4IPIPTunnelAddr: 10.233.119.0
刪除host1
[root@host2 ~]# calicoctl delete node host1 Successfully deleted 1 'Node' resource(s)
修改master.yaml
apiVersion: projectcalico.org/v3 kind: Node metadata: name: master uid: dfb352cf-2e54-11e8-82e7-52540000361b spec: bgp: ipv4Address: 10.21.21.254/16 ipv4IPIPTunnelAddr: 10.233.119.0
創建calico節點
[root@host2 ~]# calicoctl apply -f master.yaml Successfully applied 1 'Node' resource(s)
刪除異常的calico Pod
[root@host2 ~]# kubectl get pod -n kube-system NAME READY STATUS RESTARTS AGE calico-kube-controllers-5f47974799-ttz7s 1/1 Running 0 6m calico-node-274q9 2/2 Running 0 40m calico-node-dp8dz 2/2 Running 0 40m calico-node-rh3kd 1/2 CrashLoopBackOff 5 5m [root@host2 ~]# kubectl delete pod -n kube-system calico-node-rh3kd pod "calico-node-rh3kd" deleted
等待calico Pod重建
[root@host2 ~]# kubectl get pod -n kube-system NAME READY STATUS RESTARTS AGE calico-kube-controllers-5f47974799-ttz7s 1/1 Running 0 7m calico-node-274q9 2/2 Running 0 40m calico-node-9th5r 2/2 Running 0 12s calico-node-dp8dz 2/2 Running 0 40m
看完上述內容,你們掌握kubernetes中如何修改節點名稱的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。