Kuma Service Mesh on Kubernetes and Spring Boot: Microservices Made Better!

Arnav Khandelwal
4 min readMay 3, 2023
Figure 1: Kuma Mesh

It has been a long time since the industry started giving preference to microservice architecture in place of monolithic, since they are easy to deploy, can work with various technologies, and provides better availability as they are distributed. The microservices are made up of various small services, each handling some portion of the application instead of one single service, responsible for handling all the functions. Due to this, sometimes they become huge and need proper management.

Service mesh plays the crucial role of providing a decentralized mechanism for managing communications. They can also implement features like encryption, load balancing, tracing as well as logging. A service mesh mainly consists of two elements: the Control plane and the Data plane. The data plane handles the traffic, and the control plane provides configuration as well as coordination.

Video 1: Kuma Service Mesh Basics

One such service mesh is provided by Kuma (Figure 1/Video 1), which is an open-source tool and comes in both Kubernetes and Universal deployment modes. The Kuma service mesh helps in improving the security, reliability, and observability of our service mesh. It can use Prometheus and Grafana to help visualize the working of our services.

Apart from these, an API gateway is always advised to keep the services secured, as we can easily deploy various plugins to prevent any threat to the services running in our mesh. We will be using the Kong ingress controller as our gateway for the mesh.

In this article, we will be deploying a Spring Boot API, one of the most popular JVM frameworks for developing microservice applications, on Kubernetes with Kuma mesh. We will then expose the service via the kong ingress gateway, through which we can access our application. The demonstration is done in a virtual machine with Linux OS (amazon linux 2).

INITIAL SETUP

First, we need to install docker for running our Kubernetes cluster, which you can install and setup in your system from their official website or visit this link.

Next, we need to install and configure Kubernetes and Kubectl.

Figure 2: Installing Kubernetes

Notice that we still cannot run the commands for Kubernetes. For, this we need to install minikube.

Figure 3: Installing Minikube

Note that you might need to install conntrack, depending on your system.

After its done, run the command:

Figure 4: Running the container

INSTALLING KUMA

After the minikube has started, execute the following commands to install Kuma:

Figure 5: Installing Kuma

SPRING BOOT APPLICATION

Now, we need to create a spring boot application. You can create one of your own or refer to this one for testing:

Figure 6: Spring Controller Class Mentioning Endpoints

Now, we need to convert it into a docker image. For this, you can visit https://spring.io/guides/gs/spring-boot-docker/ and create the image and upload it on the docker hub

Now, we will need to inject a sidecar proxy in the default namespace. You can use the following configuration:

Figure 7: Injecting Sidecar

After this, we need to install our kong ingress controller. You can follow the instructions on the link and install it through the helm.

Now, we need to fetch and deploy the docker image of our spring-boot application. You can deploy using the following file:

Figure 8: Installing Kong Ingress via Helm

Where arnavkdocker/service1 is your image of the spring boot application.

After this is done, we need to connect this service with the Ingress gateway. For this, run the following YAML file:

Figure 9: Running via Ingress Gateway

After this is done, you can copy the IP and port of kong-proxy, which you can get by following instructions from the previous link, and add “ /service1/test1 ” on your browser.

Figure 10: Testing on Browser

You can add plugins such as rate-limiting, authentication, etc and various other functionalities of the kong-gateway from Kong-Hub.

Figure 11: Kong Gateway

In conclusion, the deployment of microservices on Kubernetes with Kuma service mesh and Kong API gateway provides a highly efficient and secure way of managing distributed applications. With the help of Kuma, we can easily manage and monitor our services, and the Kong ingress controller provides an added layer of security to prevent any threat to our services. This article outlines the steps required to deploy a Spring Boot API on Kubernetes with Kuma mesh and Kong gateway, demonstrating the ease of deployment and configuration of these tools. As technology advances, we can expect more sophisticated tools and techniques to further enhance the management of microservices and improve their performance.

--

--