Pods reporting error:"Error adding container to network "k8s-pod-network": cannot allocate new block due to per host block limit"
Below is the sample output of ./calicoctl ipam check --show-problem-ips
Found 3356 IPs that are allocated in IPAM but not actually in use.Scanning for IPs that are in use by a workload or node but not allocated in IPAM...Found 0 in-use IPs that are not in active IP pools.Found 0 in-use IPs that are in active IP pools but have no corresponding IPAM allocation.Scanning for IPAM handles with no matching IPs...Found 0 handles with no matching IPs (and 3365 handles with matches).Scanning for IPs with missing handle...Found 0 handles mentioned in blocks with no matching handle resource.Check complete; found 3356 problems.2.x, 3.x
Calico IPAM unable to allocate IP address to the PODs
Lock the data store
./calicoctl datastore migrate lock
Note: Sometimes, User might receive error as datastore not locked after executing the command. Please proceed with the next steps.
Generate a report using the check command
./calicoctl ipam check -o report.json
Release any unnecessary addresses
./calicoctl ipam release --from-report report.json
Unlock the data store
./calicoctl datastore migrate unlock
Restart the calico agents and calico-controller on the workload cluster.
Check the IPAM allocation and validate if the IP Problems are getting reduced.
./calicoctl ipam check --show-problem-ips (or) kubectl calico ipam check --show-problem-ips --allow-version-mismatch
Restart the worker nodes, if required.
Note: calicoctl is not available on the cluster controlplane by default.
Example:
curl -L https://github.com/projectcalico/calico/releases/download/v3.24.1/calicoctl-linux-amd64 -o calicoctl