This context provides a guide on how to automatically create DNS records in Kubernetes using External DNS.
Abstract
The context discusses the challenges of managing DNS records in Kubernetes, especially when dealing with numerous projects and thousands of DNS records. It introduces ExternalDNS as a solution to this problem, which allows for the dynamic control of DNS records via Kubernetes resources in a DNS provider-agnostic way. The guide then outlines the steps to create a GKE cluster, deploy ExternalDNS to the cluster, deploy a sample web application, and automate the creation of DNS records in Google Cloud DNS using External DNS. The prerequisites for this process include a Google Cloud Account and a GitHub Account (optional). The guide also provides code snippets and screenshots to assist with the process.
Bullet points
ExternalDNS allows for the dynamic control of DNS records via Kubernetes resources in a DNS provider-agnostic way.
ExternalDNS synchronizes exposed Kubernetes Services and Ingresses with DNS providers.
ExternalDNS supports multiple DNS providers, including Google Cloud DNS, AWS Route53, Azure DNS, and Digital Ocean.
The guide outlines the steps to create a GKE cluster, deploy ExternalDNS to the cluster, deploy a sample web application, and automate the creation of DNS records in Google Cloud DNS using External DNS.
The prerequisites for this process include a Google Cloud Account and a GitHub Account (optional).
The guide provides code snippets and screenshots to assist with the process.
Introduction to External DNS in Kubernetes
How to automatically create DNS records in Kubernetes using External DNS
Are you running your workloads in GKE / EKS / AKS? Do you use Services of type LoadBalancer? If yes then this is the right article for you. Let us suppose you have a web application running in your Kubernetes Cluster. You might have a public-facing load balancer so that your application is accessible to the entire world. Imagine you have a domain name called kubernetesisgreat.com and you want to map that to your public-facing load balancer provisioned by Kubernetes. For this, you can either use a gcloud command or maybe do it manually. Now, what if you have hundreds of projects and thousands of DNS records to be created? What if the LoadBalancer Endpoint changes? How do you keep a track of hundreds of thousands of DNS records? Here come external-dns to the picture. ExternalDNS allows you to control DNS records dynamically via Kubernetes resources in a DNS provider-agnostic way. ExternalDNS synchronizes exposed Kubernetes Services and Ingresses with DNS providers. ExternalDNS supports multiple DNS providers. A few of them are
Google Cloud DNS
AWS Route53
Azure DNS
Digital Ocean, etc.
ExternalDNS
What is the entire story all about? (TLDR)
Create a GKE cluster.
Deploy ExternalDNS to our GKE Cluster.
Deploy a sample Web-Application.
Automate the creation of DNS records in Google Cloud DNS using External DNS.
Prerequisites
Google Cloud Account ( You can get a Free tier Account with $300 ).
GitHub Account ( Optional ).
Creating a GKE Cluster
In the scope of this article, we will use Terraform to create the cluster. We can automate the process of creating the GKE cluster using Github actions. You can refer to my article on how to create a GKE cluster using GitHub Actions. You can also clone my GitHub repository to apply it from your cloud shell machine. Or the cluster can be simply created using the gcloud CLI.
You can follow the steps here to register a new Domain or Either Import your existing domain to the GCP and then create a Managed Public Zone. You can alternatively use freenom to get a free domain for yourself and create a Public zone in your GCP account.
Once the aforementioned steps are completed let us now deploy external-dns to our cluster.
Before you deploy you might have to change the name of the domain in the domain-filter section ( line 56 ). In my case, the name of my domain is bettercallpavan.tk ( You can also get a free domain using freenom.com ). Let us now deploy the external dns manifests to our cluster
Automate the creation of DNS records in Google Cloud DNS using External DNS.
Let us now check the logs of the external DNS pod. You can see that the records are already being created. Let us also verify the same from the Google Cloud Console.
The entries for my LoadBalancer are created in the GCP console.