higress-group/higress

dubbo-zk http转换dubbo协议如何配置

开放

#288 创建于 2023年4月12日

 (31 条评论) (0 个反应) (1 位负责人)Go (1,219 个派生)github user discovery
area/dubbogood first issuesig/controller

仓库指标

星标
 (9,036 个星标)
PR 合并指标
 (平均合并 7天 9小时) (30 天内合并 18 个 PR)

描述

#基础配置

McpBridge

apiVersion: networking.higress.io/v1
kind: McpBridge
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.higress.io/v1","kind":"McpBridge","metadata":{"annotations":{},"name":"zk-mcp","namespace":"test"},"spec":{"registries":[{"domain":"10.96.215.94","name":"zk-service","port":2181,"type":"zookeeper"}]}}
  creationTimestamp: "2023-04-11T15:53:23Z"
  generation: 2
  name: zk-mcp
  namespace: test
  resourceVersion: "86389435"
  uid: 6694a922-499d-42f0-a48d-57ac8b97d7e9
spec:
  registries:
  - domain: 10.96.215.94
    name: zookeeper
    port: 2181
    type: zookeeper

Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    higress.io/destination: providers:com.xkcoding.dubbo.common.service.HelloService:1.0.0:dev
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{"higress.io/destination":"providers:com.xkcoding.dubbo.common.service.HelloService:1.0.0:dev"},"name":"demo","namespace":"test"},"spec":{"ingressClassName":"higress","rules":[{"http":{"paths":[{"backend":{"resource":{"apiGroup":"networking.higress.io","kind":"McpBridge","name":"zk-mcp"}},"path":"/dubbo","pathType":"Prefix"}]}}]}}
  creationTimestamp: "2023-04-11T16:04:01Z"
  generation: 2
  name: demo
  namespace: test
  resourceVersion: "85545498"
  uid: 56b1f7e8-5c12-42c6-9e3c-8d8e129bd5fc
spec:
  ingressClassName: higress
  rules:
  - http:
      paths:
      - backend:
          resource:
            apiGroup: networking.higress.io
            kind: McpBridge
            name: zk-mcp
        path: /dubbo
        pathType: Prefix
status:
  loadBalancer: {}、

EnvoyFilter

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.istio.io/v1alpha3","kind":"EnvoyFilter","metadata":{"annotations":{},"name":"http-dubbo-transcoder-test","namespace":"test"},"spec":{"configPatches":[{"applyTo":"HTTP_FILTER","match":{"context":"GATEWAY","listener":{"filterChain":{"filter":{"name":"envoy.filters.network.http_connection_manager","subFilter":{"name":"envoy.filters.http.router"}}}}},"patch":{"operation":"INSERT_BEFORE","value":{"name":"envoy.filters.http.http_dubbo_transcoder","typed_config":{"@type":"type.googleapis.com/udpa.type.v1.TypedStruct","type_url":"type.googleapis.com/envoy.extensions.filters.http.http_dubbo_transcoder.v3.HttpDubboTranscoder"}}}},{"applyTo":"HTTP_ROUTE","match":{"context":"GATEWAY","routeConfiguration":{"vhost":{"route":{"name":"test"}}}},"patch":{"operation":"MERGE","value":{"route":{"upgrade_configs":[{"connect_config":{"allow_post":true},"upgrade_type":"CONNECT"}]},"typed_per_filter_config":{"envoy.filters.http.http_dubbo_transcoder":{"@type":"type.googleapis.com/udpa.type.v1.TypedStruct","type_url":"type.googleapis.com/envoy.extensions.filters.http.http_dubbo_transcoder.v3.HttpDubboTranscoder","value":{"request_validation_options":{"reject_unknown_method":true,"reject_unknown_query_parameters":true},"services_mapping":[{"group":"dev","method_mapping":[{"name":"sayName","parameter_mapping":[{"extract_key":"name","extract_key_spec":"ALL_QUERY_PARAMETER","mapping_type":"java.lang.String"}],"passthrough_setting":{"passthrough_all_headers":true},"path_matcher":{"match_http_method_spec":"ALL_GET","match_pattern":"/dubbo/hello"}}],"name":"com.xkcoding.dubbo.common.service.HelloService","version":"1.0.0"}],"url_unescape_spec":"ALL_CHARACTERS_EXCEPT_RESERVED"}}}}}},{"applyTo":"CLUSTER","match":{"cluster":{"service":"dubbo.static"},"context":"GATEWAY"},"patch":{"operation":"MERGE","value":{"upstream_config":{"name":"envoy.upstreams.http.dubbo_tcp","typed_config":{"@type":"type.googleapis.com/udpa.type.v1.TypedStruct","type_url":"type.googleapis.com/envoy.extensions.upstreams.http.dubbo_tcp.v3.DubboTcpConnectionPoolProto"}}}}}]}}
  creationTimestamp: "2023-04-12T02:17:41Z"
  generation: 1
  name: http-dubbo-transcoder-test
  namespace: test
  resourceVersion: "85685381"
  uid: 500f1e0e-8052-48ed-9964-b44ffb5d5b10
