alibabacloud-nginx-ingress-to-api-gateway
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNginx Ingress to APIG Migration
Nginx Ingress 到 APIG 迁移
Scenario Description
场景描述
Migrate Kubernetes nginx Ingress resources to Alibaba Cloud API Gateway (APIG). APIG is an Envoy-based gateway (Higress) that uses . This skill classifies every annotation into Compatible / Ignorable / Unsupported, resolves unsupported annotations via a four-level decision tree (Higress native → safe-to-drop → built-in plugin → custom WasmPlugin), generates migrated Ingress YAML, and produces a deployment-ready migration report.
ingressClassName: apignginx.ingress.kubernetes.io/*Architecture:
nginx Ingress Controller → APIG (Envoy/Higress) + optional WasmPlugin (Go, proxy-wasm-go-sdk)The core analysis workflow operates entirely offline on user-provided YAML — no cluster access, CLI tools, or cloud credentials required.
将Kubernetes nginx Ingress资源迁移至阿里云API网关(APIG)。APIG是基于Envoy的网关(Higress),使用。本技能会将所有注解分类为兼容/可忽略/不支持三类,通过四级决策树(Higress原生支持→可安全丢弃→内置插件适配→自定义WasmPlugin开发)解决不兼容注解问题,生成迁移后的Ingress YAML,并输出可直接用于部署的迁移报告。
ingressClassName: apignginx.ingress.kubernetes.io/*架构:
nginx Ingress Controller → APIG (Envoy/Higress) + 可选 WasmPlugin (Go, proxy-wasm-go-sdk)核心分析流程完全基于用户提供的YAML离线运行,无需访问集群、安装CLI工具或提供云账号凭证。
Installation
安装说明
This skill operates entirely offline on user-provided YAML. No CLI tools, SDKs, or cloud credentials are required.
On-demand tools (only when the workflow reaches a step that needs them):
| Tool | When needed | Check command | Minimum version |
|---|---|---|---|
| jq | Script-based offline analysis | | >= 1.6 |
| python3 + PyYAML | YAML parsing (alternative to yq) | | python3 >= 3.8, PyYAML >= 5.0 |
| yq | YAML parsing (alternative to python3+PyYAML) | | >= 4.0 |
| Go | Step 3 determines a custom WasmPlugin is needed | | >= 1.24 |
| Docker | Custom WasmPlugin needs to be built as OCI image | | — |
Do NOT pre-check or prompt installation of any tool during analysis.
本技能完全基于用户提供的YAML离线运行,无需安装CLI工具、SDK或提供云凭证。
按需使用的工具(仅当工作流执行到对应步骤时才需要):
| 工具 | 需要场景 | 检查命令 | 最低版本 |
|---|---|---|---|
| jq | 基于脚本的离线分析 | | >= 1.6 |
| python3 + PyYAML | YAML解析(yq的替代方案) | | python3 >= 3.8, PyYAML >= 5.0 |
| yq | YAML解析(python3+PyYAML的替代方案) | | >= 4.0 |
| Go | 步骤3判定需要开发自定义WasmPlugin时 | | >= 1.24 |
| Docker | 需要将自定义WasmPlugin构建为OCI镜像时 | | — |
分析过程中请勿预检查或提示安装任何工具。
Environment Variables
环境变量
No environment variables required. This skill does not invoke any cloud APIs or CLI tools.
无需配置环境变量。本技能不会调用任何云API或CLI工具。
Authentication
鉴权说明
Not applicable. This skill does not invoke Alibaba Cloud APIs or CLI. No credentials are needed.
不涉及鉴权。本技能不会调用阿里云API或CLI,无需任何凭证。
RAM Policy
RAM权限策略
Not applicable. This skill operates entirely on local YAML files and does not call any cloud APIs.
不涉及。本技能完全基于本地YAML文件运行,不会调用任何云API。
Parameter Confirmation
参数确认
This skill only performs analysis and code generation — it does NOT execute any deployment or cluster write operations.When the user provides Ingress YAML, proceed immediately with the full workflow (Step 1→5) and output the complete result. Do NOT ask for RegionId, OCI registry, or any other parameter. Useand<REGION>placeholders in the output.<YOUR_REGISTRY>请避免以下交互模式,直接执行对应操作即可:
- "是否需要我分析这个 Ingress?" — 建议直接分析
- "是否需要生成迁移后的 YAML?" — 建议直接生成
- "是否需要创建迁移配置文件/检查清单?" — 建议直接创建
- "是否需要开发 WasmPlugin?" — 如果决策树判定需要,建议直接开发
- "请确认 RegionId / OCI 地址" — 建议使用占位符
| Parameter Name | Required/Optional | Description | Default Value |
|---|---|---|---|
| Ingress YAML | Required | nginx Ingress YAML to migrate (paste, file, or directory) | — |
When Ingress YAML is not provided: If the user asks about migration but does not provide YAML, respond with: "请提供需要迁移的 nginx Ingress YAML(可以直接粘贴、提供文件路径或目录路径)。" Do NOT abort the conversation — guide the user to provide the required input.
本技能仅执行分析和代码生成操作,不会执行任何部署或集群写入操作。当用户提供Ingress YAML时,请立即执行完整工作流(步骤1→5)并输出完整结果,请勿询问RegionId、OCI镜像仓库地址或其他参数,输出中使用和<REGION>作为占位符即可。<YOUR_REGISTRY>请避免以下交互模式,直接执行对应操作即可:
- "是否需要我分析这个 Ingress?" — 建议直接分析
- "是否需要生成迁移后的 YAML?" — 建议直接生成
- "是否需要创建迁移配置文件/检查清单?" — 建议直接创建
- "是否需要开发 WasmPlugin?" — 如果决策树判定需要,建议直接开发
- "请确认 RegionId / OCI 地址" — 建议使用占位符
| 参数名称 | 必填/可选 | 描述 | 默认值 |
|---|---|---|---|
| Ingress YAML | 必填 | 待迁移的nginx Ingress YAML(可直接粘贴、提供文件路径或目录路径) | — |
当未提供Ingress YAML时:如果用户询问迁移相关问题但未提供YAML,回复:"请提供需要迁移的 nginx Ingress YAML(可以直接粘贴、提供文件路径或目录路径)。"请勿终止对话,引导用户提供所需输入即可。
Core Workflow
核心工作流
建议:收到 YAML 后一次性完成全部分析步骤当用户提供 Ingress YAML 时,建议立即执行全部步骤(Step 1→5)并在一次响应中输出完整结果。
- 对于未指定的参数(如 RegionId、OCI registry),使用
等占位符<REGION>- 收到 YAML 后直接进入分析流程,无需额外确认
- 各步骤之间连续执行,无需中途暂停询问用户
- 迁移配置文件和检查清单作为标准输出的一部分自动生成
- 整个工作流是确定性的:YAML 输入 → 完整迁移报告输出,无需中间确认
- 唯一必需的输入是 Ingress YAML 本身
建议:收到YAML后一次性完成全部分析步骤当用户提供Ingress YAML时,建议立即执行全部步骤(步骤1→5)并在一次响应中输出完整结果。
- 对于未指定的参数(如RegionId、OCI镜像仓库地址),使用
等占位符<REGION>- 收到YAML后直接进入分析流程,无需额外确认
- 各步骤连续执行,无需中途暂停询问用户
- 迁移配置文件和检查清单作为标准输出的一部分自动生成
- 整个工作流是确定性的:YAML输入 → 完整迁移报告输出,无需中间确认
- 唯一必需的输入是Ingress YAML本身
Step 1: Parse Ingress YAML
步骤1:解析Ingress YAML
Accept YAML from any of the following input formats:
- Direct paste in conversation (with or without markdown code fences)
- File path (e.g., ,
ingress.yaml)./k8s/ingress.yaml - Directory path (scan all /
.yamlfiles for Ingress resources).yml - Multi-document YAML (separated by )
--- - Partial YAML (missing /
apiVersion— infer as Ingress ifkindwithannotationsare present)nginx.ingress.kubernetes.io/*
For each Ingress found, extract all annotations.
nginx.ingress.kubernetes.io/*If the user's message mentions migration/analysis but does NOT include any YAML, respond with: "请提供需要迁移的 nginx Ingress YAML(可以直接粘贴、提供文件路径或目录路径)。" Do NOT abort or error out — guide the user to provide input.
支持以下任意格式的YAML输入:
- 对话中直接粘贴(带或不带markdown代码块标记均可)
- 文件路径(例如、
ingress.yaml)./k8s/ingress.yaml - 目录路径(扫描所有/
.yaml文件中的Ingress资源).yml - 多文档YAML(用分隔)
--- - 不完整YAML(缺失/
apiVersion,如果存在kind开头的注解则推断为Ingress资源)nginx.ingress.kubernetes.io/*
对每个识别到的Ingress,提取所有开头的注解。
nginx.ingress.kubernetes.io/*如果用户消息提到迁移/分析但未提供任何YAML,回复:"请提供需要迁移的 nginx Ingress YAML(可以直接粘贴、提供文件路径或目录路径)。"请勿报错或终止对话,引导用户提供输入即可。
Step 2: Classify Annotations
步骤2:注解分类
Classify each annotation into exactly one of three categories. See for the complete 117-annotation lookup table.
references/annotation-mapping.md| Category | Count | Action | Example |
|---|---|---|---|
| Compatible | 50 | Keep in migrated YAML | |
| Ignorable | 16 | Strip (Envoy handles natively) | |
| Unsupported | 51 | Strip → resolve via decision tree | |
Inline Quick Lookup — High-Frequency Annotations:
| Annotation | Category | Action |
|---|---|---|
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ✅ Compatible | Keep |
| ⚪ Ignorable | Strip |
| ⚪ Ignorable | Strip |
| ⚪ Ignorable | Strip |
| ⚪ Ignorable | Strip |
| ⚪ Ignorable | Strip |
| ⚪ Ignorable | Strip |
| ❌ Unsupported | WasmPlugin (HTTP callout) |
| ❌ Unsupported | WasmPlugin (directive conversion) |
| ❌ Unsupported | WasmPlugin (directive conversion) |
| ❌ Unsupported | Built-in |
| ❌ Unsupported | Built-in |
| ❌ Unsupported | Built-in |
| ❌ Unsupported | Higress native |
| ❌ Unsupported | Safe to drop (Envoy default behavior) |
| ❌ Unsupported | Rename to |
If an annotation is NOT in the above table, look it up in. If still not found, classify as Unsupported and resolve via the decision tree in Step 3.references/annotation-mapping.md
Special value changes (compatible but value must change):
- →
load-balance: ewma(APIG does not support EWMA)round_robin - → rename to
ssl-ciphers(singular form)ssl-cipher - →
affinity-mode: persistent(APIG only supports balanced)balanced
将每个注解归类到以下三类中的某一类,完整的117个注解映射表请参考。
references/annotation-mapping.md| 分类 | 数量 | 处理方式 | 示例 |
|---|---|---|---|
| 兼容 | 50 | 迁移后的YAML中保留 | |
| 可忽略 | 16 | 直接移除(Envoy原生支持对应能力) | |
| 不支持 | 51 | 移除后通过决策树适配 | |
高频注解快速查询表:
| 注解 | 分类 | 处理方式 |
|---|---|---|
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ✅ 兼容 | 保留 |
| ⚪ 可忽略 | 移除 |
| ⚪ 可忽略 | 移除 |
| ⚪ 可忽略 | 移除 |
| ⚪ 可忽略 | 移除 |
| ⚪ 可忽略 | 移除 |
| ⚪ 可忽略 | 移除 |
| ❌ 不支持 | WasmPlugin(HTTP回调)适配 |
| ❌ 不支持 | WasmPlugin(指令转换)适配 |
| ❌ 不支持 | WasmPlugin(指令转换)适配 |
| ❌ 不支持 | 内置 |
| ❌ 不支持 | 内置 |
| ❌ 不支持 | 内置 |
| ❌ 不支持 | Higress原生 |
| ❌ 不支持 | 可安全丢弃(Envoy默认行为) |
| ❌ 不支持 | 重命名为 |
如果注解不在上表中,请查询,如果仍未找到,归类为不支持并通过步骤3的决策树适配。references/annotation-mapping.md
特殊值转换规则(兼容但值需要修改):
- →
load-balance: ewma(APIG不支持EWMA负载均衡算法)round_robin - → 重命名为
ssl-ciphers(单数形式)ssl-cipher - →
affinity-mode: persistent(APIG仅支持balanced亲和模式)balanced
Step 3: Resolve Unsupported Annotations
步骤3:不兼容注解适配
For each unsupported annotation, follow this decision tree in order:
1. Higress native annotation? → Use native equivalent (no WasmPlugin needed)
2. Safe to drop? → Remove without replacement
3. Built-in platform plugin? → Use built-in OCI image via higress.io/wasmplugin annotation
4. None of the above? → Develop custom WasmPluginSee for the complete decision tree, and for the built-in plugin catalog.
references/migration-patterns.mdreferences/builtin-plugins.mdHigress native mappings:
| nginx annotation | Higress equivalent |
|---|---|
| |
| |
Safe-to-drop: , , ,
service-upstreamenable-access-logproxy-request-buffering: offconnection-proxy-headerBuilt-in plugins: / → , → . See .
limit-rpslimit-connectionskey-rate-limitenable-modsecuritywafreferences/builtin-plugins.mdCustom WasmPlugin (last resort): , , , etc. See for SDK reference, for conversion patterns.
auth-urlserver-snippetconfiguration-snippetreferences/wasm-plugin-sdk.mdreferences/snippet-patterns.md对每个不支持的注解,按顺序执行以下决策树:
1. 存在Higress原生对应注解? → 使用原生等价注解(无需WasmPlugin)
2. 可安全丢弃? → 直接移除无需替换
3. 存在平台内置插件支持? → 通过higress.io/wasmplugin注解引用内置OCI镜像
4. 以上都不满足? → 开发自定义WasmPlugin适配完整决策树请参考,内置插件目录请参考。
references/migration-patterns.mdreferences/builtin-plugins.mdHigress原生映射:
| nginx注解 | Higress等价注解 |
|---|---|
| |
| |
可安全丢弃的注解: 、、、
service-upstreamenable-access-logproxy-request-buffering: offconnection-proxy-header内置插件适配: / → , → ,详见。
limit-rpslimit-connectionskey-rate-limitenable-modsecuritywafreferences/builtin-plugins.md自定义WasmPlugin(最后方案): 、、等场景使用,SDK参考请见,转换规则请见。
auth-urlserver-snippetconfiguration-snippetreferences/wasm-plugin-sdk.mdreferences/snippet-patterns.mdStep 4: Generate Migrated Ingress YAML
步骤4:生成迁移后的Ingress YAML
For each input Ingress, generate a migrated copy:
yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: <original-name>-apig
namespace: <original-namespace>
annotations:
# Compatible annotations preserved
# Unsupported annotations replaced with higress.io/wasmplugin if needed
spec:
ingressClassName: apig # MUST be hardcoded to apig
rules: ... # Preserved from original
tls: ... # Preserved from original为每个输入的Ingress生成迁移后的副本:
yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: <原始名称>-apig
namespace: <原始命名空间>
annotations:
# 保留兼容的注解
# 不兼容的注解按需替换为higress.io/wasmplugin注解
spec:
ingressClassName: apig # 必须固定为apig
rules: ... # 保留原始配置
tls: ... # 保留原始配置Step 5: Output Migration Report
步骤5:输出迁移报告
所有输出建议使用中文(中文)。包括分析表、迁移总结、后续操作指南及所有说明性文字。代码块(YAML、Go、bash)保持原始语法。以下所有内容均为标准输出项,建议在一次响应中完整输出,无需逐项询问用户。
Output ALL of the following for each Ingress:
- 兼容性分析表 — annotation, value, category (兼容/可忽略/不支持), action
- 迁移后的 Ingress YAML — ready for user to apply
- 自定义 WasmPlugin 源码 — if Step 3 determined custom plugins are needed (skip only if no custom plugin is needed)
- 迁移总结 — what changed, value changes, plugins needed
- 后续操作指南 — 根据兼容性分析结果,分场景告知用户完整的迁移操作路径:
- 完全兼容(无不兼容注解):所有注解均为兼容或可忽略类型,用户可直接参考 Nginx Ingress 迁移到云原生 API 网关 完成迁移。
- 不完全兼容(存在不兼容注解):按以下顺序操作:
- 构建并推送自定义 WasmPlugin OCI 镜像
- 将迁移后 Ingress YAML 中的 OCI URL 占位符替换为真实的 WasmPlugin 镜像地址
- 将替换后的 Ingress YAML 部署到集群中
- 参考 Nginx Ingress 迁移到云原生 API 网关 继续后续操作,在步骤一「指定 IngressClass」处需指定为
apig - 网关版本要求:使用 WasmPlugin 需确保云原生 API 网关版本在 2.1.16 及以上,否则需要升级版本或创建新网关
See for the guide template.
references/deployment-guide-template.mdScope boundary: This skill generates all artifacts and instructions. It does NOT execute,kubectl apply, or any cluster/registry write operations. Those are left to the user. No confirmation needed: Every item above is always generated. Never ask "是否需要生成迁移文件/检查清单/部署指南?"docker push
所有输出建议使用中文。包括分析表、迁移总结、后续操作指南及所有说明性文字。代码块(YAML、Go、bash)保持原始语法。以下所有内容均为标准输出项,建议在一次响应中完整输出,无需逐项询问用户。
为每个Ingress输出以下所有内容:
- 兼容性分析表 — 注解、值、分类(兼容/可忽略/不支持)、处理方式
- 迁移后的Ingress YAML — 用户可直接部署使用
- 自定义WasmPlugin源码 — 如果步骤3判定需要自定义插件则输出(无自定义插件时跳过)
- 迁移总结 — 变更内容、值转换说明、所需插件说明
- 后续操作指南 — 根据兼容性分析结果,分场景告知用户完整的迁移操作路径:
- 完全兼容(无不兼容注解):所有注解均为兼容或可忽略类型,用户可直接参考 Nginx Ingress 迁移到云原生 API 网关 完成迁移。
- 不完全兼容(存在不兼容注解):按以下顺序操作:
- 构建并推送自定义WasmPlugin OCI镜像
- 将迁移后Ingress YAML中的OCI URL占位符替换为真实的WasmPlugin镜像地址
- 将替换后的Ingress YAML部署到集群中
- 参考 Nginx Ingress 迁移到云原生 API 网关 继续后续操作,在步骤一「指定 IngressClass」处需指定为
apig - 网关版本要求:使用WasmPlugin需确保云原生API网关版本在 2.1.16 及以上,否则需要升级版本或创建新网关
指南模板请参考。
references/deployment-guide-template.md能力边界: 本技能仅生成所有产物和操作指南,不会执行、kubectl apply或任何集群/镜像仓库写入操作,这些操作由用户自行执行。 无需确认: 以上所有项都会默认生成,永远不要询问"是否需要生成迁移文件/检查清单/部署指南?"docker push
Success Verification Method
成功验证方法
See for verification steps to include in the migration report.
references/verification-method.mdThe migration report should instruct the user to verify with:
bash
undefined迁移报告中需要包含的验证步骤请参考。
references/verification-method.md迁移报告应指导用户通过以下命令验证:
bash
undefinedValidate migrated YAML syntax (user runs this)
验证迁移后的YAML语法(用户自行执行)
kubectl apply --dry-run=client -f <migrated-ingress>.yaml
kubectl apply --dry-run=client -f <迁移后的Ingress文件>.yaml
Confirm ingressClassName is apig
确认ingressClassName为apig
grep "ingressClassName: apig" <migrated-ingress>.yaml
> This skill outputs verification instructions for the user. It does NOT execute these commands.grep "ingressClassName: apig" <迁移后的Ingress文件>.yaml
> 本技能仅输出验证指导,不会执行这些命令。Cleanup
清理说明
Not applicable. This skill only generates text output (YAML, Go source code, migration report). No cloud resources or cluster objects are created by this skill.
不涉及清理操作。本技能仅生成文本输出(YAML、Go源码、迁移报告),不会创建任何云资源或集群对象。
API and Command Tables
API与命令表
This skill does not execute any CLI commands or API calls. All output is text-based (YAML, Go source code, migration report with instructions for the user).
本技能不会执行任何CLI命令或API调用,所有输出均为文本格式(YAML、Go源码、带操作指南的迁移报告)。
Best Practices
最佳实践
- Always classify ALL annotations before generating migrated YAML — never skip annotations
- Use placeholders (,
<REGION>) for unspecified parameters; never hardcode user-specific values<YOUR_REGISTRY> - Preserve original ,
rules, andtlsin migrated YAMLnamespace - Add suffix to migrated Ingress name for easy identification
-apig - Prefer built-in plugins over custom WasmPlugin — check first
references/builtin-plugins.md - For custom WasmPlugin, use SDK exclusively
github.com/higress-group/wasm-go/pkg/wrapper - Track annotation value changes (e.g., →
ewma) explicitly in the reportround_robin - For /
server-snippet, enumerate every directive and verify 1:1 conversion completenessconfiguration-snippet - Never execute cluster write operations (,
kubectl apply, etc.) — only output instructions for the userdocker push
- 生成迁移YAML前必须完成所有注解的分类,不得遗漏任何注解
- 未指定的参数使用占位符(、
<REGION>),永远不要硬编码用户专属值<YOUR_REGISTRY> - 迁移后的YAML中保留原始的、
rules和tls配置namespace - 迁移后的Ingress名称添加后缀便于识别
-apig - 优先使用内置插件而非自定义WasmPlugin,优先查询
references/builtin-plugins.md - 自定义WasmPlugin必须使用SDK
github.com/higress-group/wasm-go/pkg/wrapper - 迁移报告中明确标注注解值的变更(例如→
ewma)round_robin - 处理/
server-snippet时,枚举所有指令并验证1:1转换完整性configuration-snippet - 永远不要执行集群写入操作(、
kubectl apply等),仅输出操作指南供用户执行docker push
Reference Links
参考链接
| Reference | Contents |
|---|---|
| Complete 117-annotation compatibility lookup table |
| Decision tree, Higress native mappings, safe-to-drop list, special handling |
| APIG built-in platform plugins catalog with OCI URLs |
| Region-specific OCI registry addresses for built-in plugins |
| server-snippet / configuration-snippet → WasmPlugin conversion patterns |
| Higress WASM Go Plugin SDK reference (core API) |
| WasmPlugin HTTP client patterns (external auth, callouts) |
| WasmPlugin Redis client patterns (rate limiting, session) |
| Advanced WasmPlugin patterns (streaming, tick, leader election) |
| Local WasmPlugin testing with Docker Compose |
| WasmPlugin build, OCI push, and Ingress annotation binding |
| Migration report deployment guide template |
| Testing acceptance criteria with correct/incorrect patterns |
| Success verification steps and commands |
| 定期安全复审策略与检查项 |
| 安全影响评估与数据处理流程 |
| RAM 权限声明(本 Skill 无需任何权限) |
| 参考文件 | 内容说明 |
|---|---|
| 完整的117个注解兼容性查询表 |
| 决策树、Higress原生映射、可丢弃注解列表、特殊处理规则 |
| APIG内置平台插件目录及对应OCI地址 |
| 不同区域的内置插件OCI镜像仓库地址 |
| server-snippet / configuration-snippet 转 WasmPlugin 规则 |
| Higress WASM Go Plugin SDK参考(核心API) |
| WasmPlugin HTTP客户端实现模式(外部鉴权、回调) |
| WasmPlugin Redis客户端实现模式(限流、会话管理) |
| WasmPlugin高级实现模式(流式处理、定时任务、主节点选举) |
| 使用Docker Compose本地测试WasmPlugin的方法 |
| WasmPlugin构建、OCI推送、Ingress注解绑定指南 |
| 迁移报告部署指南模板 |
| 测试验收标准及正确/错误示例 |
| 成功验证步骤与命令 |
| 定期安全复审策略与检查项 |
| 安全影响评估与数据处理流程 |
| RAM权限声明(本Skill无需任何权限) |