mirror of
https://github.com/coredns/coredns.git
synced 2026-10-23 02:35:43 -04:00
plugin/kubernetes: support pods with multiple IPs (#8635)
The Pod object stored only the primary pod IP (status.podIP), causing PodIndex lookups to fail for IPv6 clients in dual-stack clusters. This prevented the metadata plugin from populating client-pod-name and client-namespace. Replace the PodIP string field with a PodIPs []string slice populated from status.podIPs, and update podIPIndexFunc to index all IPs. Signed-off-by: Christian Norbert Menges <christian.norbert.menges@sap.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -445,7 +446,7 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
|
||||
|
||||
for _, p := range k.APIConn.PodIndex(ip) {
|
||||
// check for matching ip and namespace
|
||||
if ip == p.PodIP && match(namespace, p.Namespace) {
|
||||
if slices.Contains(p.PodIPs, ip) && match(namespace, p.Namespace) {
|
||||
s := msg.Service{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}
|
||||
pods = append(pods, s)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user