Sub topic 12
Annotations with no portable equivalent
This chapter assumes you can read an Ingress with NGINX annotations. It also assumes you know the Gateway and HTTPRoute resources from earlier chapters.
Why annotations are the hard part
Path, host and TLS rules map cleanly to Gateway API fields. Annotations are different. Ingress NGINX used them to expose the controller's own features, so many have no standard field. Moving them needs a decision for each one, not a mechanical translation.
Sort annotations into three groups
| Group | Example annotations | Gateway API answer |
|---|---|---|
| Standard equivalent | `ssl-redirect`, `canary-weight`, `rewrite-target` | `RequestRedirect`, `backendRefs` weights, `URLRewrite` |
| Partly standard, depends on version | `proxy-read-timeout`, `enable-cors`, `affinity` | `timeouts` on a rule. CORS and session persistence need a recent release or an experimental channel. |
| No standard equivalent | `configuration-snippet`, `server-snippet`, `auth-url`, `limit-rps`, `whitelist-source-range`, `proxy-body-size` | Implementation policy, `ExtensionRef`, or another layer |
Check the Gateway API release you have installed and the feature list of your implementation before you place an annotation in a group.
An example
This Ingress carries three annotations:
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "120"
nginx.ingress.kubernetes.io/limit-rps: "10"
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "X-Frame-Options: DENY";The timeout can move into the route. The header becomes a standard filter. The rate limit has no field, so it needs your implementation's policy resource.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: app
namespace: shop
spec:
parentRefs:
- name: shared-gateway
namespace: gateway-system
sectionName: https
hostnames:
- app.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
timeouts:
request: 120s
filters:
- type: ResponseHeaderModifier
responseHeaderModifier:
set:
- name: X-Frame-Options
value: DENY
backendRefs:
- name: web
port: 80The timeouts field requires a Gateway API version that includes it, and your implementation must support it.
Handling the gaps
Keep these points in mind:
- Implementation policies are not portable. Switching implementations later means rewriting them.
- Snippets are arbitrary NGINX configuration. Translate what each one does, not its text.
- Security annotations such as
auth-urlandwhitelist-source-rangefail open if you forget them. A missing rate limit or IP allowlist produces no error. Put them on a checklist. - ingress2gateway reports annotations it cannot convert. Treat that output as your gap list.
Exercise
An Ingress has the annotations ssl-redirect, limit-rps and configuration-snippet. Which can you replace with standard Gateway API fields, and what do you do about the others?
Show answer
ssl-redirect becomes a RequestRedirect filter on a route attached to the HTTP listener. limit-rps has no standard field, so use your implementation's rate-limit policy or move limiting to another layer. For configuration-snippet, read what the snippet does. Then use a standard filter if one fits, such as header modification, or an implementation policy. If neither fits, record the gap.