Skip to main content

Containers and Kubernetes · Advanced · 26 min

Move from Ingress NGINX to the Gateway API

By Padding · Updated 18 Nov 2026
Ubuntu 26.04 · ingress2gateway 1.2.0 · Gateway API 1.7.0 schemas · kubeconform 0.8.0 · Kubernetes 1.37

You will convert a set of annotated Ingress NGINX manifests to Gateway API resources with ingress2gateway, fix by hand what it cannot translate, validate the result against the schemas and switch traffic with a rollback path.

On this page

Ingress NGINX, the controller behind most Kubernetes Ingress setups, reached the end of its best-effort maintenance in March 2026. Clusters that still run it keep serving traffic, but they get no new releases, no bug fixes and no fixes for security problems found from now on. For an internet-facing proxy, that is a deadline, not a suggestion.

That leaves three options. You can keep running it and accept unpatched risk. You can move to a different Ingress controller and keep your Ingress objects, but every nginx.ingress.kubernetes.io/... annotation is specific to Ingress NGINX and has to be rewritten anyway. Or you can move to the Gateway API, which the Kubernetes project recommends. This tutorial takes the third route.

The Gateway API splits what one Ingress used to hold into three kinds of object:

  • A GatewayClass names the controller that does the work, such as Envoy Gateway. A cluster administrator installs it once.
  • A Gateway is the listener: ports, hostnames, certificates and which namespaces may attach routes. The platform team owns it.
  • An HTTPRoute says which paths and headers go to which Service, with filters for redirects, rewrites and traffic splits. The app team owns it.

Features that were annotations, such as rewrites, redirects and weighted canaries, are now typed fields that a schema can check. You will use ingress2gateway, the Kubernetes SIG Network conversion tool, on three realistic Ingresses for a demo shop at shop.example.test: a TLS site, an API with a regex rewrite and a 10% canary. The tool does most of the work. The interesting part is what it gets subtly wrong, and how you prove the hand-finished version is valid before any traffic touches it.

All work happens in ~/ingress-migration-demo. The .test domain is reserved for testing and never resolves on the internet; replace shop.example.test with your own hostname when you migrate your own app.

Step 1 · Install ingress2gateway and kubeconform

Install ingress2gateway 1.2.0 from its GitHub release, and check the download against the published checksums before you put it on your PATH:

Bash
I2G_ARCH="$(uname -m | sed 's/aarch64/arm64/')"
mkdir -p /tmp/i2g && cd /tmp/i2g
curl -fsSLO "https://github.com/kubernetes-sigs/ingress2gateway/releases/download/v1.2.0/ingress2gateway_Linux_${I2G_ARCH}.tar.gz"
curl -fsSLO "https://github.com/kubernetes-sigs/ingress2gateway/releases/download/v1.2.0/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
sudo tar -xzf "ingress2gateway_Linux_${I2G_ARCH}.tar.gz" -C /usr/local/bin ingress2gateway

Then kubeconform 0.8.0, which validates manifests against JSON schemas without a cluster:

Bash
KC_ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')"
curl -fsSL "https://github.com/yannh/kubeconform/releases/download/v0.8.0/kubeconform-linux-${KC_ARCH}.tar.gz" \
  | sudo tar -xz -C /usr/local/bin kubeconform

On macOS, brew install ingress2gateway kubeconform installs both.

Binaries installed this way get no updates from apt. To upgrade, run the same commands with the new version number from each project's releases page.

Check it worked

Bash
ingress2gateway print --help | grep -- '--providers'
kubeconform -v

The first command prints the help line for --providers, the one flag print requires. The second prints v0.8.0.

Step 2 · Collect the Ingresses you are migrating

On your cluster, first find out which IngressClasses Ingress NGINX serves and which Ingresses use them. A controller value of k8s.io/ingress-nginx means Ingress NGINX:

Bash
kubectl get ingressclass -o 'custom-columns=NAME:.metadata.name,CONTROLLER:.spec.controller'
kubectl get ingress -A -o 'custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,CLASS:.spec.ingressClassName,HOSTS:.spec.rules[*].host'

The quotes around each -o argument matter on macOS: zsh, its default shell, treats [*] as a file pattern and stops with no matches found if you leave them out.

For each app you migrate, export its Ingresses to a file with kubectl get ingress -n <namespace> <name> -o yaml. Converting from files rather than straight from the cluster gives you something to review and commit.

