kubernetes: add multicluster support (#7266)

* kubernetes: add multicluster support

Add multicluster support via Multi-Cluster Services API (MCS-API) via a
new option `multiclusterZones` in the kubernetes plugin.

When some multicluster zones are passed to the kubernetes plugin, it
will start watching the ServiceImport objects and its associated
EndpointSlices.

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* kubernetes: implement xfr support for multicluster zones

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

---------

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
This commit is contained in:
Arthur Outhenin-Chalandre
2025-05-19 07:58:16 +02:00
committed by GitHub
parent 76b199f829
commit 5c71bd0b87
23 changed files with 1634 additions and 298 deletions

View File

@@ -32,8 +32,12 @@ func (k *Kubernetes) Metadata(ctx context.Context, state request.Request) contex
if zone == "" {
return ctx
}
multicluster := false
if z := plugin.Zones(k.opts.multiclusterZones).Matches(state.Zone); z != "" {
multicluster = true
}
// possible optimization: cache r so it doesn't need to be calculated again in ServeDNS
r, err := parseRequest(state.Name(), zone)
r, err := parseRequest(state.Name(), zone, multicluster)
if err != nil {
metadata.SetValueFunc(ctx, "kubernetes/parse-error", func() string {
return err.Error()
@@ -53,6 +57,12 @@ func (k *Kubernetes) Metadata(ctx context.Context, state request.Request) contex
return r.endpoint
})
if multicluster {
metadata.SetValueFunc(ctx, "kubernetes/cluster", func() string {
return r.cluster
})
}
metadata.SetValueFunc(ctx, "kubernetes/service", func() string {
return r.service
})