4 min read
Taming DNS at Scale
Our Journey from Imperative Ansible to Declarative ExternalDNS in OpenShift
If you manage infrastructure at any meaningful scale, you already know the old engineering adage: It’s always DNS. In our environment of over 400 OpenShift clusters, DNS management had become a critical bottleneck. As our platform evolved toward a modern, hosted control planes architecture using OpenShift HyperShift, our legacy approach to DNS provisioning was holding us back. Here is the story of how we retrofitted our architecture, abandoned our imperative Ansible pipelines, and embraced a fully declarative DNS lifecycle using ExternalDNS—without having to deploy new agents to 400+ individual workload clusters.
The Problem with Imperative Infrastructure
Previously, our cluster provisioning pipeline relied heavily on Ansible. When a new OpenShift cluster was requested, the cluster creation process triggered an Ansible playbook that hit an internal microservice endpoint to provision the necessary DNS records. On paper, this worked. In practice, the imperative nature of this design introduced significant operational friction. Because the DNS lifecycle was tightly bound to a point-in-time Ansible run, we lacked a continuous reconciliation loop. If a network timeout occurred, the microservice failed, or the pipeline was interrupted, the cluster would provision, but the DNS would not. The reverse was equally problematic: cluster deletion failures would frequently leave orphaned DNS records floating in our environment. We had built a system where cluster state and DNS state were entirely decoupled, relying on an external pipeline to keep them in sync. It was a fundamental design flaw. We needed DNS to behave like the rest of Kubernetes: declarative, self-healing, and lifecycle-aware.
The Declarative Vision (and the 400-Cluster Roadblock)
Our goal was clear. We wanted DNS provisioning to match the declarative lifecycle management of the clusters themselves. Since we utilize the OpenShift HyperShift approach—where hosted control planes run as pods on a centralized management cluster—we wanted our DNS strategy to seamlessly integrate with that model. The obvious tool for the job was ExternalDNS. It is the cloud-native standard for dynamically configuring DNS providers based on Kubernetes resources. However, we immediately hit a massive logistical roadblock. We had over 400 existing workload clusters. The standard implementation pattern for ExternalDNS is to install it as an agent on every single cluster. Retrofitting 400+ live environments with new deployments, managing their RBAC permissions, and maintaining their lifecycles was an operational nightmare we wanted to avoid.
The Architectural Pivot: Leveraging the Management Cluster
We realized we were thinking about the problem the wrong way. Because we were using HyperShift, the control plane components for all 400+ workload clusters were already colocated on our management clusters. We didn’t need to touch the workload clusters at all. Instead of deploying ExternalDNS to the hosted clusters, we deployed a single instance of ExternalDNS on each management cluster. By utilizing the Multi-Cluster Engine (MCE) controller within OpenShift, we configured the centralized ExternalDNS instance to watch the namespaces hosting the control planes. Here is how it transformed our workflow:
• Centralized Observation: The management-level ExternalDNS instance monitors the services and endpoints running within the control plane namespaces of the hosted clusters. • The DNSEndpoint Custom Resource: We heavily leveraged the DNSEndpoint CR. Instead of ExternalDNS scraping every ingress or route on the guest clusters, the cluster provisioning process simply creates a DNSEndpoint resource on the management cluster. ExternalDNS sees this and handles the provider-level implementation. • Unified Lifecycle: Because the DNSEndpoint lives alongside the hosted control plane resources, it shares the exact same lifecycle. When the cluster is created, the CR is created, and DNS is provisioned. When the cluster is deleted, the namespace is wiped, the CR is destroyed, and ExternalDNS automatically cleans up the records.
What This Meant for Our Platform
Moving the DNS controller to the management cluster fundamentally changed our operational posture. First, it completely eliminated the dreaded “orphaned record” problem. The continuous reconciliation loop of ExternalDNS ensures that our DNS provider always perfectly reflects the actual state of our infrastructure. If a cluster doesn’t exist, its DNS doesn’t exist. Second, it drastically simplified our provisioning pipeline. We were able to strip out the brittle, imperative Ansible steps and retire the dedicated DNS microservice. Cluster creation is now a single, declarative action applied to the management cluster. Finally, it gave us a scalable pattern for the future. As we scale to 500 or 1,000 clusters, we don’t have to worry about deploying and upgrading ExternalDNS on a thousand endpoints. The management cluster handles the translation natively, keeping our workload clusters lean and focused entirely on running application workloads.
Moving from imperative scripts to declarative systems is rarely easy when dealing with legacy technical debt, but by leaning into the architecture of hosted control planes, we turned a massive retrofitting headache into an elegant, centralized solution.