For this tutorial, write three Ingresses that cover the annotations people use most. shop-web serves the site over TLS. shop-api sends /api/... to the API with the leading /api stripped, using a regex path and a capture group. shop-web-canary sends 10% of site traffic to a new version:

Bash
mkdir -p ~/ingress-migration-demo/ingress
cat > ~/ingress-migration-demo/ingress/shop.yaml <<'EOF'
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: shop-web
  namespace: shop
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - shop.example.test
      secretName: shop-example-test-tls
  rules:
    - host: shop.example.test
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web
                port:
                  number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: shop-api
  namespace: shop
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - shop.example.test
      secretName: shop-example-test-tls
  rules:
    - host: shop.example.test
      http:
        paths:
          - path: /api(/|$)(.*)
            pathType: ImplementationSpecific
            backend:
              service:
                name: api
                port:
                  number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: shop-web-canary
  namespace: shop
  annotations:
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-weight: "10"
spec:
  ingressClassName: nginx
  rules:
    - host: shop.example.test
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web-v2
                port:
                  number: 80
EOF

Two behaviours hide in these files. Because the Ingresses have a TLS section, Ingress NGINX redirects plain HTTP to HTTPS with a 308 for the whole host; no annotation says so, because ssl-redirect defaults to true. And use-regex applies to every path on the host, across all Ingresses, so / in shop-web is a regex too. Ingress NGINX regex matches are also case-insensitive, so /API/orders reaches the API today.

Write the services' behaviour down before you convert, in your own words: "HTTP redirects to HTTPS with 308; /api/orders reaches the API as /orders; 10% of / goes to web-v2." That list is what you test against at the end.

Check it worked

Bash
cd ~/ingress-migration-demo
kubeconform -strict -summary -kubernetes-version 1.37.3 ingress/shop.yaml

kubeconform ends with a line like Summary: 3 resources found in 1 file - Valid: 3, Invalid: 0, Errors: 0, Skipped: 0. The source files are valid Kubernetes; any problem from here on is in the translation.

Step 3 · Convert the Ingresses with ingress2gateway

Run the converter on the file. --providers=ingress-nginx reads the Ingress NGINX annotations, and with --input-file the tool reads every namespace in the file and never contacts a cluster. It writes the Gateway API objects to standard output and its report of what it changed or skipped to standard error, so keep them in separate files:

Bash
cd ~/ingress-migration-demo
ingress2gateway print --providers=ingress-nginx --input-file ingress/shop.yaml \
  > converted.yaml 2> report.txt
cat report.txt
grep -E '^kind:|^  name:' converted.yaml

The report is a table of notifications grouped by source. Expect at least an info line saying the tool uses case-insensitive regex path matches and that you may want to change this.

Run the converted output through kubeconform as a first sanity check. The Gateway API kinds are CRDs, so kubeconform needs their schemas; point it at the community CRDs catalog, pinned to one commit so the schemas cannot change under you.

The tool also writes an empty status block at the end of each route, and on the redirect route it is parents: null, which the schema rejects because parents must be a list. Status belongs to the controller, not to you, so strip those blocks into a copy before you validate:

Bash
cd ~/ingress-migration-demo
awk '/^status:/ {skip=1; next} /^---/ {skip=0} !skip' converted.yaml > converted-spec.yaml
CATALOG='https://raw.githubusercontent.com/datreeio/CRDs-catalog/30499112dbaf5d3760c0843d4841e52e62dd0233/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'
kubeconform -summary -kubernetes-version 1.37.3 \
  -schema-location default -schema-location "$CATALOG" converted-spec.yaml

Check it worked

converted.yaml holds one Gateway and at least two HTTPRoute objects, and kubeconform reports Invalid: 0 for converted-spec.yaml. The Gateway is named nginx, after the ingress class, and has HTTP and HTTPS listeners for shop.example.test. The routes are named after an Ingress plus the host, something like shop-api-shop-example-test, with a second route ending in -http that holds the redirect.

Valid against the schema is not the same as correct. The next step is reading it.

Step 4 · Read the output against the old behaviour

Open converted.yaml and compare it with the list you wrote. Search for each item:

Bash
cd ~/ingress-migration-demo
grep -n -E 'gatewayClassName|statusCode|weight|type: RegularExpression|value:|URLRewrite' converted.yaml

