DNS records
In order to create unique DNS records per VirtualMachineInstance, it is possible to set spec.hostname
and spec.subdomain
. If a subdomain is set and a headless service with a name, matching the subdomain, exists, kube-dns will create unique DNS entries for every VirtualMachineInstance which matches the selector of the service. Have a look at the DNS for Services and Pods documentation for additional information.
The following example consists of a VirtualMachine and a headless Service which matches the labels and the subdomain of the VirtualMachineInstance:
As a consequence, when we enter the VirtualMachineInstance via e.g. virtctl console vmi-fedora
and ping myvmi.mysubdomain
we see that we find a DNS entry for myvmi.mysubdomain.default.svc.cluster.local
which points to 10.244.0.57
, which is the IP of the VirtualMachineInstance (not of the Service):
So spec.hostname
and spec.subdomain
get translated to a DNS A-record of the form <vmi.spec.hostname>.<vmi.spec.subdomain>.<vmi.metadata.namespace>.svc.cluster.local
. If no spec.hostname
is set, then we fall back to the VirtualMachineInstance name itself. The resulting DNS A-record looks like this then: <vmi.metadata.name>.<vmi.spec.subdomain>.<vmi.metadata.namespace>.svc.cluster.local
.
Last updated