From 264fdb756db851bea4b33704fd545ada3232b336 Mon Sep 17 00:00:00 2001 From: superflo22 Date: Fri, 11 Apr 2025 18:02:57 +0200 Subject: [PATCH] Create first record --- internal/controller/externaldnswatcher_controller.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/controller/externaldnswatcher_controller.go b/internal/controller/externaldnswatcher_controller.go index 0d48df3..52e7514 100644 --- a/internal/controller/externaldnswatcher_controller.go +++ b/internal/controller/externaldnswatcher_controller.go @@ -23,6 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/handler" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" + "strings" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -61,6 +62,7 @@ func (r *ExternalDNSWatcherReconciler) Reconcile(ctx context.Context, req ctrl.R // Step 2: Check annotation annotations := gateway.GetAnnotations() if annotations["dns.mayers.cloud/enabled"] != "true" { + log.Info("ExternalDNS watcher is not enabled") return ctrl.Result{}, nil } @@ -93,8 +95,12 @@ func (r *ExternalDNSWatcherReconciler) Reconcile(ctx context.Context, req ctrl.R // Step 5: Collect hostnames for _, hostname := range route.Spec.Hostnames { record := &dnsv1alpha1.TechnitiumRecord{ + TypeMeta: metav1.TypeMeta{ + Kind: "TechnitiumRecord", + APIVersion: "dns.mayers.cloud/v1alpha1", + }, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-%s", route.Name, string(hostname)), + Name: fmt.Sprintf("%s", strings.ReplaceAll(string(hostname), ".", "-")), Namespace: route.Namespace, }, Spec: dnsv1alpha1.TechnitiumRecordSpec{ @@ -109,6 +115,8 @@ func (r *ExternalDNSWatcherReconciler) Reconcile(ctx context.Context, req ctrl.R }, }, } + // Log the record yaml + log.Info("TechnitiumRecord", "record", record) if err := r.Client.Patch(ctx, record, client.Apply, client.ForceOwnership, client.FieldOwner("external-dns-watcher")); err != nil { log.Error(err, "Failed to apply TechnitiumRecord")