Add custom dns record inside Kubernetes

3/10/2021

Is it possible to add a custom DNS entry (type A) inside Kubernetes 1.19? I'd like to be able to do:

kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools
host custom-dns-entry.example.com
custom-dns-entry.example.com has address 10.0.0.72

with custom-dns-entry.example.com not being registered inside my upstream DNS server (and also not having a corresponding k8s service at all). Following example https://coredns.io/2017/05/08/custom-dns-entries-for-kubernetes/ seems to provide a solution, but it is a bit complex and it may be deprecated. Is there a simpler way to do it please? For example with a few kubectl commands?

The reason why I need this is because I run my workload on kind so my ingress DNS record is not registered inside upstream DNS and some pods require access to this ingress DNS record from inside (maybe to configure a javascript client provided by the pods which will effectively access the ingress DNS record from outside...). However I cannot modify the workload code as I am not maintaining it, so addgin this custom DNS entry seems to be a reasonable solution

-- Fabrice Jammes
coredns
host
kubernetes

1 Answer

3/10/2021

CoreDNS would be the place to do this. You can also do similar-ish things using ExternalName-type Services but that wouldn't give you full control over the hostname (it would be a Service name like anything else).

-- coderanger
Source: StackOverflow