Third-party Component Management

If distributed databases on public clouds (such as Alibaba Cloud, AWS) cannot be migrated to Kato; or other databases that have not yet been migrated to Kato, then you can use third-party components to register them to Kato, thereby Make the services in the cluster can also access them. This article will demonstrate how to register MySQL outside the cluster to the Kato cluster through a third-party component, and define shared environment variables for it, so as to solve the problem of multiple services repeatedly defining database connection information variables.

If Kato is installed in Alibaba Cloud, please note that the Alibaba Cloud RDS cloud database must be in the same region as the Kato cluster.

Preparation

  • Please make sure you have installed Kato V5.1 or higher.

  • Need to add services, this article uses a MySQL outside the Kato cluster.

  • phpMyAdmin, can be installed from the application market, or can be created through Mirror.

Can you? Assuming that this MySQL is very complicated, for example, it is a distributed, master-slave replication, read-write shared MySQL, the difficulty of migration is relatively high; then you can not migrate this MySQL first, and use third-party components to transfer this MySQL The instance of is added to the Kato cluster, so that it can also use Kato service communication management, component topology relations and other functions.

Step 1: Fill in Third-party Service Information

Log in to the Kato console, and go to Create Application -> Add Third-Party Components.

Fill in information such as component name, application name, component registration method (taking API registration as an example), component address and other information.

Click Create Component, and after the test passes, click Create.

Step 2: Add Instance Address

1. Get the API address and secret key of the added instance

The API address and secret key of the added instance are displayed in the component’s Overview page, as shown in the following figure:

2. Add component instances via Restful API

In your terminal, combine the API and secret key in 1, enter a curl command similar to the following, initiate a PUT request, and add the instance 192.168.1.107 to the component.

curl -X PUT \
--url http://192.168.1.200:7070/console/third_party/bb9371b3a3288e5abb329d780d85507b \
-H "Content-Type: application/json" \
-d '{"secret_key":"jErDmpot","ip":"192.168.1.107","is_online":true}'
{"msg":"success","code":200,"data":{"bean":{},"list":[]},"msg_show":"Successfully modified"}

For detailed API registration, please refer to: [Third-party components registered based on API](/docs/user-manual/component-create/thirdparty-service/thirdparty-create/#Create third-party components registered based on api)

Step 3: Add port

After the creation is complete, you will enter the component management page. Select Port in the navigation.

Click Add Port, enter the port as 3306, and select the mysql protocol.

After the addition is complete, open the internal service, open the service component communication management function.

It should be noted here that internal services can add multiple ports, while third-party components can only add one port.

Step 4: Define and Share Connection Information

Select Connection Information in the navigation, and then define the MySQL connection information (the connection information is actually the environment variables of the service). As shown in the figure:

In this way, when other services rely on this MySQL, you can directly use its connection information. In other words, the defined connection information can be shared.

Step 5: Confirm Service

After opening the internal service, the service can use Kato’s service communication management function.

Make the prepared phpMyAdmin, establish dependencies with dependent third-party components; then update or start phpMyAdmin.

In the Dashboard of phpMyAdmin, click Access to access it, and enter the MySQL account password.

You should see a webpage similar to the following in your browser:

This shows that you have successfully added a service (MySQL) outside the cluster to the cluster through a third-party component.

Enter the instance container of phpMyAdmin, check the environment variables, you should see the MySQL connection information defined in step 4:

# env | grep MYSQL
MYSQL_PASS=kato
MYSQL_HOST=127.0.0.1
MYSQL_USER=root
MYSQL_PORT=3306

This shows that the MySQL connection information has been successfully shared with phpMyAdmin. In this example, phpMyAdmin did not use the connection information. In your actual use, you can use the connection information according to the actual situation.

Summary

At this point, I believe you have already understood how to register services outside the Kato cluster to the cluster, and define and share its environment variables; after third-party components are registered in the cluster, they can use communication governance, component topology relationships, etc., like internal services. Features.