Kong gateway installation and konga installation

1. Kong installation

Installation machine address: 192.168.19.50

1. Customize a docker network

[root@min ~]# docker network create kong-net
a9bde4e7d16e4838992000cd5612476b238f7a88f95a07c994a9f57be7f64c10

Check if the network is created successfully

[root@min ~]# docker network ls
NETWORK ID     NAME       DRIVER    SCOPE
e30d2ad88f06   bridge     bridge    local
f5707c0bc33a   host       host      local
a9bde4e7d16e   kong-net   bridge    local
469a9f965ac7   none       null      local

You can see that the kong-net network has been created successfully

2. Start the PostgreSQL container

 docker run -d --name kong-database \
  --network=kong-net \
  -p 5432:5432 \
  -e "POSTGRES_USER=kong" \
  -e "POSTGRES_DB=kong" \
  -e "POSTGRES_PASSWORD=kongpass" \
  postgres:13

3. Prepare the data required by Kong

docker run --rm --network=kong-net \
 -e "KONG_DATABASE=postgres" \
 -e "KONG_PG_HOST=kong-database" \
 -e "KONG_PG_PASSWORD=kongpass" \
 -e "KONG_PASSWORD=test" \
kong/kong-gateway:3.3.0.0 kong migrations bootstrap

After the initialization is complete, the database will add some new tables:

4. Start the Kong container

docker run -d --name kong-gateway \
 --network=kong-net \
 -e "KONG_DATABASE=postgres" \
 -e "KONG_PG_HOST=kong-database" \
 -e "KONG_PG_USER=kong" \
 -e "KONG_PG_PASSWORD=kongpass" \
 -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
 -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
 -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
 -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
 -e "KONG_ADMIN_LISTEN=0.0.0.0:8001" \
 -e "KONG_ADMIN_GUI_URL=http://localhost:8002" \
 -e KONG_LICENSE_DATA \
 -p 8000:8000 \
 -p 8443:8443 \
 -p 8001:8001 \
 -p 8444:8444 \
 -p 8002:8002 \
 -p 8445:8445 \
 -p 8003:8003 \
 -p 8004:8004 \
 kong/kong-gateway:3.3.0.0

5. Verify whether the installation is successful

curl -i -X GET --url http://localhost:8001/services

As can be seen from the above, it can be seen that kong has been installed successfully

Since the open source version of kong manage cannot be used, we need to install konga for interface management. The installation of konga is as follows:

Two, konga installation 

1. Database preparation

Konga supports three databases: MySQL, MongoDB, and PostgresSQL. Here we use mysql data as the persistence layer of Konga. Use the following command to start a mysql database

docker run --name mysql5.7  -p 3306:3306 -e  MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7

2. Install konga (virtual machine address: 192.168.19.50)

2.1 Perform initialization database operations and create table operations:

docker run --rm pantsel/konga:latest -c prepare -a mysql -u mysql://root:[email protected]:3306/konga_databas

Once created:

 2.2 Actual installation

 docker run -d -p 1337:1337 --network=kong-net -e "DB_ADAPTER=mysql"  -e "DB_HOST=192.168.19.50" -e "DB_PORT=3306" -e "DB_USER=root"  -e "DB_PASSWORD=my-secret-pw" -e "DB_DATABASE=konga_databas" -e "NODE_ENV=production" --name konga pantsel/konga

2.3 Enter on the external host browser

192.168.19.50:1337

fill in the information,

userName: kong-test

email: [email protected]

password:1234567

Click the CREATE ADMIN button to jump to the login page:

, Enter the registered information just now to log in, and then fill in the information for management

3. Test the gateway forwarding capability of kong 

1. Create a service, use postman to create a kong_service

2. Create a route based on the kong_service you just created

 

3. Prepare a springboot project. The request path of the project is as follows:

 

4. Upload the jar package to the server 192.168.19.50, and then start

nohup java -jar kong-demo-0.0.1-SNAPSHOT.jar --server.port=8080

5. Access on the browser of the external host

192.168.19.50:8000/kong_service/hello

 192.168.19.50:8000/kong_service/hello/sub

 So far, we have successfully installed kong, and successfully created a service and route, and finally tested that kong can successfully forward requests

Guess you like

Origin blog.csdn.net/zhangshenglu1/article/details/130934300