Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Build kong-dashboard or konga for docker container

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Kong is an API gateway that forwards API traffic between clients and (micro) services, extending functionality through plug-ins. Kong has

Two main components:

Kong Server: a nginx-based server that receives API requests.

Apache Cassandra: used to store operational data.

You can scale the Kong service horizontally by adding more Kong Server machines and distribute requests to those machines through front-end load balancers. According to the documentation, two Cassandra nodes are sufficient to support most cases, but if the network is very crowded, consider adding more nodes as appropriate.

One of the most attractive features of Kong for the open source community is the ability to extend existing functionality through plug-ins that are executed during the life cycle of the API request response cycle. The plug-in is written in Lua, and Kong has the following basic functions: HTTP basic authentication, key authentication, CORS (Cross-origin Resource Sharing, cross-domain resource sharing), TCP, UDP, file log, API request flow limit, request forwarding and nginx monitoring.

The Kong package can be run in some Linux distributions, Mac OS X, and Docker, both locally and on cloud servers.

In addition to the free open source version, Mashape also offers a paid enterprise version, which includes technical support, usage training services, and API analytics plug-ins.

Pre-installation preparation

Install the stable version of docker

Basic use of docker

Understand the concept and use of kong (document address: https://getkong.org/docs/)

Conceptual terminology

Upstream: an abstraction of upstream servers

Target: represents a physical service and is an abstraction of ip + port

Service: an abstract service that can be mapped directly to a physical service (host points to ip + port) or to a upstream to achieve load balancing

Route: is the abstraction of routing, which is responsible for mapping the actual request to service.

By default, the port on which KONG listens is:

8000: this port is used by KONG to listen for incoming HTTP requests from the client and forward the request to the server on board.

8443: this port is used by KONG to listen for incoming HTTP requests from the client. It is similar to the function of port 8000, but it is only used to listen for HTTP requests and has no forwarding function. You can disable it by modifying the configuration file

8001: Admin API, through this port, managers can configure the listening service of KONG

8444: through this port, managers can monitor HTTP requests.

Kong installation

Here we take versions above 0.13.x as an example, abandoning the use of API entity objects.

Create a docker network

Docker network create kong-net

Install database, kong supports postgres (above postgres9.5) and Apache Cassandra

Create a startup database. Here, postgres9.5 is used as the database to store data, as follows:

$docker run-d-name kong-database\-network=kong-net\-p 5432 POSTGRES_USER=kong 5432\-e "POSTGRES_USER=kong"\-e "POSTGRES_DB=kong"\ postgres:9.6

Database preparation, initializing Kong data

Docker run-- rm\-- network=kong-net\-e "KONG_DATABASE=postgres"\-e "KONG_PG_HOST=kong-database"\ kong:0.14.1 kong migrations up

Start kong

Docker run-d-name kong\-network=kong-net\-e "KONG_DATABASE=postgres"\-e "KONG_PG_HOST=kong-database"\-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database"\-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 0.0.0.0 8444 ssl "\-p 8000V 8000\-p 8443 V 8443\-p 8001 V 8001\-p 8444V 8444\ kong:0.14.1

Check to see if kong is running

$curl-I http://localhost:8001

If the following appears, there is no problem:

Manage kong through Restful Admin API, reference address: https://docs.konghq.com/0.14.x/admin-api/

Start Kong Dashboard or konga

The official launch of dashboard to manage Kong, the interface is clean, easy to use, let's move on.

Create and run a Kong dashboard container

Docker run-d\-- network=kong-net\-- link kong:kong-p 8008 network=kong-net 8080 pgbi/kong-dashboard start\-- kong-url http://kong:8001\-- basic-auth kong=kong

Then visit http://IP:8008

Login account: kong password: kong, as shown below:

Konga installation process

There is no dashboard in the current community version of KONG, but the paid enterprise version comes with it, and there are some enterprise-only plug-ins and upgraded enterprise plug-ins. So for users who use the community version, excluding the option of signing up a dashboard themselves, the third-party open source dashboard is undoubtedly the first choice. There are currently three dashboard being updated and maintained on GitHub, namely kong-dashboard,kongdash and konga.

When it comes to the management GUI of Kong, kong-dashboard is often said on the Internet, but the latest version (v3.6.0) does not seem to support the latest version of Kong. At present, it is konga that can find more star in github. Konga not only supports the latest version of Kong (the new split feature of service and route), but also supports administrator privilege control and the management of multiple Kong connection pools. Konga needs some data persistence processing because of its own user rights control and Kong connection pool management. The databases supported by default are mongodb, postgres, mysql. We chose PostgresSQL here because the database to which KONG connects is also PGSQL, which reduces the deployment of the database.

Start a container to prepare the database for Konga

Docker run-- rm-- network=kong-net pantsel/konga-c prepare-a postgres-u postgresql://kong@kong-database:5432/konga_db

When the migration is running, we can start Konga

Docker run-p 1337 DB_ADAPTER=postgres 1337\-network=kong-net\-e "DB_ADAPTER=postgres"\-e "DB_HOST=kong-database"\-e "DB_USER=kong"\-e "DB_DATABASE=konga_db"\-e "KONGA_HOOK_TIMEOUT=120000"\-e "NODE_ENV=production" "name konga\ pantsel/kongaAfter a while Konga will be available at:

Visit http://IP:1337

Start postgre admin 4

Create and run a postgre admin 4 container

Docker run-d-p 8009 link kong-database:kong-database 80\-- network=kong-net\-- e "PGADMIN_DEFAULT_EMAIL=admin@admin.com"\-e "PGADMIN_DEFAULT_PASSWORD=admin@admin.com"\-d dpage/pgadmin4

Then visit http://IP:8009

Login account: admin@admin.com, password: admin@admin.com

Create a server with a name, Host=XXX port:5432, username and password as kong

Reference documentation

1.kong official document: https://getkong.org/docs/

2.docker installs kong: https://blog.csdn.net/freewebsys/article/details/80428830

3. Choose Kong as your API gateway: https://www.itcodemonkey.com/article/5980.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report