Building Microservice Architecture on Kubernetes

August 22, 2019 By Derek Weeks

3 minute read time

Istanbul is home to architectural wonders of the ancient world, such as the Hagia Sophia and the Basilica Cistern, but today Istanbul brings us microservice architecture, where smaller is better.

Huseyin Babal is in Istanbul, where he was a DevOps Consultant with Kloia (now at Hazelcast). He is also the organizer of Docker Istanbul, NodeSchool Istanbul, and DevOps Underground (not held in the Basilica Cistern). At last year's All Day DevOps conference, he demonstrated how to implement a microservice architecture using Kubernetes. Huseyin’s talk was focused on an architectural overview rather than how to install Kubernetes.

Microservices divide your application’s functions into chunks that are independently deployable. Microservices are becoming an increasingly utilized tool in DevOps and CI/CD, and it is a popular subject at All Day DevOps. Kubernetes is an open-source platform to manage microservices. It is deployable on the cloud provider of your choice. AWS, Azure, and Google Cloud all provide managed instances of Kubernetes, and you can use kubespray to deploy Kubernetes in your datacenter. It helps you focus on the architecture rather than the infrastructure-level operations.

Huseyin begins talking about architecture at the high level. Most organizations need development, staging, and production environments, at a minimum. You can organize these in clusters in isolation, as you probably already do.

null

Or he suggests a better way - namespace-level isolation, along with this pro-tip, “Do not put all things in the default namespace, as it will be very hard to manage them in the future.”

Development Staging Production

Once your system is setup, you need to make sure you monitor everything. Prometheus is a tool you can use, and Huseyin walks through several of its capabilities and mentions an open-source tool to handle k8s-specific metrics automatically.

When you are ready to expose your application to the outside world, there are several options, such as a load balancer. However, creating a load balancer for each instance will be hard to manage and costly, so he recommends Nginx Ingress to automatically create a load balancer.

Of course, deploying Kubernetes, load balancing, and monitoring doesn’t mean you have implemented microservices. You need to have a solid architecture using best practices. Part of this is making sure the microservices can communicate well. Huseyin recommends striving to achieve the glory of REST.

null

Huseyin also covers using secrets, deployment scripts, project file structure, basic CI/CD with Kubernetes, distributed configuration, client code generation, and logging. Additionally, he recommends a couple tools for daily Kubernetes management: kubectx for managing your Kubernetes context and kubens for managing your Kubernetes namespace, both provided by Ahmet Alp Balkan.

Watch his whole presentation here.

Tags: open source goveranance, devops best practices, Open Source, Application Security, devsecops, Kubernetes

Written by Derek Weeks

Derek serves as vice president and DevOps advocate at Sonatype and is the co-founder of All Day DevOps -- an online community of 65,000 IT professionals.