origin icon indicating copy to clipboard operation
origin copied to clipboard

Openshift Route - missing path rewrite feature

Open marouim opened this issue 8 years ago • 17 comments

Here is my use case: Front-end application running in a POD. Back-end running in a différent POD.

Route are: myapp.example.com/ --> Front-end myapp.example.com/api --> Back-end

I would like to be able to rewrite the path and remove the "/api" portion, so the Backend would not see this path. Otherwise, I have to tell evey backend developer to add a "/api" or something else prefix to their application.

Just like proxyTable in webpack:

proxyTable: { '/api': { target: 'http://localhost:3000', changeOrigin: true, pathRewrite: { '^/api': '' }, }

Suggestion ===================

apiVersion: v1
  kind: Route
  metadata:
    labels:
      name: my-app-route
    name: my-app-route
  spec:
    host: my-app.cloudapps.example.com
    path: /api/kipos
    rewrite: /                  <======= would be nice to tell reverse proxy to remove the path
    port:
      targetPort: flaskapi
    to:
      kind: Service
      name: my-app-svc
      weight: 100
    wildcardPolicy: None
    tls:
      termination: edge

Thanks for your help !

marouim avatar Jul 30 '18 19:07 marouim

@openshift/sig-networking

enj avatar Jul 30 '18 20:07 enj

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-merge-robot avatar Oct 28 '18 22:10 openshift-merge-robot

/remove-lifecycle stale

pmeyer34 avatar Oct 29 '18 07:10 pmeyer34

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Jan 27 '19 09:01 openshift-bot

/remove-lifecycle stale

devops-42 avatar Feb 06 '19 10:02 devops-42

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Jul 12 '19 21:07 openshift-bot

/remove-lifecycle stale

devops-42 avatar Jul 17 '19 20:07 devops-42

/remove-sig networking /sig network-edge

danwinship avatar Aug 19 '19 14:08 danwinship

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Nov 17 '19 17:11 openshift-bot

/remove-lifecycle stale

devops-42 avatar Nov 17 '19 18:11 devops-42

I've now seen @marouim 's request at least three times here and two of the issues were closed due to inactivity. I don't understand why this happened, as path rewriting is a quite common thing in web servers. @ironcladlou can anyone of the openshift team please give a statement on this? Even if it isn't planned in the far future?

Gerrit-K avatar Jan 10 '20 11:01 Gerrit-K

IMO it's highly unlikely we're going to expand the Route API in this way. At this point I think we'd actually like to deprecate Route entirely and start converging with the upstream around the proposed Kubernetes Ingress V2 API. You'll find that the rewriting use case is already accounted for there.

I'd recommend becoming familiar with the upstream plans and engaging with us and the emerging community to ensure the plans align with your needs.

All that said, if you want to continue proposing the enhancement to Route, I would recommend opening an OpenShift enhancement proposal to bring the discussion to a resolution one way or another. If the proposal were in extremely close alignment with the Ingress V2 API and if there were someone willing to own the work from start to finish, I think that could increase the chances of acceptance, but that's just my opinion.

ironcladlou avatar Jan 10 '20 14:01 ironcladlou

Thank you for the quick and detailed response. The plan to converge to upstream is good news!

Gerrit-K avatar Jan 10 '20 17:01 Gerrit-K

I've been thinking about this some more.

The beta v1 Ingress API doesn't support rewriting, but users are loudly encouraged to use vendor annotations. It's clearly useful and we wouldn't be out of alignment with what's being actually used today in the community.

If we have a reasonable confidence of a lossless migration to Ingress v2, what other major risks are there to adding this API?

cc @frobware @Miciah @danehans @knobunc @smarterclayton

ironcladlou avatar Jan 10 '20 17:01 ironcladlou

Could we add this as a annotation like proposed by the upstream kubernetes documentation? I see that haproxy already has a rewrite annotation[1] for 0.10, can't we use the same as we're using haproxy already?

I've been searching way too much around this subject. Where could I find news regarding that design and/or ingress news ? Any way to relaunch the discussion?

[1] https://haproxy-ingress.github.io/docs/configuration/keys/

elafontaine avatar Mar 18 '20 18:03 elafontaine

I have this issue too.

Something like haproxy.router.openshift.io/rewrite-target: / would be helpful.

sachsenhofer avatar May 10 '20 15:05 sachsenhofer

I've opened a PR https://github.com/openshift/router/pull/129

There is also an enhancement opened to get this support: https://github.com/openshift/enhancements/pull/287

Documentation: https://github.com/openshift/openshift-docs/pull/22021

haproxy-router image to play with it: quay.io/fbenoit/haproxy-rewrite-annotation:2020.05.12

benoitf avatar May 12 '20 12:05 benoitf