module
Version:
v0.0.0-...-e3d380c
Opens a new window with list of versions in this module.
Published: Feb 9, 2020
License: Apache-2.0
Opens a new window with license information.
README
¶
go-grpc
gRPC example in Golang
Services
Codebase
Prerequisites
- Compile protobufs
protoc --proto_path=./proto/ --go_out=plugins=grpc:domain ./proto/*
Build
-
Server (hello-service)
go build -o grpc-server ./hello-service
-
Client (greeting-service)
go build -o grpc-client ./greeting-service
Run
-
Start server (hello-service)
GO111MODULE=on go run ./hello-service/main.go
-
In another shell, start client (greeting-service)
GO111MODULE=on go run ./greeting-service/main.go
Polyglot test
This repo can be used for a polyglot test together with java-grpc
Go client --> Java server
-
Start server (hello-service)
cd java-grpc/hello-service
mvnw clean spring-boot:run
-
In another shell, start client (greeting-service)
GO111MODULE=on go run ./greeting-service/main.go
Java client --> Go server
-
Start server (hello-service)
GO111MODULE=on go run ./hello-service/main.go
-
In another shell, start client (greeting-service)
cd java-grpc/greeting-service
mvnw clean spring-boot:run
Docker
Build
-
Server (hello-service)
docker build -t grpc/hello-service -f hello.Dockerfile .
-
Client (greeting-service)
docker build -t grpc/greeting-service -f greeting.Dockerfile .
Run
-
Server (hello-service)
docker run -ti --rm --name hello-service -p 50051:50051 grpc/hello-service
-
Client (greeting-service)
docker run -ti --rm --name greeting-service grpc/greeting-service
Kubernetes
Import container images
Minikube
-
Enable Minikube internal container registry
eval $(minikube docker-env)
-
Build container images normally as it would be locally
KinD
-
Build container images normally as it would be locally
-
Import in KinD
kind load docker-image grpc/hello-service
kind load docker-image grpc/greeting-service
Deploy
-
Start Kubernetes locally
-
Deploy server (hello-service)
kubectl apply -k kube/hello-service
-
Deploy client (greeting-service)
kubectl apply -k kube/greeting-service
-
Take a look of logs
kubectl logs -l app=greeting-service -f
Links
Directories
¶
Click to show internal directories.
Click to hide internal directories.