What the tool got right:

  • Canary. The rule for / has two backendRefs, web with weight: 90 and web-v2 with weight: 10. The tool subtracts canary-weight from canary-weight-total, which defaults to 100.
  • HTTPS redirect. The -http route attaches to port 80 and answers with a RequestRedirect to https, status 308, the same as Ingress NGINX. The main route attaches to the HTTPS listener only.

What needs your hand:

  • The GatewayClass. gatewayClassName: nginx copies the ingress class. Your new controller's class has another name, and there is no GatewayClass object in the output at all.
  • The regex paths. Every path on the host, including /, became a RegularExpression match such as (?i)/.*. That keeps the old case-insensitive behaviour, but regex matching is implementation-specific in the Gateway API: each controller may support a different regex dialect, or none. A plain PathPrefix is portable and faster to evaluate.
  • The rewrite. There is no URLRewrite filter anywhere. rewrite-target: /$2 relies on a regex capture group, which the Gateway API cannot express, so the tool dropped it. Applied as it is, the API would receive /api/orders instead of /orders and answer 404. Check report.txt for a notice about it, and treat a missing notice as no guarantee: always diff behaviour, not just warnings.

Some Ingress NGINX features have no Gateway API field at all, such as configuration-snippet blocks or rate limits. Those move to your controller's own policy resources; Envoy Gateway, for example, has a BackendTrafficPolicy for rate limiting and retries.

Check it worked

You can point at the line in converted.yaml for each behaviour on your list, and you have three items to fix: the class name, the regex matches and the missing rewrite.

Step 5 · Write the finished Gateway and routes

Keep converted.yaml as a record and write the finished objects as new files. They are short enough to own outright, and each one maps to a team.

The platform side, in gateway/gateway.yaml, holds the GatewayClass for Envoy Gateway and a Gateway that reuses the TLS Secret the Ingress already uses. Listeners only accept routes from their own namespace unless you say otherwise:

Bash
mkdir -p ~/ingress-migration-demo/gateway
cat > ~/ingress-migration-demo/gateway/gateway.yaml <<'EOF'
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: envoy
spec:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: shop
  namespace: shop
spec:
  gatewayClassName: envoy
  listeners:
    - name: http
      protocol: HTTP
      port: 80
      hostname: shop.example.test
    - name: https
      protocol: HTTPS
      port: 443
      hostname: shop.example.test
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: shop-example-test-tls
EOF

The app side, in gateway/routes.yaml, has three routes. The redirect route attaches to the http listener by sectionName. The other two attach to https. The API route replaces the regex and capture group with a prefix match plus ReplacePrefixMatch: /, which turns /api/orders into /orders and /api into /, the same result rewrite-target: /$2 gave:

Bash
cat > ~/ingress-migration-demo/gateway/routes.yaml <<'EOF'
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: shop-http-to-https
  namespace: shop
spec:
  parentRefs:
    - name: shop
      sectionName: http
  hostnames:
    - shop.example.test
  rules:
    - filters:
        - type: RequestRedirect
          requestRedirect:
            scheme: https
            statusCode: 308
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: shop-web
  namespace: shop
spec:
  parentRefs:
    - name: shop
      sectionName: https
  hostnames:
    - shop.example.test
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: web
          port: 80
          weight: 90
        - name: web-v2
          port: 80
          weight: 10
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: shop-api
  namespace: shop
spec:
  parentRefs:
    - name: shop
      sectionName: https
  hostnames:
    - shop.example.test
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api
      filters:
        - type: URLRewrite
          urlRewrite:
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /
      backendRefs:
        - name: api
          port: 8080
EOF

Two routes match / and /api on the same hostname. The Gateway API picks the longest matching prefix across routes, so /api/orders goes to the API and everything else to the site. A PathPrefix of /api also matches whole path segments only: /apiary does not reach the API, which matches the old regex /api(/|$).

One behaviour changes on purpose: matching is now case-sensitive, so /API/orders goes to the site, not the API. That is almost always what you want, but search your access logs for upper-case paths before you switch. A 308 keeps the request method, so a POST stays a POST after the redirect; it is an extended feature in the Gateway API, and if your controller does not support it, the route's status says so.

When the canary has done its job, the app team edits two weights in shop-web and nobody touches the Gateway. That separation is the main practical gain over annotations.

Check it worked

Bash
cd ~/ingress-migration-demo
grep -c '^kind:' gateway/gateway.yaml gateway/routes.yaml

