mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
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:
committed by
GitHub
parent
76b199f829
commit
5c71bd0b87
64
plugin/kubernetes/object/multicluster_endpoint.go
Normal file
64
plugin/kubernetes/object/multicluster_endpoint.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package object
|
||||
|
||||
import (
|
||||
"maps"
|
||||
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
mcs "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
|
||||
)
|
||||
|
||||
// Endpoints is a stripped down api.Endpoints with only the items we need for CoreDNS.
|
||||
type MultiClusterEndpoints struct {
|
||||
Endpoints
|
||||
ClusterId string
|
||||
*Empty
|
||||
}
|
||||
|
||||
// MultiClusterEndpointsKey returns a string using for the index.
|
||||
func MultiClusterEndpointsKey(name, namespace string) string { return name + "." + namespace }
|
||||
|
||||
// EndpointSliceToEndpoints converts a *discovery.EndpointSlice to a *Endpoints.
|
||||
func EndpointSliceToMultiClusterEndpoints(obj meta.Object) (meta.Object, error) {
|
||||
labels := maps.Clone(obj.GetLabels())
|
||||
ends, err := EndpointSliceToEndpoints(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
e := &MultiClusterEndpoints{
|
||||
Endpoints: *ends.(*Endpoints),
|
||||
ClusterId: labels[mcs.LabelSourceCluster],
|
||||
}
|
||||
e.Index = MultiClusterEndpointsKey(labels[mcs.LabelServiceName], ends.GetNamespace())
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
var _ runtime.Object = &Endpoints{}
|
||||
|
||||
// DeepCopyObject implements the ObjectKind interface.
|
||||
func (e *MultiClusterEndpoints) DeepCopyObject() runtime.Object {
|
||||
e1 := &MultiClusterEndpoints{
|
||||
ClusterId: e.ClusterId,
|
||||
Endpoints: *e.Endpoints.DeepCopyObject().(*Endpoints),
|
||||
}
|
||||
return e1
|
||||
}
|
||||
|
||||
// GetNamespace implements the metav1.Object interface.
|
||||
func (e *MultiClusterEndpoints) GetNamespace() string { return e.Endpoints.GetNamespace() }
|
||||
|
||||
// SetNamespace implements the metav1.Object interface.
|
||||
func (e *MultiClusterEndpoints) SetNamespace(namespace string) {}
|
||||
|
||||
// GetName implements the metav1.Object interface.
|
||||
func (e *MultiClusterEndpoints) GetName() string { return e.Endpoints.GetName() }
|
||||
|
||||
// SetName implements the metav1.Object interface.
|
||||
func (e *MultiClusterEndpoints) SetName(name string) {}
|
||||
|
||||
// GetResourceVersion implements the metav1.Object interface.
|
||||
func (e *MultiClusterEndpoints) GetResourceVersion() string { return e.Endpoints.GetResourceVersion() }
|
||||
|
||||
// SetResourceVersion implements the metav1.Object interface.
|
||||
func (e *MultiClusterEndpoints) SetResourceVersion(version string) {}
|
||||
Reference in New Issue
Block a user