天天看點

解決k8s"failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

測試環境由于機房斷電,導緻對應虛拟機暴力重新開機,之後所在k8s服務error,檢視系統日志,發現k8s三個節點的flannel檔案均丢失。

解決k8s"failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

1.首先我們重新配置k8s的flannel檔案,可以參考其他環境的檔案配置,也可以重新安裝插件生成,會在/run下面生成flannel檔案夾,下面包含網絡配置環境變量

解決k8s"failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

注明:三個節點的subnet網段不能相同

2.重配flannel之後發現,有兩個節點依然不能配置設定網絡,導緻服務error

解決k8s"failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

檢視error的pod日志,發現報錯,對應節點的cni網絡沖突

解決k8s"failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

3.檢視出錯節點cni0的網卡配置,發現cni0的這個網卡位址是10.244.2.1,明顯與報錯中的10.244.1.1不一緻

解決k8s"failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

4.我們可以将其改為10.244.1.1,也可将這個錯誤的網卡删掉,它會自己重建,這裡采用删除重生的方法,首先停用網絡,然後删除配置

ifconfig cni0 down

ip link delete cni0

然後檢視節點重建的cni0網卡,會依據flannel的網絡環境配置生成

解決k8s"failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

5.檢視叢集環境服務,系統恢複。