agent: include addresses IPs in CNI result
Build flock Image / build (push) Successful in 1m37s

resultFromAllocation now appends Addresses entries to the CNI result so
they appear in pod.status.podIPs. Kubernetes and workloads that inspect
pod metadata (e.g. Plex remote-access detection) see the public IPs
alongside the IPAM-allocated ones.

Anycast IPs are intentionally excluded — they're shared across replicas
and must not appear as per-pod IPs in Kubernetes.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Donavan Fritz
2026-04-28 18:11:17 -05:00
parent 2daa2a21f3
commit 4a60c004c3
+19
View File
@@ -254,6 +254,25 @@ func resultFromAllocation(ifName string, a Allocation) *current.Result {
Address: net.IPNet{IP: ip4, Mask: net.CIDRMask(32, 32)},
})
}
// Addresses are assigned to eth0 and should appear in pod.status.podIPs
// so Kubernetes and workloads that inspect pod metadata see them.
for _, s := range a.Addresses {
ip := net.ParseIP(s)
if ip == nil {
continue
}
if v4 := ip.To4(); v4 != nil {
r.IPs = append(r.IPs, &current.IPConfig{
Interface: intPtr(0),
Address: net.IPNet{IP: v4, Mask: net.CIDRMask(32, 32)},
})
} else {
r.IPs = append(r.IPs, &current.IPConfig{
Interface: intPtr(0),
Address: net.IPNet{IP: ip.To16(), Mask: net.CIDRMask(128, 128)},
})
}
}
return r
}