mirror of
https://github.com/coredns/coredns.git
synced 2026-10-18 00:05:42 -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:
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -271,7 +272,9 @@ func podIPIndexFunc(obj any) ([]string, error) {
|
||||
if !ok {
|
||||
return nil, errObj
|
||||
}
|
||||
return []string{p.PodIP}, nil
|
||||
idx := make([]string, len(p.PodIPs))
|
||||
copy(idx, p.PodIPs)
|
||||
return idx, nil
|
||||
}
|
||||
|
||||
func svcIPIndexFunc(obj any) ([]string, error) {
|
||||
@@ -776,7 +779,7 @@ func podModified(oldObj, newObj any) bool {
|
||||
if !okOld || !okNew {
|
||||
return true
|
||||
}
|
||||
return oldPod.PodIP != newPod.PodIP
|
||||
return !slices.Equal(oldPod.PodIPs, newPod.PodIPs)
|
||||
}
|
||||
|
||||
// endpointsEquivalent checks if the update to an endpoint is something
|
||||
|
||||
Reference in New Issue
Block a user