Skip to main content
In this lesson you’ll inspect an existing NGINX Ingress Controller deployment, review Ingress resources and application services, then update Ingress rules to change public paths and add new application routes (including a cross-namespace application). You will also learn how to use the NGINX rewrite annotation to strip the Ingress path before forwarding requests to backend services. Related reading:

1) Environment overview

First, check the cluster nodes and the workloads currently deployed.
Example output:
No deployments exist in the default namespace for this lab, but several deployments are present in other namespaces:
Example output:
(Adjust commands to match your environment if needed.)

2) Locate the Ingress Controller

List all pods to find the controller:
Look for pods in the ingress-nginx namespace. In this lab the controller deployment is named ingress-nginx-controller.

3) Applications and the existing Ingress resource

Applications run in the app-space namespace. To list all Ingress resources across namespaces:
Example output:
Describe the Ingress to view its rules and backend service mappings:
Example output:
Key points:
  • Ingress name: ingress-wear-watch (namespace app-space).
  • Host is *, so rules apply regardless of hostname.
  • /wear → wear-service:8080
  • /watch → video-service:8080
  • There is a default backend default-http-backend for unmatched requests.

4) Change the video application path from /watch to /stream

Requirement: serve the video app at /stream instead of /watch. Edit the Ingress resource and update the path for the video backend. You can use kubectl edit or apply a manifest. Example (editing in place):
Ensure the spec.rules.http.paths list contains the updated path mapping:
After saving:
  • /wear continues to serve the wear app.
  • /stream now serves the video app.
Validate with curl:

5) Add the food delivery app at /eat

A new food delivery application is now in app-space. Inspect deployments and services:
Example outputs: Deployments:
Services:
Add /eat to the ingress-wear-watch Ingress, targeting food-service:8080. Edit the Ingress and add:
Save and test:
Expect the food delivery application response.

6) Critical payment service deployed in its own namespace

A new payment service is deployed in a separate namespace to improve isolation. Inspect it:
Example outputs: Pods:
Deployment:
Service:
  • Namespace: critical-space
  • Deployment: webapp-pay
  • Service: pay-service, port 8282 (this is the service port; the pod may still be listening on a different targetPort, often 8080).
Best practice: create or manage Ingress resources in the same namespace as the application to avoid cross-namespace access issues and to give teams autonomy over their routes.

7) Create an Ingress for the payment service (/pay)

Create a namespace-scoped Ingress in critical-space to expose /pay:
Verify:
Example describe output right after creation:

8) Troubleshooting 404 responses for /pay

When you first test /pay, the application returned 404. Inspect pod logs to see what path the backend received:
Example log before rewrite:
Cause: the Ingress forwarded the full path /pay to the backend. The pay application expects requests at / (root) and has no route for /pay, hence the 404. Solution: add the NGINX rewrite annotation nginx.ingress.kubernetes.io/rewrite-target: / to the Ingress so the controller rewrites /pay to / before proxying to the backend.
Important: for more advanced rewrites (preserving subpaths or using regex captures) you may need nginx.ingress.kubernetes.io/use-regex: "true" and a regex path with capture groups. Test carefully — annotation behavior can vary across ingress-nginx versions.

9) Add the rewrite annotation and correct pathType

Edit the ingress-pay in critical-space, add the rewrite annotation, and ensure pathType is appropriate (usually Prefix for flexible matching). Example final manifest:
Apply the change with kubectl edit or kubectl apply -f. If you need to preserve subpaths (for example route /pay/foo to /foo on the backend), use a regex path such as /pay/(.*) with nginx.ingress.kubernetes.io/use-regex: "true" and adjust rewrite-target to /$1.

10) Verify the fix

After adding the rewrite, requests to /pay should be rewritten to / and the application should respond with 200. Test and inspect logs:
Example logs after rewrite:
A 200 response confirms the rewrite is functioning and the payment service is exposed at /pay.
Summary checklist Useful links and references

Watch Video

Practice Lab