Introduction
Managing DNS records manually in Kubernetes can be time-consuming and error-prone. As services scale and change dynamically, updating DNS records manually becomes inefficient. ExternalDNS automates DNS record management by dynamically syncing records with Kubernetes objects.
In this blog, we will cover:
What is ExternalDNS?
How it works with Kubernetes
Steps to deploy and configure it
Best practices for seamless automation
What is ExternalDNS?
ExternalDNS is a Kubernetes add-on that automatically manages DNS records for services and ingress resources. It eliminates manual updates by dynamically syncing DNS records with Kubernetes objects.
Key Benefits:
- Automated DNS Updates – No manual intervention required.
- Multi-Cloud Support – Works with AWS Route 53, Cloudflare, Google Cloud DNS, etc.
- Scalability – Adapts to dynamic changes in Kubernetes services.
- Improved Reliability – Reduces misconfiguration and ensures consistency.
Deploying ExternalDNS in Kubernetes
Install ExternalDNS using Helm
helm repo add external-dns https://kubernetes-sigs.github.io/external-dns/
helm repo update
For AWS Route 53:
helm install external-dns external-dns/external-dns \
--namespace kube-system \
--set provider=aws \
--set txtOwnerId="my-cluster"
For Cloudflare:
helm install external-dns external-dns/external-dns \
--namespace kube-system \
--set provider=cloudflare \
--set cloudflare.apiToken="YOUR_CLOUDFLARE_API_TOKEN" \
--set txtOwnerId="my-cluster"
Verify Installation
kubectl get pods -n kube-system -l app.kubernetes.io/name=external-dns
Configuring ExternalDNS for Kubernetes Services
Service Example (LoadBalancer Type)
apiVersion: v1
kind: Service
metadata:
name: my-app
annotations:
external-dns.alpha.kubernetes.io/hostname: myapp.example.com
spec:
type: LoadBalancer
selector:
app: my-app
ports:
- port: 80
targetPort: 8080
Apply the service:
kubectl apply -f service.yaml
Configuring ExternalDNS for Ingress Resources
Ingress Example
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ingress
annotations:
external-dns.alpha.kubernetes.io/hostname: myapp.example.com
spec:
rules:
- host: myapp.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
Apply the Ingress resource:
kubectl apply -f ingress.yaml
Verifying DNS Records
Check ExternalDNS Logs
kubectl logs -l app.kubernetes.io/name=external-dns -n kube-system
Validate DNS Resolution
dig myapp.example.com
Expected output should contain the correct A record pointing to your service.
Conclusion
ExternalDNS simplifies DNS management in Kubernetes by automating record updates, reducing manual errors, and ensuring service availability.
Key Takeaways:
Automates DNS record creation and updates
Works with multiple cloud DNS providers
Integrates seamlessly with Kubernetes services and ingress
By integrating ExternalDNS, Kubernetes administrators can enhance scalability, automation, and reliability in their infrastructure.
Have you used ExternalDNS in your Kubernetes setup? Share your experience!