2

I'm trying to setup a simple ingress with path rewriting to pass requests to my backend services.

Ref.: https://haproxy-ingress.github.io/v0.10/docs/configuration/keys/#rewrite-target

The ingress controller uses this image: quay.io/jcmoraisjr/haproxy-ingress:v0.10-beta.1.

Here is sample YAML:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: "myapp-apis-ingress"
  namespace: "my-namespace"
  labels:
    app: myapp
    tier: ingress
  annotations:
    kubernetes.io/ingress.class: "haproxy"
    haproxy.org/rewrite-target: "/"
spec:
  rules:
    - host: "myapp.mydomain"
      http:
        paths:
          - path: /api/v1/hello
            pathType: Prefix
            backend:
              service:
                name: "myapp-hello-svc"
                port:
                  number: 8080

Expected behaviour:

  • It should route requests from https://myapp.mydomain/api/v1/hello/* to the GKE service at myapp-hello-svc:8080/*

Actual behaviour:

  • It routes everything to myapp-hello-svc:8080/api/v1/hello/* (myapp-hello-svc pod receives GET /api/v1/hello/*

I've tried some other combinations and rules, but none seemed working neither.

Any ideas what I may have missed here? Thanks!

UPDATE: WORKAROUND

As currently I still can't find solution to this, I decided to use workaround by adding NGINX ingress controller to K8S cluster and routing the traffic for new APIs through it instead.

Chakrit W
  • 322
  • 3
  • 11
  • 2
    Do you have other Ingresses applied? Checking the bugs, I found this which could be the problem https://github.com/jcmoraisjr/haproxy-ingress/issues/773 – AndD Dec 22 '21 at 14:13
  • Yea, I am trying to work with this rewrite controller and it is difficult. Can you explain how you checked down the actual request? – Christian Matthew Sep 13 '22 at 17:30
  • @Christian Matthew I checked in GKE Ingress/Load Balancer logs. – Chakrit W Sep 20 '22 at 10:00

0 Answers0