Skip to content

Troubleshooting ExternalDNS in Kubernetes: Nodes with Internal IPs

Published: at 12:00 AM
External DNS

ExternalDNS is an open-source addon for Kubernetes that automates the configuration of DNS records for ingresses. It simplifies the process by observing Kubernetes resources and updating DNS records through cloud provider APIs accordingly.

If you’re delving into Infrastructure as Code (IaC), with ExternalDNS, you can take your it to the next level. By effortlessly integrating DNS record management into your Helm charts or Kubernetes config files from Git sources, you can sync up your infrastructure and DNS configurations with ease, making deployments a breeze.

ExternalDNS eliminates the need to handle external DNS records manually, saving you time and effort. Without it, managing DNS records would involve logging into a DNS provider management dashboard like Cloudflare and manually configuring each domain and subdomain.

In my own experience with a Kubernetes infrastructure, I encountered an issue related to the internal IP addresses of Kubernetes nodes. When defining a domain by adding an ingress config, ExternalDNS placed DNS records incorrectly, pointing them to our internal IPs. After some research, I discovered a simple solution provided by the ExternalDNS team: adding an annotation called external-dns.alpha.kubernetes.io/target to the ingress configs. Here’s an example of how to do it:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    kubernetes.io/ingress.class: haproxy
    external-dns.alpha.kubernetes.io/target: 3.4.5.6 # Replace with a desired IP address
spec:
  rules:
    - host: example-subdomain.example-domain.com
      http: paths:
        - paths: /
          pathType: Prefix
          backend:
            service:
              name: example-service
              port:
                number: 4444

This annotation ensures that the DNS records are correctly pointed to the specified IP address, resolving the issue with internal IPs. For more information, you can refer to the ExternalDNS documentation here.