This article describes several ways to deploy the Goku API Gateway, which can be used as a Gateway in as little as one minute. See the full article for more details.

What is the Goku API Gateway?

Goku API Gateway (Chinese name: Wukong API Gateway) is a Golang-based microservice Gateway that runs at the boundary of enterprise system services. When you’re building websites, apps, IOT’s, or even open API transactions, the Goku API Gateway helps you pull duplicate components from your internal systems and run them on Goku, such as user authorization, access control, firewalls, data conversion, etc. In addition, Goku provides the function of service choreography, so that enterprises can quickly obtain the required data from various services and realize fast response to the business.

The Community version (CE) of the Goku API Gateway has complete usage guidelines and secondary development guidelines. The code is written in pure Go language. It has good performance and scalability, and the built-in plug-in system enables enterprises to customize development for their own business. Using the Goku API Gateway allows business development teams to focus more on business implementation.

A complete set of Goku API Gateway consists of a console and several Gateway nodes. Nodes are registered with the console by IP address, and the configuration items in the console take effect on all nodes. The console is used to configure the running information of the gateway, such as access policy and forwarding API information. Nodes are used for actual forwarding. When the latest configuration is published on the console, all nodes will actively update their running configuration; The configuration published in the console supports versioning and can be published and rolled back manually.

The Goku API Gateway supports the management of clusters with multiple Gateway nodes, enabling users to access different clusters to access different service addresses.

The following is a brief diagram of the deployment architecture of two Data Centers (DCS) :

Online console address:goku-console.eolinker.com

With the online console, it is impossible to distinguish between clusters. If you want to use more powerful features, you are advised to deploy your own private cloud console.

This article presents several deployment modes of the Goku API Gateway:

First, node Docker + online console

Node Docker + online console Docker

Use the installation package to install directly

Links required for deployment and installation:

  • Node Docker:hub.docker.com/r/eolinker/…
  • The console Docker:hub.docker.com/r/eolinker/…
  • Online console: goku-console.eolinker.com
  • Installation package address: github.com/eolinker/go…

First, node Docker+ online console

Goku API Gateway provides node Docker and console Docker. The fastest way is to only deploy node Docker, and then configure the Gateway information through the online console. After the configuration, export the file and upload it to the node server, and finally start node Docker.

Using the step

1. After the configuration is complete, export the configuration on the home page of the online console:

Docker run-dt -p {forwarding port number}:6689 \ -v {log mounting address}:/app/goku-ce/node/work \ -v {configuration file address}:/app/goku-ce/node/work/goku-node.json \ eolinker/goku-api-gateway-ce-nodeCopy the code

The following is an example of the complete configuration:

docker run -dt -p 6689:6689 \
-v /app/goku-ce/node/work:/app/goku-ce/node/work \
-v /app/goku-ce/node/versionConfig_b14a1af4-b961-4dfb-8bfe-d4d157dd651e.json:/app/goku-ce/node/work/goku-node.json \
eolinker/goku-api-gateway-ce-node
Copy the code

The IP address for users to access the API through the gateway is {{node IP address: port}}/{{forwarding URL}}.

Node Docker+ console Docker

1. Deployment console

1. Create a goku-CE exclusive network

Docker network create --driver Bridge --subnet=172.18.12.0/24 --gateway=172.18.12.1 goku-ceCopy the code

2. Run the console program

Docker run-dt -p {browser access port number}:7000 \ -v {sqLite database mount address}:/app/goku-ce/console/work \ -e GOKU_ADMIN_PASSWORD={console admin password} \ --network=goku-ce \ -- IP 172.18.12.2 \ --name goku-ce-console \ eolinker/goku-api-gateway-ce-consoleCopy the code

The full example starts as follows:

docker run -dt -p 7000:7000 \ -v /app/goku-ce/work:/app/goku-ce/console/work \ -e GOKU_ADMIN_PASSWORD=123456 \ --network=goku-ce \ -- IP 172.18.12.2 \ --name goku-ce-console \ eolinker/goku-api-gateway-ce-consoleCopy the code

3. Log in to the console

Open the browser, enter the domain name /IP address + browser access port number, go to the console page, and enter the user name (admin) and password (admin password set on the startup) for login:

(2) Deploy the gateway node

1. Go to the console and create a node

The node IP address must be the same as the IP address bound when starting the docker container of the node:

New node details tutorial

2. Generate and publish the configuration on the console

After publishing the configuration, the node reads the console’s latest configuration to run.

Click on the tutorial link to view publishing configuration

3, start node Docker container

Docker run-dt -p {forwarding port number}:6689 \ --network goku-ce \ -- IP {node IP address} \ -v {log mounting address}:/app/goku-ce/node/work \ -e GOKU_ADMIN_ADDRESS={console IP}:7005 \ eolinker/goku-api-gateway- CE-nodeCopy the code

The full example is as follows:

Docker run-dt-p 6689:6689 \ --network goku-ce \ -- IP 172.18.12.3 \ -v /app/goku-ce/work:/app/goku-ce/node/work \ -e GOKU_ADMIN_ADDRESS = 172.18.12.2:7005 \ eolinker/goku - API - gateway - ce - nodeCopy the code

4. Check the running status of the node

The node management page is displayed. If the node status is running, the node starts normally.

Use the installation package

Installation preparation: Download the latest Release package on Github.

Project address: github.com/eolinker/go…

(1) Install the console

1. Installation command:

mkdir -p {install dir} mv console-{version}.tar.gz {tmp}/ cd {tmp}/ tar -xzf console-{version}.tar.gz cd console-{version} && ./install.sh {install dir} cd {install dir}

2. Go to {install dir}/console/config and edit the configuration file. For the configuration syntax, see yamL.

Goku. Conf as follows:

Listen_port: indicates the listening Port of the management background, which can be opened to the external network. Db_type: indicates the database type. V3.1.0 supports only sqLite db_path: Sqlite DB file path

3. Go to {install dir}/console and run the run.sh file to start the console.

First run:

Sh start {config file} Administrator account Password of the administratorCopy the code

Example:

./run.sh start config/goku.conf admin 123456
Copy the code

Non-first run:

./run.sh start|restart
Copy the code

4. In the browser, enter the server IP address + program listening port number to go to the console page

Note: The program listens to the value of listen_port in the configuration item of goku.conf

(2) Node installation

1. Installation command:

  mkdir -p {install dir}
  mv goku-node-{version}.tar.gz {tmp}/
  cd {tmp}/
  tar -xzf goku-node-{version}.tar.gz
  cd goku-node-{version} && ./install.sh {install dir}
  cd {install dir}
Copy the code

2. Create a node on the console

(1) Log in to the console, select the gateway node from the first-level menu, and create a cluster:

Add a node

The new node
determine

  • When creating a node, enter the internal IP address or local IP address in the node IP field
  • If the value of IP in the admin_bind field in the goku.conf configuration file is 127.0.0.1 or localhost, the node IP address must be set to 127.0.0.1

3. Start the node program:

 {install dir}/run.sh {start|stop|reload|restart|force-reload} [admin url] [port]
Copy the code

The value of the admin URL is the same as the value of the Admin_bind field in the goku.conf configuration file.

Example:

 {install dir}/run.sh start 127.0.0.1:7005 7702
Copy the code

4. Check whether the node is running properly:

Go to the gateway node page on the console. If the status of the node is running, the node starts normally.

Help.eolinker.com/#/tutorial/…

A link to the

Node Docker:hub.docker.com/r/eolinker/…

The console Docker:hub.docker.com/r/eolinker/…

New console: goku-console.eolinker.com

Project address: github.com/eolinker/go…

Project website: www.eolinker.com