Skip to content

Upstream extension mapping cluster metadata to HTTP headers #15472

@tbarrella

Description

@tbarrella

Title: Upstream extension mapping cluster metadata to HTTP headers

Description:
Something more general than #13897 but lighter than #10455 would be an upstream_config extension that allows injecting HTTP headers based on cluster metadata.

For an example usage other than #13897, consider multiple clusters for the same address but different ports, where the upstream Envoy is listening on one port and an application is listening on multiple other ports. The endpoint addresses for each cluster could use the Envoy port, whereas the metadata for each cluster could contain the corresponding application port. This extension could be configured to use that metadata to add an HTTP header with the application port. Route config in the upstream Envoy would then use the header value to direct the request to the right port.

Cluster config could look like

  load_assignment:
    endpoints:
    - lb_endpoints:
      - endpoint:
          address:
            socket_address:
              address: 10.0.0.1
              port_value: 9900
  metadata:
    filter_metadata:
      envoy.upstreams.http.metadata:
        application_port: 8080
  upstream_config:
    typed_config:
      "@type": type.googleapis.com/envoy.upstreams.http.metadata.v3.MetadataConnectionPoolProto
      headers:
      - name: X-Envoy-Application-Port
        key: application_port

Using a port here is one example, but this could be used for any situation where the upstream server wants information that depends on the cluster used to send the request. A prototype PR for this is lambdai#7. The API could potentially be extended to allow using metadata from the endpoint as well.

Would others find this to be useful? Would it make sense for this repo to contain an extension like this? (Or is there already a way to do this?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/clusterarea/metadatastalestalebot believes this issue/PR has not been touched recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions