Sign In
Sign In

ExternalDNS

Updated on 27 March 2025

ExternalDNS is a tool for automatically managing DNS records based on Kubernetes resources. It updates DNS records according to annotations specified in service and ingress manifests. ExternalDNS simplifies domain name management for services in a Kubernetes cluster, eliminating the need to manually modify records in the DNS control panel.

Installation

To install ExternalDNS:

  1. Go to the Kubernetes section and click on the cluster.
  2. Navigate to the Addons tab.
  3. Click on the three dots next to ExternalDNS and click Install.

After installation, wait for the cluster update and verify that the ExternalDNS resources are in the Running state:

kubectl get pods -n external-dns

Using ExternalDNS

Before using ExternalDNS, you must manually create domains in the control panel so that ExternalDNS can manage their records.

Using Annotations in Ingress

ExternalDNS manages DNS records based on annotations in manifests. For example, to associate a domain name with an Ingress resource, you can use the following manifest:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  namespace: ingress-example
  annotations:
    external-dns.alpha.kubernetes.io/hostname: "app.example.com"
    external-dns.alpha.kubernetes.io/ttl: "1200"
spec:
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-app
            port:
              number: 80

Annotation descriptions:

  • external-dns.alpha.kubernetes.io/hostname — Specifies the domain name to be associated with this resource.
  • external-dns.alpha.kubernetes.io/ttl — Sets the DNS record's TTL in seconds.

This method is suitable if the Ingress controller is deployed on all nodes. However, it has some drawbacks:

  • If the Ingress controller does not run on all nodes, some traffic may be sent to unavailable IP addresses.
  • Kubernetes may move pods to other nodes, changing IP addresses and causing service downtime.
  • DNS load balancing does not consider node availability, which can lead to traffic loss.

Using LoadBalancer (Recommended)

One of the most efficient ways to use ExternalDNS is in combination with a load balancer. In this case, the service gets a fixed external IP address and distributes traffic among the pods. ExternalDNS automatically creates a DNS record with this IP address.

Example manifest:

apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  annotations:
    external-dns.alpha.kubernetes.io/hostname: "app.example.com"
    external-dns.alpha.kubernetes.io/ttl: "1200"
spec:
  selector:
    app.kubernetes.io/name: ingress-nginx
  ports:
    - name: http
      port: 80
      targetPort: 80
    - name: https
      port: 443
      targetPort: 443
  type: LoadBalancer

In this example, the load balancer directs traffic to pods labeled app.kubernetes.io/name: ingress-nginx, where the Ingress controller runs.

Using ExternalDNS with a load balancer simplifies DNS management. Instead of tracking IP changes across different nodes, you only need to associate the domain name with a single fixed IP. This reduces the risk of downtime due to node changes, and load balancing between pods ensures service stability. If the cluster configuration changes, ExternalDNS automatically updates the DNS record, eliminating the need for manual intervention.

Was this page helpful?
Updated on 27 March 2025

Do you have questions,
comments, or concerns?

Our professionals are available to assist you at any moment,
whether you need help or are just unsure of where to start.
Email us
Hostman's Support