docs/en/Community-Articles/2023-06-05-Kubernetes-Integration-Abp-Studio/POST.md
Microservice architecture is a quite common approach to build highly scalable solutions with a large development team. While there are standard tools, like Kubernetes, to deploy, run and scale your microservices, the development side is not as mature as that. It is not easy to develop, run and test a single microservice that depends on other microservices and services. Running a copy of the entire system in the developer's machine is impractical.
In this article, I will introduce an efficient way of creating a development environment that is well integrated to Kubernetes. In this way, you can just run the microservice you are building and let Kubernetes run all your dependencies in your local machine or a remote server.
I will demonstrate the solution by introducing and using a brand new tool for ABP Developers: ABP Studio!
This article is based on my Kubernetes Integrated Microservice Development with ABP Studio talk performed in ABP Dotnet Conf'23. You can watch that talk if you would like watching rather than reading.
Let’s start by introducing the main topics I will cover in this article:
It is important to understand what is the essential problem when we try to set up a development environment for a microservice solution. To understand the main difficulty, let’s see what a microservice solution looks like:
A typical microservice solution consists of many components communicating to each other. In this example;
There will be much more supporting services, like Redis, Elasticsearch and so on. As you see, we have a lot of independent services and applications interacting with each other in a typical microservice solution.
Generally, your responsibility is developing one or a few of these microservices or applications, not all of them. For example, you may be responsible for developing or testing the Product microservice:
All you want to do is to write your code, then run and test your service if it is correctly working. However, to be able to develop, run, test or debug the product microservice, all of the service and infrastructure dependencies need to be running and communicating to each other.
Okay, maybe not all, but most of them are needed. Otherwise, you can not open the application UI, login to the system, add products to basket and place an order to see if it is working properly, or you can not live debug your service code in case of trouble.
So, how to make the whole system up and running easily to be able to focus on developing, testing and debugging the Product microservice?
You are not the only one getting trouble to develop, run, test and debug a microservice solution. Microsoft also thought of it and introduced a tool called the Project Tye. With its own words in their GitHub repository:
Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier.
Tye can simplify microservices development by making it easy to run many services with one command, use dependencies in containers, discover addresses of other services using simple conventions. It can also deploy .NET applications to Kubernetes by automatically creating containers for .NET applications and generating Kubernetes manifests with minimal knowledge or configuration.
The deployment part is not mature and they have to do a lot of work. However, the solution runner part works very well.
Tye project consists of three major components:
Tye uses a YAML file to configure your solution. It typically contains many service definitions. There are three type of services can be defined in this YAML file:
Here, an example content of a tye.yaml file:
Once you define your YAML file, Tye can run all the services with a single terminal command: tye run. It builds all .NET applications before running them. If you specify the watch parameter, it watches the changes in your .NET projects, re-builds and runs them when a change happens. There are also other commands to build and deploy your solution.
The final major component is the Tye Dashboard. With this dashboard, you can see the list of the services with their statuses. You can also view their logs and open their UI with a single click.
A screenshot from the Tye Dashboard:
I’ve prepared a microservice solution for demos in this article and I will use the same solution in all demos. Here, an overall diagram of the example solution:
We have two web applications, two API Gateways, 5 microservices. 3 of them are shown here: Product, Ordering and Identity microservices. Every microservice has its independent SQL Server database. They communicate through REST API calls and distributed events via RabbitMQ.
You can watch my 6-minutes demo to see the Project Tye in action:
<iframe width="560" height="315" src="https://www.youtube.com/embed/S0-z29lMokA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>Click here to watch the demo on YouTube
The demo shows how the Tye project is useful. However, there are many missing points and problems with the current project state. Let’s talk about them;
So, basically, it seems Microsoft has no further interest in this project and you can expect it will be retired in the near future.
Okay, now we came to the ABP Studio part. At Volosoft, we were silently working on the ABP Studio project for more than one year.
ABP Studio is a cross-platform desktop application for ABP developers. It is well integrated to the ABP Framework and aims to provide a comfortable development environment for you by automating things, providing insights about your solution, making develop, run and deploy your solutions much easier.
We are planning to release a beta version in Q3 of 2023. You can expect the following features shipping with the initial release:
I've prepared a demo of the ABP Studio Solution Runner, but first I want to mention the main features of the solution runner:
You can watch my 9-minutes demo to see ABP Studio Solution Runner in action:
<iframe width="560" height="315" src="https://www.youtube.com/embed/sSCxyccoHqE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>Click here to watch the demo on YouTube
Finally, we came to the essential topic I want to talk about. Until that point, we had a good understanding of the problem and possible solutions. In this part, we will make a final touch to the solution to have a great development environment for a microservice solution.
ABP Studio Kubernetes Tunnel System allows you to connect your local development environment to a local or remote Kubernetes cluster, where that cluster already runs your microservice solution. In this way, you can access any service in Kubernetes with their service name as DNS, just like they are running in your local computer. This is established with a secure VPN connection.
Secondly, you can intercept any service in that cluster, so all the traffic to the intercepted service is automatically redirected to your service that is running in your local machine. When your service needs to use any service in Kubernetes, the traffic is redirected back to the cluster, just like your local service is running inside the Kubernetes. In this way, you don’t need to care about how all other services are configured and running. You just focus on the service you are responsible for developing, testing or debugging. You can use your favorite IDE since you are running your service in your local machine as you always do.
The solution runner is a great way of running multiple services locally. However, if your solution consists of hundreds of services, running all them in your local machine will consume your system resources and slow down your development speed. The best news is that: You can use the Kubernetes Tunnelling combined with all the solution runner features to have a perfect local microservice development environment.
I am sure that you want to see it in action, but before that, let me explain how the solution works.
All of these happen when you click the Connect button on the ABP Studio. Now, your computer can use the internals of the Kubernetes cluster. But, how the HTTP Requests coming to the Product service in the Kubernetes cluster are redirected to your local machine?
Don’t worry, ABP Studio doesn’t change your local environment variables. The change only affects the live product service instance, and it is reverted when you disable the interception in ABP Studio. Also, when you click the Disconnect button in ABP Studio, all the changes made to your cluster and your local computer will be cleared. It won’t leave any sign in your systems.
So, now we have a fully Kubernetes integrated development environment. Let’s see how it is used in ABP Studio in the following 9-minutes demo:
<iframe width="560" height="315" src="https://www.youtube.com/embed/CeUq2ysz-mQ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>Click here to watch the demo on YouTube
In the next months, the team will be working on the following items:
We have other great plans for that product. However, I can not declare them yet as they are secrets for now :) We’ve planned to release the first beta version in Q3 of 2023.
I want to notice that ABP Studio is not a new version or replacement of ABP Suite. We built the ABP Studio from scratch. Both products will be developed and shipped in parallel. ABP Suite will continue to focus on code generation. ABP Studio doesn’t have any code generation capabilities yet. So, you will use both of them together.
Okay let’s summarize what I’ve explained in this article:
With that final part, we had a great and easy to use microservice development environment. It is great, because we can focus on only a single service, while we don’t care about all other parts of the solution. Also, we can save our local development machine system resources by delegating running the dependencies to a remote Kubernetes server.