spec:
  configPatches:
  - applyTo: HTTP_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: envoy.filters.network.http_connection_manager
            subFilter:
              name: envoy.filters.http.router
    patch:
      operation: INSERT_BEFORE
      value:
        name: envoy.filters.http.http_dubbo_transcoder
        typed_config:
          '@type': type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: type.googleapis.com/envoy.extensions.filters.http.http_dubbo_transcoder.v3.HttpDubboTranscoder
  - applyTo: HTTP_ROUTE
    match:
      context: GATEWAY
      routeConfiguration:
        vhost:
          route:
            name: test
    patch:
      operation: MERGE
      value:
        route:
          upgrade_configs:
          - connect_config:
              allow_post: true
            upgrade_type: CONNECT
        typed_per_filter_config:
          envoy.filters.http.http_dubbo_transcoder:
            '@type': type.googleapis.com/udpa.type.v1.TypedStruct
            type_url: type.googleapis.com/envoy.extensions.filters.http.http_dubbo_transcoder.v3.HttpDubboTranscoder
            value:
              request_validation_options:
                reject_unknown_method: true
                reject_unknown_query_parameters: true
              services_mapping:
              - group: dev
                method_mapping:
                - name: sayName
                  parameter_mapping:
                  - extract_key: name
                    extract_key_spec: ALL_QUERY_PARAMETER
                    mapping_type: java.lang.String
                  passthrough_setting:
                    passthrough_all_headers: true
                  path_matcher:
                    match_http_method_spec: ALL_GET
                    match_pattern: /dubbo/hello
                name: com.xkcoding.dubbo.common.service.HelloService
                version: 1.0.0
              url_unescape_spec: ALL_CHARACTERS_EXCEPT_RESERVED
  - applyTo: CLUSTER
    match:
      cluster:
        service: dubbo.static
      context: GATEWAY
    patch:
      operation: MERGE
      value:
        upstream_config:
          name: envoy.upstreams.http.dubbo_tcp
          typed_config:
            '@type': type.googleapis.com/udpa.type.v1.TypedStruct
            type_url: type.googleapis.com/envoy.extensions.upstreams.http.dubbo_tcp.v3.DubboTcpConnectionPoolProto

ServiceEntry

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.istio.io/v1beta1","kind":"ServiceEntry","metadata":{"annotations":{},"name":"dubbo","namespace":"test"},"spec":{"endpoints":[{"address":"10.105.182.181","ports":{"http":20880}}],"hosts":["dubbo.static"],"location":"MESH_EXTERNAL","ports":[{"name":"tcp","number":20880,"protocol":"TCP"}],"resolution":"STATIC"}}
  creationTimestamp: "2023-04-12T02:12:57Z"
  generation: 2
  name: dubbo
  namespace: test
  resourceVersion: "86051239"
  uid: 8ed60a2d-2c9b-42a5-9b43-5989a103d774
spec:
  endpoints:
  - address: 10.105.182.181
    ports:
      http: 20880
  hosts:
  - dubbo.static
  location: MESH_EXTERNAL
  ports:
  - name: tcp
    number: 20880
    protocol: TCP
  resolution: STATIC

VirtualService

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.istio.io/v1beta1","kind":"VirtualService","metadata":{"annotations":{},"name":"global","namespace":"test"},"spec":{"gateways":["higress-system/global"],"hosts":["*"],"http":[{"match":[{"ignoreUriCase":false,"uri":{"prefix":"/dubbo"}}],"name":"test","route":[{"destination":{"host":"dubbo.static","port":{"number":20880}}}]}]}}
  creationTimestamp: "2023-04-12T02:14:05Z"
  generation: 1
  name: global
  namespace: test
  resourceVersion: "85650524"
  uid: 4907eccb-acd2-40ed-a5d0-e5bde8e898fc
spec:
  gateways:
  - higress-system/global
  hosts:
  - '*'
  http:
  - match:
    - ignoreUriCase: false
      uri:
        prefix: /dubbo
    name: test
    route:
    - destination:
        host: dubbo.static
        port:
          number: 20880

dubbo服务和zk、higress-gateway的service 地址

dubbo-provider   ClusterIP   10.105.182.181   <none>        8087/TCP,20880/TCP     ns:test
zookeeper        ClusterIP   10.96.215.94     <none>        2181/TCP             ns:test
higress-gateway      LoadBalancer   10.107.58.2      <pending>     80:30225/TCP,443:31010/TCP   ns:higress-system

测试

# curl 10.107.58.2:80/dubbo/hello?name='kkk' -v -H 'host: dubbo.static'
* About to connect() to 10.107.58.2 port 80 (#0)
*   Trying 10.107.58.2...
* Connected to 10.107.58.2 (10.107.58.2) port 80 (#0)
> GET /dubbo/hello?name=kkk HTTP/1.1
> User-Agent: curl/7.29.0
> Accept: */*
> host: dubbo.static
>
< HTTP/1.1 502 Bad Gateway
< content-length: 87
< content-type: text/plain
< date: Wed, 12 Apr 2023 03:35:41 GMT
< server: istio-envoy
<
* Connection #0 to host 10.107.58.2 left intact
upstream connect error or disconnect/reset before headers. reset reason: protocol error[
# curl 10.107.58.2:80/dubbo/hello?name='kkk' -v
* About to connect() to 10.107.58.2 port 80 (#0)
*   Trying 10.107.58.2...
* Connected to 10.107.58.2 (10.107.58.2) port 80 (#0)
> GET /dubbo/hello?name=kkk HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 10.107.58.2
> Accept: */*
>
< HTTP/1.1 502 Bad Gateway
< content-length: 87
< content-type: text/plain
< date: Wed, 12 Apr 2023 03:36:02 GMT
< server: istio-envoy
<
* Connection #0 to host 10.107.58.2 left intact
upstream connect error or disconnect/reset before headers. reset reason: protocol error

贡献者指南