You see gateway/gateway.yaml:2 and gateway/routes.yaml:3.

Step 6 · Validate the finished manifests

Validate the files you will apply, this time with -strict, which also rejects fields that do not exist, such as replacePrefixmatch with the wrong capital:

Bash
cd ~/ingress-migration-demo
CATALOG='https://raw.githubusercontent.com/datreeio/CRDs-catalog/30499112dbaf5d3760c0843d4841e52e62dd0233/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'
kubeconform -strict -summary -kubernetes-version 1.37.3 \
  -schema-location default -schema-location "$CATALOG" gateway/

The catalog commit pinned here holds the Gateway API 1.7.0 schemas. Your controller may support an older release; Envoy Gateway 1.10, for example, supports Gateway API 1.6.1. Everything here uses only v1 resources and fields, which are the same in both. The API server and the controller still have the final say once you apply.

Add this command to your CI so a broken route never reaches the cluster; /tutorials/validate-kubernetes-manifests-before-they-reach-a-cluster covers that set-up.

Check it worked

The summary reads Summary: 5 resources found in 2 files - Valid: 5, Invalid: 0, Errors: 0, Skipped: 0. Change replacePrefixMatch to replacePrefixmatch in routes.yaml and run it again: kubeconform reports the HTTPRoute as invalid and names the unknown field. Change it back.

Step 7 · Run both controllers side by side

Ingress NGINX and the Gateway controller can run in the same cluster, each with its own load balancer address, serving the same Services. Nothing changes for users until DNS moves, which makes this the safe point to test.

Install the Gateway API CRDs and Envoy Gateway 1.10 as in the step "Install the Gateway API CRDs and Envoy Gateway" of /tutorials/route-traffic-to-snip-with-the-gateway-api. On a cloud cluster, leave out the kind-specific EnvoyProxy: Envoy Gateway then gets a LoadBalancer Service with its own public address. Then apply the finished files and wait for the Gateway:

Bash
cd ~/ingress-migration-demo
kubectl apply -f gateway/
kubectl wait --for=condition=Programmed gateway/shop -n shop --timeout=180s
kubectl get httproute -n shop

Read both addresses. The service name for Ingress NGINX depends on how it was installed; ingress-nginx-controller in the ingress-nginx namespace is the Helm chart's default:

Bash
NEW_IP="$(kubectl get gateway shop -n shop -o jsonpath='{.status.addresses[0].value}')"
OLD_IP="$(kubectl get svc ingress-nginx-controller -n ingress-nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')"
echo "old=$OLD_IP new=$NEW_IP"

Some clouds publish a hostname instead of an IP. In that case use .hostname in the OLD_IP query, and resolve it with dig +short before passing it to curl.

Test each item on your behaviour list against the new address, without touching DNS. --resolve makes curl connect to that address while still sending your hostname for TLS and the Host header:

Bash
curl -sS -o /dev/null -w '%{http_code} %{redirect_url}\n' \
  --resolve shop.example.test:80:"$NEW_IP" http://shop.example.test/cart
curl -sS -o /dev/null -w '%{http_code}\n' \
  --resolve shop.example.test:443:"$NEW_IP" https://shop.example.test/api/healthz
curl -sS -o /dev/null -w '%{http_code}\n' \
  --resolve shop.example.test:443:"$OLD_IP" https://shop.example.test/api/healthz

Replace /api/healthz with a path your API answers. For the canary, call an endpoint that shows which version answered (replace /version with yours) 200 times and count:

Bash
for i in $(seq 1 200); do
  curl -s --resolve shop.example.test:443:"$NEW_IP" https://shop.example.test/version; echo
done | sort | uniq -c

Check it worked

  • kubectl get httproute -n shop lists shop-http-to-https, shop-web and shop-api. If one is missing from traffic, kubectl describe httproute <name> -n shop shows Accepted and ResolvedRefs under Status; a False names the reason.
  • The redirect test prints 308 https://shop.example.test/cart.
  • The API test prints the same status code through the new and the old address.
  • The canary count is roughly 180 to 20. Over 200 requests it varies by a handful either way.

Step 8 · Switch DNS and retire Ingress NGINX

Lower the TTL on your hostname's DNS record to 300 seconds or less, then wait at least as long as the old TTL before you switch, so resolvers have fetched the short value.

