1gRPC Hostname Example 2===================== 3 4The hostname example is a Hello World server whose response includes its 5hostname. It also supports health and reflection services. This makes it a good 6server to test infrastructure, like load balancing. This example depends on a 7gRPC version of 1.28.1 or newer. 8 9### Run the Server 10 111. Navigate to this directory: 12 13```sh 14cd grpc/examples/python/xds 15``` 16 172. Run the server 18 19```sh 20virtualenv venv -p python3 21source venv/bin/activate 22pip install -r requirements.txt 23python server.py 24``` 25 26### Run the Client 27 281. Set up xDS configuration. 29 30After configuring your xDS server to track the gRPC server we just started, 31create a bootstrap file as desribed in [gRFC A27](https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md): 32 33``` 34{ 35 xds_servers": [ 36 { 37 "server_uri": <string containing URI of xds server>, 38 "channel_creds": [ 39 { 40 "type": <string containing channel cred type>, 41 "config": <JSON object containing config for the type> 42 } 43 ] 44 } 45 ], 46 "node": <JSON form of Node proto> 47} 48``` 49 502. Point the `GRPC_XDS_BOOTSTRAP` environment variable at the bootstrap file: 51 52``` 53export GRPC_XDS_BOOTSTRAP=/etc/xds-bootstrap.json 54``` 55 563. Run the client: 57 58``` 59python client.py xds-experimental:///my-backend 60``` 61 62### Verifying Configuration with a CLI Tool 63 64Alternatively, `grpcurl` can be used to verify your server. If you don't have it, 65install [`grpcurl`](https://github.com/fullstorydev/grpcurl/releases). This will allow 66you to manually test the service. 67 68Be sure to set up the bootstrap file and `GRPC_XDS_BOOTSTRAP` as in the previous 69section. 70 711. Verify the server's application-layer service: 72 73```sh 74> grpcurl --plaintext -d '{"name": "you"}' localhost:50051 75{ 76 "message": "Hello you from rbell.svl.corp.google.com!" 77} 78``` 79 802. Verify that all services are available via reflection: 81 82```sh 83> grpcurl --plaintext localhost:50051 list 84grpc.health.v1.Health 85grpc.reflection.v1alpha.ServerReflection 86helloworld.Greeter 87``` 88 893. Verify that all services are reporting healthy: 90 91```sh 92> grpcurl --plaintext -d '{"service": "helloworld.Greeter"}' localhost:50051 93grpc.health.v1.Health/Check 94{ 95 "status": "SERVING" 96} 97 98> grpcurl --plaintext -d '{"service": ""}' localhost:50051 99grpc.health.v1.Health/Check 100{ 101 "status": "SERVING" 102} 103``` 104