Sub topic 13
Generating a first draft with ingress2gateway
This chapter assumes you know the Ingress resource, the Gateway, HTTPRoute and ReferenceGrant resources from earlier chapters, and basic kubectl use. You will run ingress2gateway against a namespace, then review what it produced.
What the tool does
ingress2gateway is a command-line tool from the Kubernetes SIG Network project. It reads Ingress resources and the annotations of a specific provider, and prints Gateway API manifests. It does not change your cluster. Treat its output as a draft, not a finished migration.
The tool works in three steps.
- It reads Ingress objects from your cluster or from files.
- It converts the fields it understands into Gateways and HTTPRoutes.
- It prints warnings for annotations it cannot translate.
Running it
The --providers flag selects which annotation set to interpret. Here it is ingress-nginx.
ingress2gateway print --providers ingress-nginx --namespace shop > gateway-draft.yaml
kubectl apply --dry-run=server -f gateway-draft.yaml
kubectl get gateway,httproute -A
kubectl describe httproute app -n shopThe first command writes the draft to a file. The second asks the API server to validate it without saving anything. The last two commands only make sense after you have applied the draft to a test environment. They show the Accepted and ResolvedRefs conditions in each resource's status.
Flags and supported annotations change between releases. Run ingress2gateway print --help and read the project's release notes for your version.
Reviewing the output
Read every generated resource against the original Ingress. These are the usual problems.
| Check | Why it matters |
|---|---|
| `gatewayClassName` | The tool cannot know which implementation you chose. Set it to your class. |
| Warnings on stderr | Each warning names an annotation that was dropped or only partly translated. |
| Namespaces | The Gateway may land in the app namespace. Your platform team may want a shared one. |
| TLS Secrets | The Secret must be in the Gateway's namespace, or you need a ReferenceGrant. |
| Redirects and canaries | Confirm that `ssl-redirect` became a `RequestRedirect` route and that canary weights are correct. |
| Path types | Check that `Prefix` and `Exact` matches kept their meaning. |
A practical workflow
- Export a draft per namespace, not for the whole cluster, so each review stays small.
- Save the warnings to a file and turn each one into a work item, using the mapping approach from the previous chapter.
- Edit the draft by hand. Keep the edited files in version control.
- Apply to a staging cluster and check the status conditions.
Exercise
ingress2gateway prints a draft, and kubectl apply --dry-run=server succeeds. Why can you still not cut production traffic over, and what should you do with the tool's warnings?
Show answer
A dry run only checks that the manifests are valid for the API server. It does not show whether the routes behave like the NGINX setup, since dropped annotations change behavior. Treat each warning as a work item, resolve it by hand or with an implementation-specific feature, then verify the Accepted and ResolvedRefs conditions and test real traffic.