Switch the record to the new address (an A record to NEW_IP, or a CNAME to the load balancer's hostname). Keep Ingress NGINX running. Some ISP and mobile-network resolvers hold records longer than the TTL, so clients can reach the old address for a day or more. Watch the old controller's log until requests for your Services stop.

The default Ingress NGINX access log does not record the Host header, so searching for your hostname finds nothing, or only referers. Each line does end with the upstream it used in square brackets, named <namespace>-<service>-<port>, so search for those: shop-web-80, shop-web-v2-80 and shop-api-8080 here. Read every controller pod, because deployment/... picks just one. With a label selector, kubectl logs also shows only the last 10 lines of each pod unless you pass --tail=-1, even with --since; on a controller that serves other hosts too, those 10 lines can all belong to other upstreams and the count reads 0 too early:

Bash
dig +short shop.example.test @1.1.1.1
kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx,app.kubernetes.io/component=controller \
  --since=10m --tail=-1 --prefix \
  | grep -cE '\[shop-(web|web-v2)-80\]|\[shop-api-8080\]'

The rollback while both run is one DNS change back to OLD_IP. Decide in advance what would trigger it, such as a rise in 5xx responses on the new Gateway.

Before you delete the Ingresses, check how the TLS certificate is managed. If the Ingress has a cert-manager.io/cluster-issuer or cert-manager.io/issuer annotation, cert-manager created the Certificate for it and made the Ingress its owner. Deleting the Ingress then deletes the Certificate, and renewals stop silently. cert-manager names that Certificate after the Secret, so applying a new Certificate called shop-example-test-tls only edits the existing one and leaves the Ingress as its owner. Look for it first:

Bash
kubectl get certificate -n shop -o 'custom-columns=NAME:.metadata.name,OWNER:.metadata.ownerReferences[*].kind'

If OWNER shows Ingress, take the Certificate away from the Ingress in two moves. First remove the cert-manager annotation from every Ingress that names the Secret, so cert-manager stops managing a Certificate for them (use issuer instead of cluster-issuer if that is the one you have; the trailing - removes it). Then remove the owner reference from the Certificate, so deleting the Ingress no longer deletes it:

Bash
kubectl annotate ingress shop-web shop-api -n shop cert-manager.io/cluster-issuer-
kubectl patch certificate shop-example-test-tls -n shop --type=json \
  -p '[{"op":"remove","path":"/metadata/ownerReferences"}]'
kubectl get certificate -n shop -o 'custom-columns=NAME:.metadata.name,OWNER:.metadata.ownerReferences[*].kind'
kubectl get certificate shop-example-test-tls -n shop

The first of the last two commands now shows <none> under OWNER, and the second shows True under READY. The Certificate keeps its issuer and renews on its own, and the Gateway keeps reading the same Secret. If you would rather have cert-manager manage the certificate from the Gateway, as /tutorials/route-traffic-to-snip-with-the-gateway-api does, add the issuer annotation to the Gateway instead; that needs cert-manager's Gateway API support turned on.

Once the old controller has had no traffic for your host for a day or two, delete the Ingresses. This removes routing through Ingress NGINX for those hosts, so be sure DNS has moved:

Bash
kubectl delete ingress shop-web shop-api shop-web-canary -n shop

When no Ingress uses the nginx class any more, uninstall the controller. If you installed it with Helm:

Bash
helm uninstall ingress-nginx -n ingress-nginx

The demo folder only holds the files from this tutorial. Commit gateway/ to your app's repository first if you want to keep it, then remove the folder and the downloads:

Bash
rm -rf ~/ingress-migration-demo /tmp/i2g

Check it worked

  • dig returns the new address from more than one public resolver.
  • The count of log lines for your three upstreams drops to 0 over successive checks.
  • kubectl get ingress -n shop prints No resources found in shop namespace., and kubectl get gateway shop -n shop still shows PROGRAMMED True.
  • kubectl get certificate -n shop still lists a Certificate for shop-example-test-tls, with no Ingress as owner.

Next steps

  • /tutorials/route-traffic-to-snip-with-the-gateway-api: build a Gateway from scratch with Envoy Gateway and cert-manager issuing the certificate.
  • /tutorials/validate-kubernetes-manifests-before-they-reach-a-cluster: run kubeconform in CI on every change to your routes.
  • /tutorials/choose-a-kubernetes-service-type: why the Gateway gets a LoadBalancer on a cloud and a NodePort on a local cluster.

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Platform Engineering

Get new tutorials

New tutorials, about twice a month.