calicoctl ipam show --show-borrowed cannot determine IP state
Some IP already used by pod not exist in the command output cause pod used these IP failed initialize by cni .
kubectl get pod |grep 172.16.102.20
pod-1-172-16-102-20 0/3 Init:0/1 0 2m57s <none> k8snew70 <none> <none>
pod-2-172-16-102-20 3/3 Running 0 7d1h 172.16.102.20 k8snew73 <none> <none>
pod-1 was pending by cni because ip 172.16.102.20 already used by pod-2
describe pod FailedCreatePodSandBox event output:
Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "8492a67638609c85805e98622feb210008dcebaf46e615c6df73254104b3c94c" network for pod "redis-testbug-172-16-102-20": networkPlugin cni failed to set up pod "redis-testbug-172-16-102-20_default" network: error getting IP from IPAM: resource already exists: 172.16.102.20
I have tried create 3 pod in the meantime, finally two of three IPs were saved as borrowed, one not. seem not guaranteed.
I also tried use another command calicoctl ipam show --ip to determine IP state. but output of this command was not formatted and could change between different versions. so the result not reliable.
Annotations of pod is like, Let me know if you need other info to help troubleshoot.
Annotations: capacity.topolvm.cybozu.com/00default: 1073741824
cni.projectcalico.org/ipAddrs: ["172.16.102.20"]
cni.projectcalico.org/podIP: 172.16.102.20/32
cni.projectcalico.org/podIPs: 172.16.102.20/32
Expected Behavior
Current Behavior
Possible Solution
Steps to Reproduce (for bugs)
1. 2. 3. 4.
Context
Your Environment
- Calico version
> calicoctl version
Client Version: v3.15.5
Git commit: 20918766
Cluster Version: v3.15.5
Cluster Type: k8s,bgp,kubeadm,kdd
- Orchestrator version (e.g. kubernetes, mesos, rkt): k8s v1.19.10
- Operating System and version:
- Link to your project (optional):
~~@hjy93 are you using annotations to request a specific IP address?~~
EDIT: Nevermind, I see that you are.
You have two pods both with the same annotation, and Calico won't assign the same IP to two pods (by design, this is required).
You should change your rollingupdate configuration to Recreate to delete the old pod before launching the new.
@caseydavenport Thanks for help.
However, this is not my question. Please forgive me if I haven't make it clear. Let me try again.
We have another IP management service to assign static ip for every pod and this service use the command calicoctl ipam show --show-borrowed |grep <my-ip> to check if the IP to be assigned was already used.
The reason why my two pods use the same IP is because the above command output didn't , which it should, show the IP already assigned to the first pod.
e.g.
After IP1 was used by pod1. calicoctl ipam show --show-borrowed command output shoud contain IP1's borrowed info as I expected. But it not. Then happens pod2 use IP1 again in my case.
That's what I mean I couldn't determine IP usage state based on this command.
Could you share what calicoctl ipam show contained for your situation, and an example of what you want it to contain? I'm still not entirely sure what it is that is missing.
@caseydavenport Thanks, I re-read calico's understanding of borrowed. Exactly as you said.