Create first record
This commit is contained in:
parent
fda3120bd3
commit
264fdb756d
1 changed files with 9 additions and 1 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue