diff --git a/pkg/maas/dns/dns.go b/pkg/maas/dns/dns.go index 2d2c0cd..2622512 100644 --- a/pkg/maas/dns/dns.go +++ b/pkg/maas/dns/dns.go @@ -5,6 +5,7 @@ import ( "github.com/pkg/errors" infrainfrav1beta1 "github.com/spectrocloud/cluster-api-provider-maas/api/v1beta1" "github.com/spectrocloud/cluster-api-provider-maas/pkg/maas/scope" + util2 "github.com/spectrocloud/cluster-api-provider-maas/pkg/util" "github.com/spectrocloud/maas-client-go/maasclient" "k8s.io/apimachinery/pkg/util/sets" ) @@ -27,6 +28,13 @@ func NewService(clusterScope *scope.ClusterScope) *Service { // ReconcileDNS reconciles the load balancers for the given cluster. func (s *Service) ReconcileDNS() error { s.scope.V(2).Info("Reconciling DNS") + + if util2.IsCustomEndpointPresent(s.scope.MaasCluster.GetAnnotations()) { + s.scope.GetDNSName() + s.scope.V(0).Info("custom dns is provided skipping dns reconcile", "dns", s.scope.GetDNSName()) + return nil + } + ctx := context.TODO() dnsResource, err := s.GetDNSResource() diff --git a/pkg/maas/scope/cluster.go b/pkg/maas/scope/cluster.go index bd2a875..e48d6b6 100644 --- a/pkg/maas/scope/cluster.go +++ b/pkg/maas/scope/cluster.go @@ -23,6 +23,7 @@ import ( "github.com/google/uuid" "github.com/pkg/errors" infrav1beta1 "github.com/spectrocloud/cluster-api-provider-maas/api/v1beta1" + infrautil "github.com/spectrocloud/cluster-api-provider-maas/pkg/util" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -132,6 +133,11 @@ func (s *ClusterScope) SetDNSName(dnsName string) { // GetDNSName sets the Network systemID in spec. // This can't do a lookup on Status.Network.DNSDomain name since it's derviced from here func (s *ClusterScope) GetDNSName() string { + if infrautil.IsCustomEndpointPresent(s.MaasCluster.GetAnnotations()) { + s.SetDNSName(s.MaasCluster.Spec.ControlPlaneEndpoint.Host) + return s.MaasCluster.Spec.ControlPlaneEndpoint.Host + } + if !s.Cluster.Spec.ControlPlaneEndpoint.IsZero() { return s.Cluster.Spec.ControlPlaneEndpoint.Host } diff --git a/pkg/util/cluster.go b/pkg/util/cluster.go new file mode 100644 index 0000000..18c3ff8 --- /dev/null +++ b/pkg/util/cluster.go @@ -0,0 +1,10 @@ +package util + +const ( + CustomEndpointProvidedAnnotation = "spectrocloud.com/custom-dns-provided" +) + +func IsCustomEndpointPresent(annotations map[string]string) bool { + _, ok := annotations[CustomEndpointProvidedAnnotation] + return ok +}