Onboard a Service
Introduction
Advertising services to your DNS provider with ExternalDNS is as easy as adding an annotation for the hostname you wish to assign. This document will describe exposing a service to ExternalDNS.
Create an Annotation
Create a YAML configuration filed using the following template, which has annotations
added under metadata to begin advertising the service with ExternalDNS.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-ns1
annotations:
external-dns.alpha.kubernetes.io/hostname: subdomain.domain.tld # Required
external-dns.alpha.kubernetes.io/ttl: "120" # Optional: In Seconds
spec:
selector:
app: nginx
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 80
Add Annotations in a Deployed Ingress YAML File
If you already have an ingress deployed on your cluster, then use the following command to edit the YAML file.
kubectl edit service <service-name>
In the YAML file, under metadata, add the following annotations under the service API:
metadata:
name: nginx-ns1
annotations:
external-dns.alpha.kubernetes.io/hostname: subdomain.domain.tld # Required
external-dns.alpha.kubernetes.io/ttl: "120" # Optional: In Seconds
Verify the Record Creation
As ExternalDNS checks for record changes to be created, updated, or deleted every 60 seconds,
give a minute or two for your changes to propagate. You can also view the logs of the
external-dns pod to see your DNS records change in real time.
After sufficient time has passed, either check the user interface of the DNS provider or
use dig, nslookup, or another similar DNS lookup tool to confirm changes are
published.