monkale-io / coredns-manager-operator

With the CoreDNS Manager Operator, you can handle internal DNS directly within your Kubernetes cluster, simplifying the process and reducing infrastructure needs.
Apache License 2.0
32 stars 1 forks source link

[BUG] - Low priority - DNSZone - complex first NS hostname #7

Closed nikolay-udovik closed 5 months ago

nikolay-udovik commented 5 months ago

Bug Report

Description

Kubebuilder validation restricts the spec.primaryNS.hostname field to a simpler hostname format, preventing the creation of more complex hostnames required for certain DNS setups.

Steps to Reproduce

Please provide detailed steps to reproduce the issue:

  1. Create a DNSZone resource with a complex hostname.
    cat << EOF | kubectl apply -f -
    ---
    apiVersion: monkale.monkale.io/v1alpha1
    kind: DNSZone
    metadata:
     name: bubble-lab
     namespace: kube-system
    spec:
     connectorName: coredns
     domain: "bubble.lab"
     primaryNS:
       hostname: master-0.k3s
       ipAddress: "192.168.122.21"
     respPersonEmail: "monkaleio@gmail.com"
    EOF
  2. Error
    The DNSZone "bubble-lab" is invalid: spec.primaryNS.hostname: Invalid value: "master-0.k3s": spec.primaryNS.hostname in body should match '^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$'

Expected Behavior

The system should allow complex hostnames such as master-0.k3s for the primaryNS.hostname field to enable more detailed DNS configurations.

Actual Behavior

The current validation rules restrict the hostname format, resulting in an error when trying to apply more complex hostnames.

Environment

All environments where the CoreDNS Manager Operator is deployed.

Additional Context

The validation rules enforced by Kubebuilder do not permit the creation of more complex hostnames. For instance, the requirement is to create an NS record pointing to master-0.k3s.example.com and subsequently create an A record for it.

Example

<lab>root@core-k3s-lb-0:~# cat << EOF | kubectl apply -f -
> ---
apiVersion: monkale.monkale.io/v1alpha1
kind: DNSZone
metadata:
  name: bubble-lab
  namespace: kube-system
spec:
  connectorName: coredns
  domain: "bubble.lab"
  primaryNS:
    hostname: master-0.k3s
    ipAddress: "192.168.122.21"
  respPersonEmail: "monkaleio@gmail.com"
> EOF
The DNSZone "bubble-lab" is invalid: spec.primaryNS.hostname: Invalid value: "master-0.k3s": spec.primaryNS.hostname in body should match '^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$'
<lab>root@core-k3s-lb-0:~# cat << EOF | kubectl apply -f -
> ---
apiVersion: monkale.monkale.io/v1alpha1
kind: DNSZone
metadata:
  name: bubble-lab
  namespace: kube-system
spec:
  connectorName: coredns
  domain: "bubble.lab"
  primaryNS:
    hostname: master-0
    ipAddress: "192.168.122.21"
  respPersonEmail: "monkaleio@gmail.com"
> EOF
dnszone.monkale.monkale.io/bubble-lab configured

The Kubebuilder validation prevents the use of more complex hostnames. The objective is to create an NS record pointing to master-0.k3s.example.com and then create an A record for it.


monkale-io commented 5 months ago

Resolved in 1.0.3