Connect services
Applications composed of many microservices need a infrastructure layer for service to service communication: to control the delivery of service requests to other services, to perform load balancing, and to discover other services.
Although you can code the logic that governs communication directly into the microservices, a Kumori Service Link is the recommended way to connect services in the same deployment environment due to it abstracts and externalizes the services connections configuration.
Kumori Service Links main benefits:
-
Allow developers to focus on adding business value with each service they build, rather than worrying about how each service communicates with all other services.
-
Allow DevOps to setup a service mesh programmatically, an essential feature to deploy applications composed of microservices in their CI/CD pipelines.
1. Create services connections
For easy understanding, in this guide we’ll see how to connect the REST API service deployed in the Deploy a service REST API guide, to the MongoDB service deployed in the Deploy a service database guide.
Open the Developer submenu. Click on Link services.
1.1. Select the environment
First, select the environment on which the services to connect are running. For example, select the tenant Freemium
, the account freemium
, and the environment freemium
.
1.2. Services to link
Specify the list of services to connect and set a service or link name to each of them.
1.3. Connect the services above
Finally, for each connection:
-
Select the service or link name of the service that will act as client, following the previous example, select the REST API service which is the service that is a client of the database service.
-
Set the client channel (in the example, in the REST API service) that will be connected to the server channel in the target service.
-
Select the service or link name of the service that will act as server, following the example, select the database service which will receive the TCP calls from REST API.
-
Set the server channel (in the example, in the database service) that will be connected to the client channel.
Click Link. This process will take a few minutes.
Go to any of the linked services card in the Runtime Dashboard, for example the REST API service card, and open the card menu.
Click on Links option and check both services are connected.
Congratulations, you successfully connected the REST API to the database in just a few minutes.