plugin/kubernetes: Add support for topology-aware headless services via "az-pinned" subdomains (#8388)

This commit is contained in:
rpb-ant
2026-08-10 16:24:50 -04:00
committed by GitHub
parent b2ef1a13e8
commit c2ca1b2c23
10 changed files with 624 additions and 39 deletions

View File

@@ -829,3 +829,59 @@ func TestBoundIPs(t *testing.T) {
})
}
}
func TestKubernetesParseZonal(t *testing.T) {
tests := []struct {
input string
shouldErr bool
expectedZonal bool
}{
{
`kubernetes coredns.local {
zonal
}`,
false,
true,
},
{
`kubernetes coredns.local {
zonal us-west-2a
}`,
true,
false,
},
{
`kubernetes coredns.local {
zonal
noendpoints
}`,
true,
false,
},
{
`kubernetes coredns.local {
}`,
false,
false,
},
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.input)
k8sController, err := kubernetesParse(c)
if test.shouldErr {
if err == nil {
t.Errorf("Test %d: Expected error, got none for input '%s'", i, test.input)
}
continue
}
if err != nil {
t.Errorf("Test %d: Expected no error, got '%v' for input '%s'", i, err, test.input)
continue
}
if k8sController.opts.zonal != test.expectedZonal {
t.Errorf("Test %d: Expected zonal=%v, got %v", i, test.expectedZonal, k8sController.opts.zonal)
}
}
}