Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Literal Rewrite flag for Ingress Nginx #188

Open
kylehodgetts opened this issue Nov 8, 2021 · 0 comments
Open

Literal Rewrite flag for Ingress Nginx #188

kylehodgetts opened this issue Nov 8, 2021 · 0 comments

Comments

@kylehodgetts
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently ingress nginx only supports the ability to trim a path prefix before passing the request onto the service. It would be nice to be able to completely rewrite the entire base path with a literal value before passing the request onto the service

** how it compares to trim prefix **
Currently:

openapi: 3.0.1
x-kusk:
  namespace: my-namespace
  service:
    name: webapp
    namespace: my-service-namespace
    port: 7000
  path:
    base: /my-app
    trim_prefix: /my-app
paths:
  /:
    get: {}
...

will result in

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  creationTimestamp: null
  name: webapp-ingress
  namespace: my-namespace
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - backend:
              service:
                name: webapp
                port:
                  number: 7000
            path: /my-app(/|$)(.*)
            pathType: Prefix
status:
  loadBalancer: {}

Rewrite with literal should look like this as per the documentation https://kubernetes.github.io/ingress-nginx/examples/rewrite/#app-root:

openapi: 3.0.1
x-kusk:
  namespace: my-namespace
  service:
    name: webapp
    namespace: my-service-namespace
    port: 7000
  path:
    base: /my-app
    rewrite_base: /other-app-path
paths:
  /:
    get: {}
...

which should result in the following:

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /my-other-app-path
  creationTimestamp: null
  name: webapp-ingress
  namespace: my-namespace
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - backend:
              service:
                name: webapp
                port:
                  number: 7000
            path: /my-app
            pathType: Prefix
status:
  loadBalancer: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant