With the latest news of the Ingress NGINX Controller migration, thousands of engineers are attempting to figure out how they can migrate to Gateway API, the new standard for gateway traffic to various applications running within Kubernetes. Because teams could have hundreds or more Ingress manifests using the Controller, a method of turning those manifests into Gateway API core and implementation-specific objects is necessary.
In this blog post, you’ll learn a bit about the “why” behind the deprecation and how to migrate your Ingress NGINX configurations.
Why The Deprecation?
When Kubernetes first came out, there was a need to show an example of how to manage ingress traffic. Because of that, Ingress NGINX was created. However, because of its breadth of usage and support across the various cloud providers, it ended up becoming a standard. Since the standard was created, there were still only a handful of people working on maintenance and new features around Ingress NGINX.
Implementing Ingress2gateway Via Kgateway
With what you’ve learned so far throughout this blog post regarding the Ingress NGINX retirement, you may be thinking to yourself, “Alright, so how do I keep the lights on and remove the Controller?”
The answer is by migrating to Gateway API.
But because that would be incredibly cumbersome to do manually, you can use the Ingress2gateway migration tool. Since Gateway API was designed to be extensible, migrating most production use cases also requires implementation-specific objects. For example, migrating an Ingress with the “nginx.ingress.kubernetes.io/auth-type: basic” annotation requires an implementation-specific object such as kgateway’s TrafficPolicy.
</svg>Note</p>
Technically, you can keep the underlying Ingress object and change the ingressClassName. Why not just do that? Because the Kubernetes project is moving toward Gateway API. In short, there’s no reason to migrate to something that’s considered deprecated by the community. If you just rename the Ingress objects, you’re creating more tech debt for yourself down the road when you eventually have to migrate.
</div>
In the next two sections, you’ll first deploy an object with Ingress NGINX into your Kubernetes cluster and then you’ll learn how to migrate it to kgateway , a conformant Gateway API implementation .
Using The Migration Tool
The first step is to download the migration tool. You can find the installation options for your Operating System in the docs here .
You can verify that the command works by running the build/binary, as in the following output.
With the binary, you can use the print command with the providers and emitter flags to do the following:
Specify that you want the source to be the Ingress NGINX Controller.
Choose what you want to migrate to (the “emitter”), which in this case is kgateway using the standard from Kubernetes Gateway API CRDs (kgateway is the current supported implementation in this downstream fork).
Convert the source objects to Kubernetes Gateway API objects that work with the chosen emitter.
For example, to print the Kubernetes objects that the conversion produces, run the following command.
Next, you’ll find three key use cases that many organizations deploy within production environments and how to convert them with ingress2gateway.
Deploying Ingress NGINX Implementations
In this section, you’ll cover three key scenarios that many production-level environments use:
TLS/SSL
Auth
CORS
The goal with the three test cases is to ensure that the ingress2gateway tool works as expected for various use cases depending on your environment.
Deployment Setup
Deploy a test application, which is only a simple HTTP service. It runs in a Kubernetes Deployment and has a Kubernetes Service.
Use Case 1: TLS/SSL
Create certs for testing.
Create a new Kubernetes secret for TLS certs.
Apply the Ingress configuration.
</svg>Note</p>
Notice the annotation that specifies which control plane/gateway you’re switching to. The reason is to ensure that the Gateway object you’re planning on using is supported and works as expected—using the Kubernetes Gateway API CRDs allows you to stay as agnostic as possible.
</div>
</li>
Run the ingress2gateway tool. You should see output similar to the following.
</ol>
Functional Tests
Apply the new objects that were printed above.
Verify the Gateway is accepted.
Ensure that the HTTP Routes are attached.
Get the IP address of the Gateway.
Test the HTTP redirect (should return a 301).
Test the HTTPS route.
Test
Result
Gateway accepted
True
HTTPRoutes attached
Both True
HTTP redirect
301 to https://api.example.com/
HTTPS route
Returns httpbin.org page from backend
Use Case 2: Auth
Create a username and password (the secret is stored in a Kubernetes secret).
Apply the Ingress configuration.
Use the ingress2gateway tool to convert it.
You should see output similar to the following.
Functional Tests
Create a basic-auth secret.
Apply the new converted objects.
Verify the Gateway is accepted.
Ensure the HTTP route is attached.
Get the Gateway IP.
Test without auth. This should fail with a 401.
Test with auth.
Test
Result
Gateway accepted
True
HTTPRoute attached
True
TrafficPolicy attached
True
Request without auth
401 Unauthorized
Request with valid auth (admin:testpass123)
200 OK
Use Case 3: CORS
Apply the Ingress configuration below.
Run the ingress2gateway tool.
You should see output similar to the following.
Functional Tests
Apply the new converted objects.
Verify the Gateway is accepted.
Confirm the HTTP route is attached.
Capture the Gateway IP.
Test the CORS preflight request. A 200 is expected.
Test with a disallowed origin.
Test with an allowed origin.
Test
Result
Gateway accepted
True
HTTPRoutes attached
Both True
Policies attached
Both True
CORS Tests
Test
Result
Preflight with allowed origin (https://app.example.com )
200 OK with correct CORS headers
Preflight with disallowed origin
Passed through to backend (see note below)
Basic Auth Tests
Test
Result
Request without credentials
401 Unauthorized
Request with valid credentials (admin:testpass123)
200 OK
Conclusion
As with all technology stacks, new pieces of the puzzle get released and sometimes replace existing implementations. Because of the maintenance needs around Ingress NGINX—it was hard to troubleshoot, difficult to standardize across projects, and only a handful of people were working on it—the new standard, Kubernetes Gateway API, was released with the goal of being an agnostic CRD to work with any vendor and any gateway. The concern with that was there was no clear migration step as thousands of engineers were using Ingress NGINX, so a tool to move from that to the new Kubernetes Gateway API standard was necessary. The specifications in this tool (emitter design and initial implementation) have recently moved to the upstream ingress2gateway project as well. In this blog post, you learned how to perform the migration on an object using the Ingress NGINX Controller to the new Gateway API standard.
Keep in Touch
If you have any questions or just want to learn more about kgateway, feel free to reach out to us on in the #kgateway channel in the CNCF Slack or our community meetings ! There is a vibrant, open-source community in both places with people eager to chat and learn.