Skip to content

Commit 8e34c41

Browse files
authored
feat: 集成内置 Plugin Server 并升级版本至 2.2.1 (#254)
* feat(all-in-one): 集成并配置内置 Plugin Server 以分发 WASM 插件 - 新增 all-in-one 镜像内 Plugin Server 组件及其 nginx 配置 - 在 superviosrd 中新增 plugin-server 启动管理 - 通过环境变量 USE_PLUGIN_SERVER 控制 Plugin Server 启用与否 - 调整启动脚本以支持根据 USE_PLUGIN_SERVER 配置加载 WASM 插件方式 - 配置脚本增加 --use-plugin-server 与 --no-plugin-server 参数支持 - docker-compose 添加 plugin-server 服务及相关环境变量 - 支持 All-in-One 模式通过环境变量灵活开启或关闭内置 Plugin Server - README 增加 All-in-One 发布模式文档说明使用 Plugin Server 配置 - 调整默认配置,启用 Plugin Server 并更新相关镜像标签和地址 - 增加 gitignore 忽略插件服务器生成及 IDE 配置文件 * chore(deployment): 更新插件服务器版本和配置改进 - 将 all-in-one 中插件服务器及相关组件版本从 2.1.11 升级至 2.2.1 - 优化插件服务器 nginx 配置,新增健康检查接口 /healthz - 修改 docker-compose 健康检查命令以适配新的健康检查路径 - 清理根目录 .gitignore 文件,简化忽略规则 - all-in-one/.gitignore 修正.idea 文件忽略配置 - compose/scripts/prepare.sh 脚本新增插件服务器配置检查和默认 nginx 配置写入功能
1 parent b1dd19c commit 8e34c41

15 files changed

Lines changed: 303 additions & 15 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ docker compose
9999

100100
Higress Console 在服务器本地监听的端口。默认值为 8080。
101101

102+
* --use-plugin-server
103+
104+
使用内置的 Plugin Server 通过 HTTP 方式分发 WASM 插件。此为默认行为。
105+
106+
* --no-plugin-server
107+
108+
禁用内置的 Plugin Server,WASM 插件将通过 OCI 镜像方式加载。
109+
102110
* -r, --rerun
103111

104112
在 Higress 已配置完成后重新执行配置流程。
@@ -140,6 +148,48 @@ higress-precheck-1 "/bin/bash ./prechec…" precheck exited (0)
140148

141149
查看 Higress 各组件的运行日志。
142150

151+
## Docker All-in-One 模式
152+
153+
除了 Docker Compose 多容器部署外,Higress 还提供了 All-in-One 单容器部署模式,将所有组件打包在一个 Docker 镜像中运行。
154+
155+
### 构建镜像
156+
157+
```bash
158+
docker build -t higress-all-in-one ./all-in-one
159+
```
160+
161+
### 启动容器
162+
163+
```bash
164+
docker run -d --name higress \
165+
-p 8080:8080 -p 8443:8443 -p 8001:8001 \
166+
higress-all-in-one
167+
```
168+
169+
### 环境变量
170+
171+
All-in-One 模式通过环境变量控制各组件的行为,可在 `docker run` 时通过 `-e` 参数传入:
172+
173+
* `MODE`
174+
175+
运行模式。可选值为 `full`(默认)、`gateway``console`
176+
177+
* `O11Y`
178+
179+
是否启用可观测性组件(Prometheus、Grafana 等)。可选值为 `on``off`(默认)。需镜像中已包含相关组件。
180+
181+
* `USE_PLUGIN_SERVER`
182+
183+
是否启用内置的 Plugin Server 通过 HTTP 方式分发 WASM 插件。默认启用。设置为 `false``off``no``N` 可禁用,禁用后 WASM 插件将通过 OCI 镜像方式加载。
184+
185+
```bash
186+
# 禁用 Plugin Server
187+
docker run -d --name higress \
188+
-e USE_PLUGIN_SERVER=off \
189+
-p 8080:8080 -p 8443:8443 -p 8001:8001 \
190+
higress-all-in-one
191+
```
192+
143193
## 设计文档
144194

145195
- [方案整体设计](./docs/design.md)

all-in-one/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/*.cmd
33
/*.bat
44
/docker-compose.yml
5-
/higress
5+
/higress
6+
.idea

all-in-one/Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
ARG HUB=higress-registry.cn-hangzhou.cr.aliyuncs.com/higress
22
ARG BASE_VERSION=2022-10-27T19-02-22
3-
ARG CORE_VERSION=2.1.11
4-
ARG CONSOLE_VERSION=2.1.11
3+
ARG CORE_VERSION=2.2.1
4+
ARG CONSOLE_VERSION=2.2.1
55
ARG APISERVER_VERSION=0.0.29
6-
ARG ENVOY_VERSION=2.1.11
6+
ARG ENVOY_VERSION=2.2.1
7+
ARG PLUGIN_SERVER_VERSION=2.2.1
78

89
FROM ${HUB}/api-server:${APISERVER_VERSION} AS apiserver
910
FROM ${HUB}/higress:${CORE_VERSION} AS controller
1011
FROM ${HUB}/pilot:${CORE_VERSION} AS pilot
1112
FROM ${HUB}/gateway:${CORE_VERSION} AS gateway
1213
FROM ${HUB}/console:${CONSOLE_VERSION} AS console
1314
FROM ${HUB}/eclipse-temurin:21-jre AS jdk
15+
FROM ${HUB}/plugin-server:${PLUGIN_SERVER_VERSION} AS plugin-server
1416

1517
FROM ${HUB}/base:${BASE_VERSION}
1618

@@ -37,6 +39,9 @@ COPY --from=gateway /usr/local/bin/supercronic* /usr/local/bin/
3739
# Install console
3840
COPY --from=console /app /app
3941

42+
# Install plugin-server (nginx with wasm plugins)
43+
COPY --from=plugin-server /usr/share/nginx/html/plugins /usr/share/nginx/html/plugins
44+
4045
# Install JDK required by console
4146
ENV JAVA_HOME=/opt/java/openjdk
4247
COPY --from=jdk $JAVA_HOME $JAVA_HOME
@@ -53,7 +58,7 @@ RUN arch="$(dpkg --print-architecture)"; \
5358
esac; \
5459
apt-get update --allow-unauthenticated; \
5560
apt-get install --no-install-recommends -y --allow-unauthenticated \
56-
wget supervisor logrotate cron; \
61+
wget supervisor logrotate cron nginx; \
5762
apt-get upgrade -y --allow-unauthenticated; \
5863
apt-get clean; \
5964
rm -rf /var/log/*log /var/lib/apt/lists/* /var/log/apt/* /var/lib/dpkg/*-old /var/cache/debconf/*-old; \
@@ -74,7 +79,8 @@ COPY ./gateway/podinfo /etc/istio/pod
7479
COPY ./scripts /usr/local/bin
7580
COPY ./apiserver/config /app/kubeconfig
7681
COPY ./config /opt/data/defaultConfig
82+
COPY ./plugin-server/nginx.conf /etc/nginx/plugin-server/nginx.conf
7783

78-
EXPOSE 8080 8443 8001
84+
EXPOSE 8080 8443 8001 8002
7985

8086
ENTRYPOINT ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
daemon off;
2+
user www-data;
3+
worker_processes auto;
4+
pid /run/nginx.pid;
5+
error_log /var/log/nginx/error.log notice;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
15+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16+
'$status $body_bytes_sent "$http_referer" '
17+
'"$http_user_agent"';
18+
19+
access_log /var/log/nginx/access.log main;
20+
21+
sendfile on;
22+
keepalive_timeout 65;
23+
24+
server {
25+
listen 8002;
26+
server_name localhost;
27+
28+
# Static files root directory
29+
root /usr/share/nginx/html;
30+
31+
# Hide Nginx version
32+
server_tokens off;
33+
34+
# Health check endpoint
35+
location = /healthz {
36+
return 200 'ok';
37+
add_header Content-Type text/plain;
38+
}
39+
40+
# Error pages
41+
error_page 500 502 503 504 /50x.html;
42+
location = /50x.html {
43+
root /usr/share/nginx/html;
44+
}
45+
}
46+
}

all-in-one/scripts/base.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ case $O11Y in
6565
esac
6666
echo "O11Y=$O11Y"
6767

68+
case $USE_PLUGIN_SERVER in
69+
false|FALSE|off|OFF|no|NO|N|n)
70+
USE_PLUGIN_SERVER=off
71+
;;
72+
*)
73+
# Default to on
74+
USE_PLUGIN_SERVER=on
75+
;;
76+
esac
77+
echo "USE_PLUGIN_SERVER=$USE_PLUGIN_SERVER"
78+
6879
CONSOLE_USED_MARKER='/data/.console-used'
6980
CONSOLE_USED='false'
7081
if [ -f "$CONSOLE_USED_MARKER" ]; then

all-in-one/scripts/start-console.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ if [ "$O11Y" == "on" ]; then
3030
export HIGRESS_CONSOLE_DASHBOARD_DATASOURCE_LOKI_URL="http://localhost:3100"
3131
fi
3232

33+
if [ "$USE_PLUGIN_SERVER" == "on" ]; then
34+
export HIGRESS_ADMIN_WASM_PLUGIN_CUSTOM_IMAGE_URL_PATTERN="http://localhost:8002/plugins/\${name}/\${version}/plugin.wasm"
35+
fi
36+
3337
HIGRESS_CONSOLE_KUBE_CONFIG="/app/kubeconfig" \
3438
HIGRESS_CONSOLE_SERVICE_HOST="higress-console.static" \
3539
HIGRESS_CONSOLE_SERVICE_PORT=80 \

all-in-one/scripts/start-controller.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ waitForApiServer
1919

2020
set -e
2121

22+
# Use HTTP for loading wasm plugins from plugin-server
23+
if [ "$USE_PLUGIN_SERVER" == "on" ]; then
24+
export MCP_SERVER_WASM_IMAGE_URL="http://localhost:8002/plugins/mcp-server/1.0.0/plugin.wasm"
25+
fi
26+
2227
/usr/local/bin/higress \
2328
serve \
2429
--kubeconfig=/app/kubeconfig \
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname -- "$0")"
4+
ROOT=$(pwd)
5+
cd - >/dev/null
6+
source $ROOT/base.sh
7+
8+
if [ "$USE_PLUGIN_SERVER" != "on" ]; then
9+
echo "Plugin-server won't run when USE_PLUGIN_SERVER is not turned on."
10+
sleep 2
11+
exit 0
12+
fi
13+
14+
# Start nginx for plugin-server (foreground mode via daemon off in nginx.conf)
15+
exec nginx -c /etc/nginx/plugin-server/nginx.conf

all-in-one/supervisord/supervisord.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ stdout_logfile_maxbytes=10MB
1818
redirect_stderr=true
1919
environment=
2020

21+
[program:plugin-server]
22+
directory=/
23+
command=bash /usr/local/bin/start-plugin-server.sh
24+
priority=50
25+
autostart=true
26+
autorestart=unexpected
27+
startsecs=1
28+
stdout_logfile=/var/log/higress/plugin-server.log
29+
stdout_logfile_maxbytes=10MB
30+
redirect_stderr=true
31+
environment=
32+
2133
[program:controller]
2234
directory=/
2335
command=bash /usr/local/bin/start-controller.sh

0 commit comments

Comments
 (0)