Kubernetes之network: failed to set bridge addr: “cni0“ already has an IP address different from xxx问题

Kubernetes之network: failed to set bridge addr: “cni0” already has an IP address different from xxx问题

1. Problem

When using Kubernetes to deploy the application, I found that a Pod could not be created successfully. kubectl describe pods <pod-name> -n <namespace>The results obtained are as follows:

From the screenshot above, you can see that the problem occurs in the IP allocation to the Pod, which means that the IP of cni0 is different from 10.244.9.1/24. Next, we enter node9 and use the ifconfigcommand to view the IP information. The results are as follows:

From the above figure we can see that the IP of flannel.1 is 10.244.9.0, and then we use it again cat /run/flannel/subnet.env. The content of the file is as follows:

In fact, the current problem is compared It is clear that the overlay network we use is Flannel, which means that the IP address segment of the Pod should be under the subnet of Flannel, and now we see that the IP address segment of cni0 is different from the address segment of flannel subnet, so there is a problem.

2 Solution

  • Method 1 is to modify the IP segment of cni0 to 10.244.9.1.
  • Method 2 is to delete the wrong network card, and then it will be rebuilt automatically.
    Next, we delete the wrong cni0, and then let it rebuild by itself, the operation process is as follows:
    sudo ifconfig cni0 down    
    sudo ip link delete cni0

Related reference:
Solve k8s "failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24"

Guess you like

Origin blog.csdn.net/qq_41489540/article/details/114300470