Giter Club home page Giter Club logo

Comments (10)

zeusro avatar zeusro commented on June 7, 2024 2
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    konghq.com/strip-path: "true"    
    kubernetes.io/ingress.class: kong    
spec:
  rules:
  - host: my.host.local
    http:
      paths:
      - path: /sample/
        backend:
          serviceName: my-svc
          servicePort: 80

from kubernetes-ingress-controller.

meonthewire avatar meonthewire commented on June 7, 2024 1

Hi @hbagdi

When I call this url http://my.host.local/sample the path /sample is sent to upstream service. This is a expected behavior for kong-ingress? I expected that the path will not sent to upstream service.

curl --header "Host: my.host.local" http://200.x.x.x/sample -vvv
*   Trying 200.x.x.x...
* TCP_NODELAY set
* Connected to 200.x.x.x (200.x.x.x) port 80 (#0)
> GET /sample HTTP/1.1
> Host: my.host.local
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=UTF-8
< Content-Length: 0
< Connection: keep-alive
< X-Powered-By: Sails <sailsjs.org>
< Date: Fri, 10 Aug 2018 14:10:15 GMT
< X-Kong-Upstream-Latency: 2
< X-Kong-Proxy-Latency: 0
< Via: kong/0.13.1
< 
* Connection #0 to host 200.x.x.x left intact

from kubernetes-ingress-controller.

hbagdi avatar hbagdi commented on June 7, 2024

Hello @Lmorais,

What you're seeing is an expected behavior.
The annotation you're using is supported by ingress-nginx but not by Kong Ingress Controller.

Kong by default will strip the path for you so you don't need to add that annotation to your Ingress resource.

Thank you for opening this issue.

from kubernetes-ingress-controller.

hbagdi avatar hbagdi commented on June 7, 2024

I'm not sure if I see upstream being sent /sample in the cURL output you've posted above. It seems like Kong is proxying the request (Via header).

Do you see a log in your service which says that it received /sample?
Is there an echo endpoint in your upstream service which could be handy for your debugging?

from kubernetes-ingress-controller.

andrewtappert avatar andrewtappert commented on June 7, 2024

I'm having the same problem. I do see in my upstream service logs that the path is not being stripped, and when I query the Kong Admin API for the route created for the ingress, I see that strip_path is false.

from kubernetes-ingress-controller.

andrewtappert avatar andrewtappert commented on June 7, 2024

@Lmorais @hbagdi As mentioned above, I found that strip_path was not being set by default (v0.0.5). I achieved a request path rewrite by creating a KongIngress, like so:

apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: echo-ingress
route:
  strip_path: true

...corresponding to this ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: echo-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: foo.bar
    http:
      paths:
      - path: /echo
        backend:
          serviceName: echo-service
          servicePort: 8080

That takes care of the rewrite, although I found that that if the ingress already exists, it must be deleted and re-created to pick up the config from the KongIngress, per #56 (comment)

Note, though, that I haven't got this extremely basic example working without specifying a host, which I don't actual want to do. (#84)

from kubernetes-ingress-controller.

hbagdi avatar hbagdi commented on June 7, 2024

Hello @andrewtappert

That takes care of the rewrite, although I found that that if the ingress already exists, it must be deleted and re-created to pick up the config from the KongIngress, per #56 (comment)

This should not be required with Ingress controller 0.1.0. This bug was fixed in #92

It seems like the ingress controller is creating routes with strip_path set to false by default, in which case, as you figured out, you will need to use KongIngress resource to set it to false.

from kubernetes-ingress-controller.

volver-13 avatar volver-13 commented on June 7, 2024

Hi @hbagdi
ingress controller version: 0.2.2
strip_path is set to false for any created rules, is that expected?

from kubernetes-ingress-controller.

zarelit avatar zarelit commented on June 7, 2024

strip_path is now false by default, since KIC 0.8.0

from kubernetes-ingress-controller.

narongsaky avatar narongsaky commented on June 7, 2024
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    konghq.com/strip-path: "true"    
    kubernetes.io/ingress.class: kong    
spec:
  rules:
  - host: my.host.local
    http:
      paths:
      - path: /sample/
        backend:
          serviceName: my-svc
          servicePort: 80

This solution work for me, thanks.

from kubernetes-ingress-controller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.