chore: add missing READMEs

This commit is contained in:
Sun-ZhenXing
2025-11-08 21:57:17 +08:00
parent a65a009640
commit febd1601a2
34 changed files with 1806 additions and 167 deletions

107
src/kong/README.md Normal file
View File

@@ -0,0 +1,107 @@
# Kong Gateway
[English](./README.md) | [中文](./README.zh.md)
This service deploys Kong Gateway, a cloud-native API gateway and service mesh, with PostgreSQL database and optional Konga GUI.
## Services
- `kong-db`: PostgreSQL database for Kong
- `kong-migrations`: Database migration service (runs once)
- `kong`: Kong Gateway service
- `kong-gui`: Konga GUI for Kong management (profile: `gui`)
## Quick Start
```bash
docker compose up -d
```
To enable Konga GUI:
```bash
docker compose --profile gui up -d
```
## Environment Variables
| Variable Name | Description | Default Value |
| ------------------------------ | ---------------------------------------------------- | ----------------------- |
| `GLOBAL_REGISTRY` | Global registry prefix for all images | `""` |
| `KONG_VERSION` | Kong image version | `3.8.0-alpine` |
| `KONGA_VERSION` | Konga GUI image version | `latest` |
| `POSTGRES_VERSION` | PostgreSQL image version | `16.6-alpine3.21` |
| `KONG_DB_PASSWORD` | PostgreSQL password for Kong database | `kongpass` |
| `KONG_PROXY_PORT_OVERRIDE` | Host port for Kong proxy (maps to port 8000) | `8000` |
| `KONG_PROXY_SSL_PORT_OVERRIDE` | Host port for Kong proxy SSL (maps to port 8443) | `8443` |
| `KONG_ADMIN_API_PORT_OVERRIDE` | Host port for Kong Admin API (maps to port 8001) | `8001` |
| `KONG_ADMIN_SSL_PORT_OVERRIDE` | Host port for Kong Admin API SSL (maps to port 8444) | `8444` |
| `KONG_GUI_PORT_OVERRIDE` | Host port for Konga GUI (maps to port 1337) | `1337` |
| `KONG_ADMIN_LISTEN` | Kong Admin API listen address | `0.0.0.0:8001` |
| `KONG_ADMIN_GUI_URL` | Kong Admin GUI URL | `http://localhost:8002` |
| `TZ` | Timezone | `UTC` |
Please modify the `.env` file as needed for your use case.
## Volumes
- `kong_db_data`: PostgreSQL data for Kong
- `konga_data`: Konga application data (if using GUI profile)
## Ports
- `8000`: Kong proxy (HTTP)
- `8443`: Kong proxy (HTTPS)
- `8001`: Kong Admin API (HTTP)
- `8444`: Kong Admin API (HTTPS)
- `1337`: Konga GUI (optional, with `gui` profile)
## Access Points
- Kong Proxy: <http://localhost:8000>
- Kong Admin API: <http://localhost:8001>
- Konga GUI: <http://localhost:1337> (if enabled)
## Basic Usage
### Add a Service
```bash
curl -i -X POST http://localhost:8001/services \
--data name=example-service \
--data url='http://example.com'
```
### Add a Route
```bash
curl -i -X POST http://localhost:8001/services/example-service/routes \
--data 'paths[]=/example'
```
### Test the Route
```bash
curl -i http://localhost:8000/example
```
## Custom Configuration
To use a custom Kong configuration file, uncomment the volume mount in `docker-compose.yaml`:
```yaml
volumes:
- ./kong.conf:/etc/kong/kong.conf:ro
```
## Security Notes
- Change the default database password in production
- Enable authentication for Kong Admin API in production
- Use SSL/TLS for all communications in production
- Regularly update Kong and its plugins for security patches
- Consider using Kong's RBAC and authentication plugins
## License
Kong Gateway is licensed under Apache License 2.0. See [Kong GitHub](https://github.com/Kong/kong) for more information.

107
src/kong/README.zh.md Normal file
View File

@@ -0,0 +1,107 @@
# Kong Gateway
[English](./README.md) | [中文](./README.zh.md)
此服务用于部署 Kong Gateway一个云原生 API 网关和服务网格,包含 PostgreSQL 数据库和可选的 Konga GUI。
## 服务
- `kong-db`Kong 的 PostgreSQL 数据库
- `kong-migrations`:数据库迁移服务(运行一次)
- `kong`Kong 网关服务
- `kong-gui`:用于 Kong 管理的 Konga GUI配置文件`gui`
## 快速开始
```bash
docker compose up -d
```
启用 Konga GUI
```bash
docker compose --profile gui up -d
```
## 环境变量
| 变量名 | 说明 | 默认值 |
| ------------------------------ | ---------------------------------------------- | ----------------------- |
| `GLOBAL_REGISTRY` | 全局镜像仓库前缀 | `""` |
| `KONG_VERSION` | Kong 镜像版本 | `3.8.0-alpine` |
| `KONGA_VERSION` | Konga GUI 镜像版本 | `latest` |
| `POSTGRES_VERSION` | PostgreSQL 镜像版本 | `16.6-alpine3.21` |
| `KONG_DB_PASSWORD` | Kong 数据库的 PostgreSQL 密码 | `kongpass` |
| `KONG_PROXY_PORT_OVERRIDE` | Kong 代理主机端口(映射到端口 8000 | `8000` |
| `KONG_PROXY_SSL_PORT_OVERRIDE` | Kong 代理 SSL 主机端口(映射到端口 8443 | `8443` |
| `KONG_ADMIN_API_PORT_OVERRIDE` | Kong Admin API 主机端口(映射到端口 8001 | `8001` |
| `KONG_ADMIN_SSL_PORT_OVERRIDE` | Kong Admin API SSL 主机端口(映射到端口 8444 | `8444` |
| `KONG_GUI_PORT_OVERRIDE` | Konga GUI 主机端口(映射到端口 1337 | `1337` |
| `KONG_ADMIN_LISTEN` | Kong Admin API 监听地址 | `0.0.0.0:8001` |
| `KONG_ADMIN_GUI_URL` | Kong Admin GUI URL | `http://localhost:8002` |
| `TZ` | 时区 | `UTC` |
请根据实际需求修改 `.env` 文件。
## 卷
- `kong_db_data`Kong 的 PostgreSQL 数据
- `konga_data`Konga 应用程序数据(使用 GUI 配置文件时)
## 端口
- `8000`Kong 代理HTTP
- `8443`Kong 代理HTTPS
- `8001`Kong Admin APIHTTP
- `8444`Kong Admin APIHTTPS
- `1337`Konga GUI可选使用 `gui` 配置文件)
## 访问点
- Kong 代理:<http://localhost:8000>
- Kong Admin API<http://localhost:8001>
- Konga GUI<http://localhost:1337>(如已启用)
## 基本使用
### 添加服务
```bash
curl -i -X POST http://localhost:8001/services \
--data name=example-service \
--data url='http://example.com'
```
### 添加路由
```bash
curl -i -X POST http://localhost:8001/services/example-service/routes \
--data 'paths[]=/example'
```
### 测试路由
```bash
curl -i http://localhost:8000/example
```
## 自定义配置
要使用自定义 Kong 配置文件,请在 `docker-compose.yaml` 中取消注释卷挂载:
```yaml
volumes:
- ./kong.conf:/etc/kong/kong.conf:ro
```
## 安全提示
- 生产环境中请更改默认数据库密码
- 生产环境中为 Kong Admin API 启用身份验证
- 生产环境中所有通信使用 SSL/TLS
- 定期更新 Kong 及其插件以获取安全补丁
- 考虑使用 Kong 的 RBAC 和身份验证插件
## 许可证
Kong Gateway 采用 Apache License 2.0 许可。详情请参见 [Kong GitHub](https://github.com/Kong/kong)。