module
Version:
v0.0.0-...-d441da7
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-client-lb
Example of gRPC client-side load balancing in Golang
Services
Build
-
Server
make build-server
# or
go build -o grpc-server ./server
-
Client
make build-client
# or
go build -o grpc-client ./client
Run
-
Run server
make run-server
# or
./grpc-server
-
In another shell, run client
make run-client
# or
./grpc-client
From source
-
Run server
make run-server-src
# or
protoc --proto_path=./proto/ --go_out=plugins=grpc:domain ./proto/*
GO111MODULE=on go run ./server/main.go
-
In another shell, run client
make run-client-src
# or
protoc --proto_path=./proto/ --go_out=plugins=grpc:domain ./proto/*
GO111MODULE=on go run ./client/main.go
Docker
Build
-
Server
make container-build-server
# or
docker build -t grpc/grpc-server -f server.Dockerfile .
-
Client
make container-build-client
# or
docker build -t grpc/grpc-client -f client.Dockerfile .
Run
-
Run server
make container-run-server
# or
docker run -ti --rm --name server -p 50051:50051 grpc/grpc-server
-
In another shell, run client
make container-run-client
# or
docker run -ti --rm --name client grpc/grpc-client
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
make load-container-kind
# or
kind load docker-image grpc/grpc-server
kind load docker-image grpc/grpc-client
Deploy
-
Start Kubernetes locally
-
Deploy server
make deploy-server
# or
kubectl apply -k kube/server
-
Deploy client
make deploy-client
# or
kubectl apply -k kube/client
-
Take a look of logs
Cleanup
Minikube
make stop-minikube
# or
minikube stop
minikube delete
KinD
make stop-kind
# or
kind delete cluster
Example
-
Run server
go run example/server/main.go
-
In another shell, run client
go run example/client/main.go
Links
Directories
¶
|
|
|
|
example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Click to show internal directories.
Click to hide internal directories.