【问题标题】:Generate UUID via Envoy Proxy通过 Envoy 代理生成 UUID
【发布时间】:2021-12-30 12:03:13
【问题描述】:

我正在尝试使用以下特使扩展来关联 x-request-id HTTP 标头中的 uuid

type.googleapis.com/envoy.extensions.request_id.uuid.v3.UuidRequestIdConfig

这是我的工作 yaml,只有一个我通过 envoy 公开的 api

static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 10001
    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: edge
          http_filters:
          - name: envoy.filters.http.router
          route_config:
            virtual_hosts:
            - name: direct_response_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/v1/hello"
                route:
                  cluster: cluster1        
  clusters:
  - name: cluster1
    connect_timeout: 5s
    load_assignment:
      cluster_name: cluster1
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8080

我的问题是在上面的yaml中我在哪里添加uuid生成的扩展

        typed_config:
          "@type": type.googleapis.com/envoy.extensions.request_id.uuid.v3.UuidRequestIdConfig
          pack_trace_reason: false

【问题讨论】:

    标签: envoyproxy


    【解决方案1】:

    您必须将此扩展名放在HttpConnectionManager 配置中(在request_id_extension 下):

    static_resources:
      listeners:
      - address:
          socket_address:
            address: 0.0.0.0
            port_value: 8080
        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
              codec_type: AUTO
              stat_prefix: ingress_http
              request_id_extension:
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.request_id.uuid.v3.UuidRequestIdConfig
                  pack_trace_reason: false
    ...
    

    我在此处的文档中找到了信息:https://www.envoyproxy.io/docs/envoy/v1.21.0/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#extensions-filters-network-http-connection-manager-v3-httpconnectionmanager(在页面中搜索 request_id_extension)。

    此属性在此处的 proto 文件中定义:https://github.com/envoyproxy/envoy/blob/v1.21.0/api/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#L626-L642

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-23
      • 2017-06-25
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多