1) Environment overview
First, check the cluster nodes and the workloads currently deployed.default namespace for this lab, but several deployments are present in other namespaces:
2) Locate the Ingress Controller
List all pods to find the controller:ingress-nginx namespace. In this lab the controller deployment is named ingress-nginx-controller.
3) Applications and the existing Ingress resource
Applications run in theapp-space namespace. To list all Ingress resources across namespaces:
- Ingress name:
ingress-wear-watch(namespaceapp-space). - Host is
*, so rules apply regardless of hostname. /wear→wear-service:8080/watch→video-service:8080- There is a default backend
default-http-backendfor 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):
spec.rules.http.paths list contains the updated path mapping:
/wearcontinues to serve the wear app./streamnow serves the video app.
5) Add the food delivery app at /eat
A new food delivery application is now inapp-space. Inspect deployments and services:
/eat to the ingress-wear-watch Ingress, targeting food-service:8080. Edit the Ingress and add:
6) Critical payment service deployed in its own namespace
A new payment service is deployed in a separate namespace to improve isolation. Inspect it:- Namespace:
critical-space - Deployment:
webapp-pay - Service:
pay-service, port8282(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 incritical-space to expose /pay:
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:
/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 theingress-pay in critical-space, add the rewrite annotation, and ensure pathType is appropriate (usually Prefix for flexible matching). Example final manifest:
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:
/pay.
Summary checklist
Useful links and references