The power of CoreDNS in Kubernetes

Tyson Lawrie
2 min readAug 9, 2019

--

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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Tyson Lawrie
Tyson Lawrie

Written by Tyson Lawrie

A software engineer and automation enthusiast, made in Australia, Ex New Yorker. Building flowabl.io and userprofiles.io. Maintaining useboomerang.io

No responses yet