Onboard a Headless Service
Introduction
Advertising headless services to your DNS provider with ExternalDNS is as easy as adding an annotation for the hostname you want to assign. This topic describes exposing a headless 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 headless service with ExternalDNS.
apiVersion: v1
kind: Service
metadata:
name: headless-test
annotations:
external-dns.alpha.kubernetes.io/hostname: subdomain.domain.tld # Required
external-dns.alpha.kubernetes.io/ttl: "120" # Optional: In Seconds
spec:
clusterIP: None
ports:
- port: 80
targetPort: 8080
selector:
app: headless-test
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:
metadata:
name: <already existing headless service name>
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.