This script detects and resolves IP address conflicts in Kubernetes clusters using the Whereabouts CNI plugin.
It identifies duplicate IP allocations in both pod annotations and Whereabouts CRDs, then resolves them using a deterministic priority system.
TKG versions prior to 2.5.4
TCA: 3.2.0.1, 3.3.0.1
TCP: 5.0, 5.0.2
Whereabouts v0.5.4 has a known issue that results in this behavior.
Resolved in TCA 3.3.0.1
This script detects and resolves IP address conflicts in Kubernetes clusters using the Whereabouts CNI plugin. It identifies duplicate IP allocations in both pod annotations and Whereabouts CRDs, then resolves them using a deterministic priority system.
Download the script attached to this KB and copy it to the Kubernetes cluster's control plane.
kubectl` - Must be configured with access to your Kubernetes clusterjq` - JSON processor (version 1.5+)base64` - Base64 encoding/decoding (usually pre-installed)bash` - Version 4.0+ (for associative arrays)timeout` - Command timeout utility (script has fallback if not available)
./detect_IP_conflict_v1.0.2.sh [MODE]
./detect_IP_conflict_v1.0.2.sh A./detect_IP_conflict_v1.0.2.sh
./detect_IP_conflict_v1.0.2.sh B./detect_IP_conflict_v1.0.2.sh C
--grace-period=0 --force` for immediate deletion
./detect_IP_conflict_v1.0.2.sh A
Output example:=== Whereabouts IP Duplicate Detector(v1.0.2) ===Mode: A (A=Detect, B=Fix CRD, C=Fix+Delete Pods)Priority: Pods with CRD entries in Whereabouts are kept over pods without CRD entries
Scanning pods for network-status IPs......
Duplicate pod annotation IP detected: 10.0.#.# Found 2 pods with this IP: - <NameSpace>/<PodName-1> (created: 2024-01-01T10:00:00Z) - <NameSpace>/<PodName-2> (created: 2024-01-01T11:00:00Z) <NameSpace>/<PodName-1>: CRD entry = true <NameSpace>/<PodName-2>: CRD entry = false → Will DELETE: <NameSpace>/<PodName-2> (no CRD entry) → Will KEEP: <NameSpace>/<PodName-1> (has CRD entry in Whereabouts)
./detect_IP_conflict_v1.0.2.sh B
./detect_IP_conflict_v1.0.2.sh CKUBECTL_TIMEOUT=120 ./detect_IP_conflict_v1.0.2.sh A
Duplicate pod annotation IP detected: <IP> Found N pods with this IP: - <namespace>/<pod> (created: <timestamp>) - <namespace>/<pod> (created: <timestamp>) <namespace>/<pod>: CRD entry = true/false <namespace>/<pod>: CRD entry = true/false → Will DELETE: <namespace>/<pod> (<reason>) → Will KEEP: <namespace>/<pod> (<reason>)
Reasons for deletion:
Processing CRD: <namespace>/<crd-name>→ Removing stale allocation <namespace>/<pod>→ Removing duplicate CRD allocation <namespace>/<pod> for IP <IP>✔ Updated <namespace>/<crd-name>
Deleting pod <namespace>/<pod> (duplicate IP <IP>)✓ Successfully deleted <namespace>/<pod>
KUBECTL_TIMEOUT=5 ./detect_IP_conflict_v1.0.2.sh A kubectl connectivitykubectl get pods -Acommand -v kubectl
command -v jq
command -v base64
kubectl get pods -Akubectl auth can-i delete pods
./detect_IP_conflict_v1.0.2.sh A
./detect_IP_conflict_v1.0.2.sh B ./detect_IP_conflict_v1.0.2.sh C
KUBECTL_TIMEOUT=60 ./detect_IP_conflict_v1.0.2.sh A
./detect_IP_conflict_v1.0.2.sh A./detect_IP_conflict_v1.0.2.sh B
./detect_IP_conflict_v1.0.2.sh A
./detect_IP_conflict_v1.0.2.sh C./detect_IP_conflict_v1.0.2.sh A
KUBECTL_TIMEOUT=60 ./detect_IP_conflict_v1.0.2.sh A
KUBECTL_TIMEOUT=5 ./detect_IP_conflict_v1.0.2.sh A
The script uses deterministic priority to decide which pod to keep when multiple pods claim the same IP:
For issues or questions: