GitXplorerGitXplorer
m

yages

public
36 stars
14 forks
0 issues

Commits

List of commits on branch master.
Unverified
6687b2f796f73bbd832b6d3f646420362e34f3d0

updates docs

mmhausenblas committed 7 years ago
Unverified
f72d2332dd71639f0adc481c354eee702d28545a

updates docs

mmhausenblas committed 7 years ago
Unverified
a52929d8ce36535f87ca210e9d369fb6abdde67a

inits containerized workflow

mmhausenblas committed 7 years ago
Unverified
c11ddd092b47779bb1b52845f5f7e8e3ae922d2f

fixes docs

mmhausenblas committed 7 years ago
Unverified
737aa5bc2a4794e5be32aaf8023eff5285dd0343

updates docs

mmhausenblas committed 7 years ago
Unverified
3bec64f0e7c3894e1a9612372ab5c010edc19971

updates docs

mmhausenblas committed 7 years ago

README

The README file for this repository.

Yet another gRPC echo server

YAGES (yet another gRPC echo server) is an educational gRPC server implementation. The goal is to learn gRPC and communicate best practices around its deployment and usage in the context of Kubernetes.

As an Kubernetes app

You can install YAGES as an app in your Kubernetes cluster (tested with Kubernetes v1.9, v1.10, and v1.11) like so:

$ kubectl apply -f http://mhausenblas.info/yages/app.yaml

Then, in order to invoke the service you've got essentially two options: from inside the cluster or from the outside the cluster, by exposing the service.

From inside the cluster

To access the gRPC server from inside the cluster, you can for example use the gump container image that has grpcurl installed:

$ kubectl run -it --rm grpcurl --restart=Never --image=quay.io/mhausenblas/gump:0.1 -- sh 
If you don't see a command prompt, try pressing enter.
/go $ grpcurl --plaintext yages:9000 yages.Echo.Ping
{
  "text": "pong"
}

From outside the cluster

TBD: Using Ingress as shown in ingress.yaml or an OpenShift Route object with TLS passthrough set.

As a local app

Install

Requires Go 1.9 or above, do:

$ go get -u github.com/mhausenblas/yages

Use

You can run go run main.go in $GOPATH/src/github.com/mhausenblas/yages or if you've added $GOPATH/bin to your path, directly call the binary:

$ yages
2018/03/25 16:23:42 YAGES in version dev serving on 0.0.0.0:9000 is ready for gRPC clients …

Open up a second terminal session and using grpcurl execute the following:

# invoke the ping method:
$ grpcurl --plaintext localhost:9000 yages.Echo.Ping
{
  "text": "pong"
}
# invoke the reverse method with parameter:
$ grpcurl --plaintext -d '{ "text" : "some fun here" }' localhost:9000 yages.Echo.Reverse
{
  "text": "ereh nuf emos"
}
# invoke the reverse method with parameter from JSON file:
$ cat echo.json | grpcurl --plaintext -d @ localhost:9000 yages.Echo.Reverse
{
  "text": "ohce"
}

Note that you can execute grpcurl --plaintext localhost:9000 list and grpcurl --plaintext localhost:9000 describe to get further details on the available services and their respective methods.

Develop

First you want to generate the stubs based on the protobuf schema. Note that this requires the Go gRPC runtime and plug-in installed on your machine, including protoc in v3 set up, see grpc.io for the steps.

Do the following:

$ protoc \
  --proto_path=$GOPATH/src/github.com/mhausenblas/yages \
  --go_out=plugins=grpc:yages \
  yages-schema.proto

Executing above command results in the auto-generated file yages/yages-schema.pb.go. Do not manually edit this file, or put in other words: if you add a new message or service to the schema defined in yages-schema.proto just run above protoc command again and you'll get an updated version of yages-schema.pb.go in the yages/ directory as a result.