It is possible to configure CoreDNS to mapping one domain to another domain by adding rewrite rule.
Suppose you have domain example.com and you want that domain to point to google.com domain.
To do this in CoreDNS, you can use the rewrite plugin.
Configuration of CoreDNS is stored in coredns ConfigMap in kube-system namespace.
You can edit it using:
root@kmaster:~# kubectl edit cm coredns -n kube-system
Just add one rewrite rule, like in the example below:
apiVersion: v1
data:
Corefile: |
.:53 {
errors
health
rewrite name example.com google.com # mapping example.com to google.com
ready
...
Next you need to reload CoreDNS, to use new configuration. You may delete coredns Pod (coredns is deployed as Deployment, so new Pod will be created) or you can send it a SIGUSR1 to tell it to reload graceful.
Finally we can check how it works:
root@kmaster:~# kubectl run -it --rm --image=infoblox/dnstools:latest dnstools
dnstools# host -t A google.com
google.com has address 172.217.21.238
dnstools# host -t A example.com
example.com has address 172.217.21.238
You can find more information about rewrite plugin in Coredns rewrite documentation.