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

Run go extension for separate routes only #36669

Open
alex-sorochkin opened this issue Oct 17, 2024 · 2 comments
Open

Run go extension for separate routes only #36669

alex-sorochkin opened this issue Oct 17, 2024 · 2 comments
Labels

Comments

@alex-sorochkin
Copy link

alex-sorochkin commented Oct 17, 2024

Title: Is there an opportunity to run go extensions separately for different routes?

Description:
I'm starting to use Envoy as API GW for my project. I already have some services and now I want to organize routing via that all. Additionally I'd like to use some modules on go, but for separate groups of URLs. So, other URLs shouldn't be processed by modules.
The other issue I want to cover is that I have more than one module, and I don't want them all be executed per each configured route. Other words I want each route be able to configure the list of extensions be executed.
I use envoy.filters.network.http_connection_manager filter but I can't have them more than one in my config.

Is there any chance to solve that?

My config is below. Thanks!

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address:
          protocol: TCP
          address: 0.0.0.0
          port_value: 10000
      filter_chains:
        - filters:
            - name: envoy.filters.network.http_connection_manager
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
                stat_prefix: ingress_http
                route_config:
                  name: local_route
                  virtual_hosts:
                    - name: backend
                      domains:
                        - "*"
                      routes:
                        - match:
                            prefix: "/hallo1"
                          route:
                            cluster: cluster1
#                            want my extension be executed here
                        - match:
                            prefix: "/hallo2"
                          route:
                            cluster: cluster2
#                            DON'T want my extension be executed here
                        - match:
                            prefix: "/"
                          route:
                            cluster: cluster1
                http_filters:
                  - name: envoy.filters.http.golang
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.golang.v3alpha.Config
                      library_id: mypluginid
                      library_path: "/etc/envoy/bin/envoy-gw.so"
                      plugin_name: simple
                      plugin_config:
                        "@type": type.googleapis.com/xds.type.v3.TypedStruct
                        value:
                          prefix_localreply_body: "Configured local reply from go"
                  - name: envoy.filters.http.router
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

  clusters:
    - name: cluster1
      connect_timeout: 30s
      type: STATIC
      dns_lookup_family: V4_ONLY
      lb_policy: ROUND_ROBIN
      load_assignment:
        cluster_name: cluster1
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: "127.0.0.1"
                      port_value: 9091
    - name: cluster2
      connect_timeout: 30s
      type: STATIC
      dns_lookup_family: V4_ONLY
      lb_policy: ROUND_ROBIN
      load_assignment:
        cluster_name: cluster2
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: "127.0.0.1"
                      port_value: 9092

@alex-sorochkin alex-sorochkin added the triage Issue requires triage label Oct 17, 2024
@tyxia tyxia added area/go and removed triage Issue requires triage labels Oct 18, 2024
@tyxia
Copy link
Member

tyxia commented Oct 18, 2024

add @doujiang24 who is Envoy go expert

@doujiang24
Copy link
Member

@alex-sorochkin
Golang filter enabled in the hcm.http_filters level, just like normal Envoy filters.
But it support route level configuration: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/golang_filter#per-route-plugin-configuration

That means each route could have specified Golang filter configuration. This should be what you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants