Search code examples
kubernetesdnskubernetes-helmlinode

How do I configure external-dns to create A Record, not CNAME


I am following Linode's tutorials on using helm to deploy to Linode Kubernetes Engine (LKE) and I have reached the section on configuring external DNS which uses bitnami's external-dns package to configure a domain on Linode's DNS servers.

When I try to annotate my service, using exactly the same command as in the video, it results in a CNAME alias and no A/TXT Records.

The logs from the external-dns show

time="2022-01-01T14:45:10Z" level=info msg="Creating record." action=Create record=juicy type=CNAME zoneID=1770931 zoneName=mydomain.com

time="2022-01-01T14:45:11Z" level=info msg="Creating record." action=Create > record=juicy type=TXT zoneID=1770931 zoneName=mydomain.com

time="2022-01-01T14:45:11Z" level=error msg="Failed to Create record: [400] [name] Record conflict - CNAMES must be unique" action=Create record=juicy type=TXT zoneID=1770931 zoneName=mydomain.com

These logs imply that external-dns is first creating a CNAME record (which isn't required/wanted at all) and then attempting to create a TXT record which uses the same hostname as the newly-created CNAME, which obviously isn't allowed. And it is clearly not attempting to create the A Record at all.

I would really appreciate any info about why this might be happening and what I can do to correct it. For clarity, the desired result is one A Record and one TXT Record, both with the hostname 'juicy'


Solution

  • It appears this is due to external-dns applying some logic which detects if the target is an Elastic Load Balancer.

    After creating the CNAME alias, external-dns is then trying to create a TXT Record with the same hostname, which is failing because this is not allowed. To get around this, external-dns provides a --txt-prefix flag which allows you to prefix the TXT hostname with a string, thus making it different from the newly-created CNAME record.

    Arguably, external-dns does not need to switch from A Record to CNAME in this instance because Linode's Load Balancers have IP addresses, not domain names. An issue has been raised on GitHub.

    If you're following Linode's excellent tutorial and/or you're installing external-dns with helm, the --txt-prefix flag needs to be set at installation:

    helm install external-dns bitnami/external-dns \                                                                                                                               
      --namespace external-dns --create-namespace \
      --set provider=linode \
      --set linode.apiToken=$LINODE_API_TOKEN \
    --set txtPrefix=your-prefix-string
    

    (namespace and other values are included to match the Linode tutorials) The rest of the tutorial can then be followed as is.