The power of CoreDNS in Kubernetes
I am a Software Engineer at IBM enjoying the journey to a Cloud Native landscape.

When starting out with kubernetes we gave a lot of focus to the object definitions, deployment topology, and packaging. As our usage matured we started implementing policy objects and additional components to cover areas like OpenTracing or Policy Management. We have also started exploring service meshes.
In the mean time we ran into a problem where we had installed middleware and application services of which we could not adjust the network configuration. Yet requirements around using a forward-proxy and on occasion directing traffic via private VLANs rather than public ingress.
Solution: CoreDNS Plugins
Without the ability to implement and / or configure application level networking frameworks, and without a service mesh to run a side car to control the network interaction we went in circles exploring our own internal implementations of various solutions.
By far the simplest was to implement a CoreDNS plugin to handle the routing of this network traffic.
To solve the issue where a particular middleware component needed to connect to another piece of middleware on a private VLAN interface, all we had to do was use the host
plugin from CoreDNS, which acts similar to a host entry.
Note: we couldn’t use the deployment hosts implementation as the piece of middleware was spun up via a controller at run time and didn’t pass on the hosts entry.
Configuring CoreDNS
CoreDNS uses a Corefile inside of the data section of the configmap.
To utilize the host plugin and an entry, it is as simple as adding the hosts {} block in the below definition.
data: Corefile: | .:53 { errors health hosts <DNS> { <IP> <DNS> fallthrough } kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure upstream fallthrough in-addr.arpa ip6.arpa }
Conclusion
I hope the above shows you another way to solve an issue inside kubernetes if the default hosts block of a kubernetes object is not available.
CoreDNS has many plugins that all provide simple but powerful functionality.