1
votes

I have an Ingress file which contains only one annotation:

---
  apiVersion: "extensions/v1beta1"
  kind: "Ingress"
  metadata: 
    name: "logging-microservice-ingress"
    namespace: "000000001"
    annotations:
      nginx.ingress.kubernetes.io/rewrite-target: /
  spec: 
    rules: 
      - 
        host: "ms-shared-nad.techmahindra.com"
        http: 
          paths: 
            - 
              backend: 
                serviceName: "logging-microservice-000000001"
                servicePort: 3000
              path: "/logging-microservice"

When I call https://example.com/logging-microservice/logs backend service generates,

GET /logs --> 200

When I added two more annotations like

  nginx.ingress.kubernetes.io/limit-connections: 1
  nginx.ingress.kubernetes.io/limit-rps: 1

backend gives

GET /logging-microservice/logs --> 404

I don't have access to see the actual nginx configuration being generated there. But, wondering how applying rate limiting can alter the rewrite base.

I have tried rate limiting in open source nginx server and it works as expected. What could be the change to remove path from the url which is passed to the upstream api backend?


Update :

I have accessed the cluster and record the changes happening:

location ~* "^/logging-microservice" {
    rewrite "(?i)/logging-microservice" / break;
}
location ~* "^/" {
}

is changing to

location /logging-microservice {

}
location / {
}

when rate limiting annotations are added.


1

1 Answers

0
votes

Even if you were given with Ingress.yaml with

nginx.ingress.kubernetes.io/rewrite-target: /

and everything was working fine, you need it like

nginx.ingress.kubernetes.io/rewrite-target: "/"

Other thing is, order of annotations matters;

it can't be :

  nginx.ingress.kubernetes.io/rewrite-target: "/"
  nginx.ingress.kubernetes.io/limit-connections: "1"
  nginx.ingress.kubernetes.io/limit-rps: "1"

it should be :

  nginx.ingress.kubernetes.io/limit-connections: "1"
  nginx.ingress.kubernetes.io/limit-rps: "1"
  nginx.ingress.kubernetes.io/rewrite-target: "/"

learned the hard way!