Recently, I worked on launching Voila Deer and its related microservices in Kubernetes, and I would love to share my experience with you how Kubernetes made my life much easier thanks to Kubernetes internal DNS. Kubernetes is an open source container cluster manager that allows automate deployments and to interact with application containers. Before I shoot and demonstrate how easy it’s to create services that use Kubernetes internal DNS for communication, I will explain how things were done before.
When building a microservice which would be used by another service, we would do a lot of stuff. Let’s say that we are working on Panda service, we would deploy it on a server and specify an application port — let say 14989, then we would create hostname panda.metabroadcast.com and configure its DNS record. And lastly, we would configure Apache/Nginx to port forward all requests to the panda application. The service that wants to use the panda service, we would use panda.metabroadcast.com. This is pandastic! Or not, since we started to use Kubernetes.
When deploying microservices on Kubernetes, we specify namespace which then is used as an environment of all microservices that are deployed to that specific namespace. For example, we would use the appropriate namespace for all production and staging applications. As I explained previously it can be a quite tedious work to configure microservice before it can be used by another service. But this is not the case in Kubernetes thanks to its internal DNS magic. No more Apache/Nginx configuration, DNS records. Let me demonstrate with Kubernetes deployment configuration file bellow.
As you can see we have panda service Kubernetes deployment configuration, that uses staging namespace. However, it also references a property from the Panda service configuration map. Bellow you can see an example of configuration map file.
To make use of bamboo microservice, all that we need to do is to make a call from the panda service to the bamboo service by making calls to http://bamboo. Finally, we need to specify service configuration file which would be used when starting up the service in Kubernetes. Example of service configuration:
That’s it! We have a happy Panda service that’s making use of bamboo microservice.
All that it take to make services talk to each other in Kubernetes is to deploy services under the same namespace and then to use each service names to make HTTP requests. It’s obvious that Kubernetes will make many engineers here at MetaBroadcast very happy, as we won’t need to worry about how the services talk to each other as this now is handled by Kubernetes internal DNS.
If you enjoyed the read, drop us a comment below or share the article, follow us on Twitter or subscribe to our #MetaBeers newsletter. Before you go, grab a PDF of the article, and let us know if it’s time we worked together.