bjw-s / helm-charts

A collection of Helm charts
https://bjw-s.github.io/helm-charts/
Apache License 2.0
535 stars 100 forks source link

Add support for filters in route.main.rules #224

Closed drzaeus77 closed 8 months ago

drzaeus77 commented 8 months ago

Details

Describe the solution you'd like:

I would like to be able to include a filters section in the route (Gateway API). An example would be something like:

    route:
      main:
        enabled: true
        kind: HTTPRoute
        parentRefs:
           ...
        rules:
          - backendRefs:
              - name: backend1
                port: 3000
          - matches:
              - path:
                  type: PathPrefix
                  value: /api
            backendRefs:
              - name: backend2
                port: 3001
            filters:
              - type: URLRewrite
                urlRewrite:
                  path:
                    type: ReplacePrefixMatch
                    replacePrefixMatch: ""

Currently I am doing the above with a separate HTTPRoute object.

Anything else you would like to add:

I believe the following may be a reasonable patch, but don't have enough helm experience to build and test it.

diff --git a/charts/library/common/templates/classes/_route.tpl b/charts/library/common/templates/classes/_route.tpl
index 77f9d90..7cb92f0 100644
--- a/charts/library/common/templates/classes/_route.tpl
+++ b/charts/library/common/templates/classes/_route.tpl
@@ -74,6 +74,10 @@ spec:
     matches:
         {{- toYaml . | nindent 6 }}
       {{- end }}
+      {{- with .filters }}
+    filters:
+        {{- toYaml . | nindent 6 }}
+      {{- end }}
     {{- end }}
   {{- end }}
 {{- end }}
larivierec commented 8 months ago

i think i could pick this up and fix GRPC at the same time. https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1alpha2.GRPCRoute GRPC also supports match + filters