内网higress配置wasm插件流程

​ 内网环境higress里面的插件用不了,因为插件的镜像是外网的oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/mcp-server/all-in-one:2.0.0

​ 但是这个是一个符合 OCI 标准的 Wasm 插件镜像,需要从 OCI 兼容的镜像仓库(如 Docker Hub、Harbor、ACR 等)拉取这个 Wasm 模块。不是所有 Harbor 版本默认启用 OCI Artifact 支持(Wasm 是一种 OCI Artifact,不是普通容器镜像)。
​ 请确保:
Harbor ≥ v2.2.0(推荐 v2.6+)
在 Harbor 项目设置中 启用 “支持 Helm Chart、Wasm 等 OCI Artifacts”(通常叫 “Enable OCI Artifacts” 或类似选项)
推送 Wasm 时使用 oras 或支持 OCI Artifacts 的工具(不能用 docker push)

使用Harbor ≥ v2.2.0版本推送对应的wasm插件

日志中的错误:

1
2
3
4
5
error   wasm    convert the wasm config: 1 error occurred:
* cannot fetch Wasm module oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/mcp-server/all-in-one:2.0.0:
could not fetch Wasm OCI image:
could not fetch manifest: Get "https://higress-registry.cn-hangzhou.cr.aliyuncs.com/v2/":
dial tcp 121.40.213.69:443: connect: connection refused

说明:

  • Higress Gateway Pod 无法访问公网(或私有镜像仓库)。
  • 目标地址 higress-registry.cn-hangzhou.cr.aliyuncs.com 是阿里云容器镜像服务(ACR),但你的集群节点或 Pod 没有网络权限访问该地址(可能是防火墙、代理、VPC 隔离等原因)。
  • 连接被 connection refused,说明连 TCP 三次握手都失败了,很可能是 出向网络被阻断

解决方案

  1. 在能访问公网的机器上拉取镜像:

    1
    crane pull oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/mcp-server/all-in-one:2.0.0 all-in-one-2.0.0.wasm

    或使用 oras

    1
    oras pull higress-registry.cn-hangzhou.cr.aliyuncs.com/mcp-server/all-in-one:2.0.0
1
2
3
4
5
6
   
2. **将 `.wasm` 文件推送到你们内部的镜像仓库(如 Harbor、自建 ACR 等):**
```bash
oras push your-internal-registry.local/mcp-server/all-in-one:2.0.0 \
--manifest-config /dev/null:application/vnd.unknown.config.v1+json \
all-in-one-2.0.0.wasm:application/vnd.wasm.content.layer.v1+wasm
  1. 修改 Higress 插件配置,将 image 字段指向内网地址:

    1
    2
    3
    spec:
    settings:
    image: oci://your-internal-registry.local/mcp-server/all-in-one:2.0.0

✅ 这样 Gateway 就无需访问外网,直接从内网拉取,避免网络问题。

证书问题

错误如下

1
* cannot fetch Wasm module oci://harbor01.xjky.com/mcp-server/all-in-one:2.0.0: could not fetch Wasm OCI image: could not fetch manifest: Get "https://harbor01.xjky.com/v2/": tls: failed to verify certificate: x509: certificate signed by unknown authority

这个错误表明 Higress Gateway Pod 不信任你的 Harbor 服务器证书。因为你的 Harbor (harbor01.xjky.com) 使用的是自签名证书或内部 CA 签发的证书,而 Pod 的容器内没有信任该 CA。

修改 higress-config ConfigMap,添加 Wasm 拉取的不安全选项:

1
kubectl edit cm -n higress-system higress-config

mesh 配置段添加:

1
2
3
4
5
mesh: |-
defaultConfig:
proxyMeta
WASM_INSECURE_SKIP_VERIFY: "true"
WASM_INSECURE_SKIP_HOSTNAME_VERIFY: "true"

然后重启:

kubectl rollout restart deploy/higress-gateway -n higress-system

其他问题

禁用不需要的插件

1
2
3
4
5
# 查看现有的 WasmPlugin
kubectl get wasmplugin -A

# 删除或禁用 key-auth 插件
kubectl delete wasmplugin -n higress-system key-auth # 或者你的插件名称

重启所有组件

1
2
3
4
5
# 重启 controller 使 ConfigMap 生效
kubectl rollout restart deploy/higress-controller -n higress-system

# 重启 gateway
kubectl rollout restart deploy/higress-gateway -n higress-system

Higress 的主要日志组件

  1. higress-controller
    • 负责监听 Kubernetes 的 Ingress、Gateway API 等资源变更,并生成配置。
    • 日志内容:配置同步、事件处理、控制器内部状态等。
  2. higress-gateway
    • 基于 Envoy 的数据面网关,处理实际的 HTTP/HTTPS 流量。
    • 日志内容:访问日志(access log)、错误日志、Wasm 插件日志、Envoy 内部日志等。
  3. Wasm 插件日志(可选)
    • 如果你启用了自定义或官方 Wasm 插件,插件内部通过 wrapper.Log 打印的日志也会输出到标准输出中 。

如何查看日志

Higress 所有组件的日志默认都输出到 容器的标准输出(stdout/stderr),因此你可以使用 kubectl logs 查看:

1
2
3
4
5
6
7
8
# 查看 controller 日志
kubectl logs -n higress-system <higress-controller-pod-name>
# 查看 gateway 日志(可能有多个副本)
kubectl logs -n higress-system <higress-gateway-pod-name>
如果你不确定 Pod 名称,可以先列出:
kubectl get pods -n higress-system
例如:
kubectl logs -n higress-system higress-gateway-5cb7f44768-snfbd