envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.27k stars 4.69k forks source link

xds: support lookup by alias in dynamic extensions #28411

Open kyessenov opened 11 months ago

kyessenov commented 11 months ago

xDS resource aliases appear to be ignored when using Lua, Wasm, and other dynamic extensions. That restricts the ability to modify the cluster names, which are usually internal to the control plane infrastructure.

Example:

#  lua.yaml
node:
  id: test
  cluster: test
static_resources:
  listeners:
  - name: main
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 8000
    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
          codec_type: AUTO
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/"
                direct_response:
                  status: 200
                  body:
                    inline_string: "Hello\n"

          http_filters:
          - name: lua1
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
              default_source_code:
                inline_string:
                  function envoy_on_response(response_handle)
                    response_handle:headers():add("foo", "bar")
                    local headers, body = response_handle:httpCall(
                      "lua_cluster",
                      {
                        [":method"] = "GET",
                        [":path"] = "/",
                        [":authority"] = "lua_cluster"
                      },
                      "hello world",
                      1000)
                    response_handle:headers():add("fortio", headers["date"])
                  end
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
dynamic_resources:
  cds_config:
    path_config_source:
      path: lua_cluster.yaml
# lua_cluster.yaml
resources:
- "@type": type.googleapis.com/envoy.service.discovery.v3.Resource
  name: cluster_0
  aliases: ["lua_cluster"]
  resource:
    "@type": type.googleapis.com/envoy.config.cluster.v3.Cluster
    connect_timeout: 1s
    name: cluster_0
    load_assignment:
      cluster_name: cluster_0
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8080
github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

kyessenov commented 10 months ago

not stale, CC @adisuissa fyi.

adisuissa commented 10 months ago

I think aliases are only being supported in VHDS at the moment.

This can probably be solved as part of the xDS-Manager design, but at the moment there are higher priority items.

kyessenov commented 10 months ago

xDS spec is not marking this field as unimplemented, so it should be supported by xDS client in Envoy I imagine (if not, we need to mark it as such). This issue is mostly about propagating the aliases from xDS client to cluster manager in Envoy (to support a cluster lookup by alias).