编写网关接口迁移配置与切换方案
盘点现有入口规则并转换为网关资源清单,列明行为差异,提供并行验证、流量切换与回退方案。
完整提示词
<context>
The community ingress-nginx controller was retired by the Kubernetes project in March 2026 and gets no further releases or security fixes, so clusters need to move to Gateway API or a maintained controller. The Ingress objects themselves are easy; the behaviour lives in `nginx.ingress.kubernetes.io/*` annotations and the controller ConfigMap, and none of it carries over automatically. Some annotations map to core Gateway API features: `rewrite-target` to a `URLRewrite` filter, `ssl-redirect` to a `RequestRedirect` filter on an HTTP listener, canary weights to weighted `backendRefs`, gRPC backends to `GRPCRoute`. Others become implementation-specific policies (timeouts in some cases, body size, rate limits, external auth, CORS on older implementations). `configuration-snippet` and `server-snippet` have no equivalent and must be understood and rebuilt. Regex paths (`use-regex`) are implementation-specific. Silent differences cause outages: ingress-nginx defaults such as a 1 MB request body limit, 60 second proxy timeouts, forwarded headers and path normalization may not match the new implementation. Gateway API separates the platform-owned `Gateway` from app-owned routes, so ownership must be decided. A conversion tool (ingress2gateway) gives a starting point, not a finished result.
</context>
<task>
Setup: {{setup}}
1. Read every Ingress, the controller ConfigMap and Helm values. Build the inventory of hosts, paths, TLS secrets and annotations, including global settings.
2. Choose the target implementation with the user if not chosen, and design Gateways, listeners, TLS (cert-manager integration) and route ownership.
3. Convert each Ingress to routes. For each annotation, use the core feature if one exists, an implementation policy if not, and list the rest as gaps with options. Never drop an annotation silently.
4. Write down every default that differs and set it explicitly where the app depends on it (body size, timeouts, headers, path matching).
5. Plan the cutover: run the new implementation alongside with its own load balancer address, test each host by resolving it to the new address, then switch DNS with a lowered TTL, keeping the old controller until traffic drains.
6. Give verification commands for route status, certificates and a per-host smoke test. Do not apply anything to a cluster; leave applying to the user.
</task>
<constraints>
- Do not apply, delete or modify cluster resources; produce manifests and commands for the user to run.
- Do not claim an annotation maps exactly when semantics differ; say how.
- Do not invent policy resource names for an implementation; check its documentation or mark "to verify".
{{> guardrails/verify-before-done}}
{{> guardrails/scope-discipline}}
</constraints>
<output_format>
## Inventory
Table: Ingress | hosts | annotations used | Gateway API equivalent | gap.
## Target design
Controller or Gateway implementation, Gateway and listener layout, who owns which resources, TLS.
## Converted resources
The new manifests, with notes per annotation that changed meaning.
## Cutover plan
Side-by-side run, test method, DNS switch, rollback.
## Behaviour differences
Defaults that change (timeouts, body size, headers, path matching) and how each is handled.
## Remaining risks
Bullets, or "None".
</output_format>可替换内容
- {{setup}}
- {{> guardrails/verify-before-done}}
- {{> guardrails/scope-discipline}}
分类与标签
编程开发、容器集群、网关迁移、入口路由、流量切换、配置转换