Exposing Dubbo-go services using Pixiu

Exposing Dubbo-go services using Pixiu

The Dubbo-go-pixiu gateway supports calls to Dubbo clusters in GO/Java. In the scenario of Dubbo-go 3.0, we can request the Pixiu gateway over HTTP protocol outside the cluster, perform protocol conversion at the gateway layer, and further call the Dubbo-go services inside the cluster.

img

The path for users to call Dubbo-go services is http://$(app\_name)/$(service\_name)/$(method).

For example, if a proto file has the following definition:

  1. package org.apache.dubbo.quickstart.samples;
  2. service UserProvider {
  3. rpc SayHello (HelloRequest) returns (User) {}
  4. }
  5. message HelloRequest {
  6. string name = 1;
  7. }

And when the dubbo-go service starts, it configures the application name as my-dubbogo-app in the dubbogo.yml:

  1. dubbo:
  2. application:
  3. name: my-dubbogo-app

The Pixiu gateway can resolve the path as http://my-dubbogo-app/org.apache.dubbo.quickstart.samples.UserProvider/SayHello and forward it to the corresponding service. The body from external HTTP requests is JSON serialized request parameters, for example, {“name”:“test”}.

We currently recommend using Nacos as the registration center.

Users can deploy our demo in their cluster, preferably with the ability to expose lb type services so that services in the cluster can be accessed from the public network, or requests can be made directly within the cluster. For your cluster, execute:

  1. $ kubectl apply -f https://raw.githubusercontent.com/dubbogo/triple-pixiu-demo/master/deploy/pixiu-triple-demo.yml

This will create the following resources under the dubbogo-triple-nacos namespace, including three triple-servers, one pixiu gateway, and one nacos server. The services will be exposed to the public network via Service.

  1. namespace/dubbogo-triple-nacos created
  2. service/dubbo-go-nacos created
  3. deployment.apps/dubbogo-nacos-deployment created
  4. deployment.apps/pixiu created
  5. deployment.apps/server created
  6. service/pixiu created

Obtain the public IP of Pixiu and make a call:

  1. $ kubectl get svc -n dubbogo-triple-nacos
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. dubbo-go-nacos ClusterIP 192.168.123.204 <none> 8848/TCP 32s
  4. pixiu LoadBalancer 192.168.156.175 30.XXX.XXX.XX 8881:30173/TCP 32s

Call the demo service with curl and receive the response.

  1. $ curl -X POST -d '{"name":"laurence"}' http://30.XXX.XXX.XX:8881/dubbogoDemoServer/org.apache.dubbo.laurence.samples.UserProvider/SayHello
  2. {"name":"Hello laurence","id":"12345","age":21}

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)