There are two possible solutions that can resolve this issue by either modifying the Ingress behavior or providing a workaround at the service level.
When I was working on migration projects recently, I encountered an unexpected issue related to theGKE (Google Kubernetes Engine) Ingress controller. Specifically, I found that the GKE Ingress controllerdoesn’t support URL path overwriting. Let me explain the issue with an example and walk you through the challenges it caused during my debugging process.
Suppose you have a GKE Ingress controller with different URL path mappings for several services in your cluster. For instance:
In a typical setup, when a user makes a request to the Ingress controller, it forwards that request to the correct service. However, rather than forwarding it to the root of the service (e.g., http://service_IP/), the Ingress controller includes the original path in the forwarding request (e.g., http://service_IP/customer).
This means that the application behind each service needs to be aware of the incoming path. For example, if the service receives a request at /customer, it should handle it accordingly. If the application expects the request at the root level (i.e., /), this mismatch becomes problematic.
The real trouble arose during the health check configuration. In Kubernetes, each service typically has a health probe configured at the root path (e.g., /health or /).
There are two possible solutions that can resolve this issue by either modifying the Ingress behavior or providing a workaround at the service level.
One solution to handle URL path overwriting correctly is to install the NGINX Ingress controller, which supports path rewriting. With path rewriting, the NGINX Ingress controller can remove or modify the path before forwarding the request to the backend service. This way, the service can receive the request at the root path, as expected.
This allows your backend services to handle health checks at the root path, without worrying about the path forwarding behavior of the Ingress controller.
Another option is to install Istio and define VirtualServices for each service. Istio provides a more advanced service mesh that allows for flexible routing and path forwarding behavior. You can define rules to ensure that when a request comes in with a specific path, Istio can either rewrite the path or direct traffic to the appropriate service in a way that aligns with your service’s expected URL structure.
This approach gives you more control over how traffic is routed within your cluster and can be useful if you need more advanced features such as retries, timeouts, or traffic mirroring in addition to path forwarding.
This diagram illustrates the three scenarios:
Solution 1: NGINX Ingress Controller:
Solution 2: Istio VirtualService:
Full article : https://medium.com/devops-dev/challenges-with-url-path-forwarding-in-gke-ingress-controller-c175057a...
follow me on Medium : https://medium.com/@rasvihostings