Automatically Manage DNS Records for Your Microservices in Amazon EKS with ExternalDNS
Configure Amazon Route53 as a DNS provider for external access to microservices.

About | |
---|---|
✅ AWS experience | 200 - Intermediate |
⏱ Time to complete | 30 minutes |
🧩 Prerequisites | - AWS Account |
📢 Feedback | Any feedback, issues, or just a 👍 / 👎 ? |
⏰ Last Updated | 2023-10-03 |
- Install the latest version of kubectl. To check your version, run:
kubectl version --short
. - Install the latest version of eksctl. To check your version, run:
eksctl info
. - Install the latest version of Helm. To check your version, run:
helm version
. - Install the latest version of AWS CLI. To check your version, run:
aws --version
.
- Authentication: Utilize the IAM Role for Service Account (IRSA) for the ExternalDNS add-on with the OpenID Connect (OIDC) endpoint to ensure secure communication between Kubernetes pods and AWS services.
- Route53 Hosted Zone Creation: Create a private hosted zone that will hold the DNS records of the Kubernetes service. This hosted zone will serve as a container for all the DNS records related to your Kubernetes service.
- ExternalDNS Add-on Setup: Deploy the ExternalDNS add-on on your Amazon EKS cluster and configure it to synchronize Kubernetes service DNS records with your Route53 domain.
- Sample Application Deployment: As a practical example, we'll walk you through the steps to build and expose the "2048 Game Sample Application" on port 80. To facilitate this, we'll utilize custom annotations for ExternalDNS, particularly the 'hostname' annotation, which instructs the ExternalDNS controller on how to access the Kubernetes service via the specified HTTP path. For more annotations, see Setting up ExternalDNS for Services on AWS.
Note that even if you're still within your initial 12-month AWS Free Tier period, the Route 53 hosted zone falls outside the AWS free tier. Hence, usage could result in additional charges.
The ExternalDNS add-on is self-managed, and customers are responsible for overseeing its lifecycle and maintenance.
- First, confirm that you are operating within the correct cluster context. This ensures that any subsequent commands are sent to the intended Kubernetes cluster. You can verify the current context by executing the following command:
- Define the
CLUSTER_ACCOUNT
environment variable to store your AWS account ID.
- Define the
CLUSTER_NAME
environment variable for your EKS cluster.
- Define the
CLUSTER_REGION
environment variable for your EKS cluster.
- Define the
CLUSTER_VPC
environment variable for your EKS cluster.
- Define the
AWS_ROUTE53_DOMAIN
environment variable to store your Route 53 domain name.
- Create a new hosted zone in AWS Route 53.
- Retrieve the ID of the hosted zone you created in AWS Route 53.
- Verify that the Route53 hosted zone was created successfully.
- Configure IAM permissions to allow ExternalDNS pods to manage Route 53 records in your AWS account.
- Create the policy to grant the necessary permissions for ExternalDNS to interact with Route 53.
- Use the policy to create an IAM role for the service account. This service account will be used by ExternalDNS pods to manage records in the Route53 hosted zone.
my-externaldns-demo.com
hosted zone. This configuration enables the ExternalDNS add-on to automate the management of DNS records for services running in your Kubernetes cluster, ensuring that these services can be accessed using domain names. To learn more, see ExternalDNS parameters.- Update the kubeconfig file to set the context to the current EKS cluster.
- Run the following Helm command to install the ExternalDNS add-on on your EKS cluster. This command will configure the ExternalDNS add-on to manage DNS records for your specified domain.
- Define the
SUB_DOMAIN
environment variable.
- Create the Namespace, Deployment and Service with an ExternalDNS annotation. To learn more about these components, refer to the following resources: Deployments, Services, Load Balancing, and Networking, and ExternalDNS .
- Create the Kubernetes resources by applying the configuration file to the Kubernetes API server.
- You can verify the logs using the following command. Please note that it may take a few seconds to update the entries.
- You can verify the newly created DNS records, which point to the
game-2048
service within the private hosted zone, by running the following command:
- Since the hosted domain is private, you can access the service
game-2048
using the user-friendly URLgame-2048.my-externaldns-demo.com
from within the pods. We will be creating a test pod and running a curl command to verify the setup.
- Double click the
test.html
file that was created by the previous command. You should see the following contents.

HOSTED_ZONE_ID
and AWS_ROUTE53_DOMAIN
, and the steps for domain registration. You've also delved into the specifics of URL navigation for external clients.HOSTED_ZONE_ID
& AWS_ROUTE53_DOMAIN
variable with your registered domain, then revisit the steps in this guide. By doing so, you'll be able to access the service directly from a browser by navigating to <SUB_DOMAIN>.<AWS_ROUTE53_DOMAIN>
. This final setup ensures a comprehensive, fully operational environment, poised for both internal and external service accessibility.Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.