./gradlew generateProto
Proto definitions
Java implementation for gRPC based on gRPC generated code
File to build an image based on the application
Files to deploy the application in a Kubernetes cluster with Istio
Files necessary to build .pb file, source "https://github.com/googleapis/googleapis"
br.com.amsj.grpc.calculator.server.CalculatorServer
br.com.amsj.grpc.calculator.client.AverageServerStreamClient
br.com.amsj.grpc.calculator.client.SquareRootUnaryClient
Reference: https://github.com/grpc/grpc-java/blob/master/documentation/server-reflection-tutorial.md
build.gradle
evans --proto <PATH-TO-PROTO-FILE> --port <PORT> --host <HOST>
evans --proto calculator.proto --port 50081 --host localhost
evans --host <LOCALHOST> -p <PORT> -r
evans --host localhost -p 50081 -r
show services
call <SERVICE-NAME>
call CalculatorSquareRoot
call CalculatorAverage
localhost:50081
docker buildx build -t <YOUR-DOCKERHUB-USER>/calculatorgrpc --platform linux/arm64,linux/amd64 --push -f docker-build/Dockerfile .
To consume use the Load Balancer for port 5000, or create Node port for Istio expose the application
protoc -Igoogleapis/ -I. --include_imports --include_source_info --descriptor_set_out=src/main/proto/calculator/proto.pb src/main/proto/calculator/calculator.proto
kubectl -n calculatorgrpc create cm proto-descriptor --from-file=src/main/proto/calculator/proto.pb --dry-run=client -o yaml > deploy/06-calculatorgrpc-cm-proto.yaml
kubectl apply -f deploy/
"calculatorgrpc.teste.com.br:30119"
{
"number": 81
}
{
"numbers": [
10,
20,
30
]
}
{
"number": 10
}
curl --location --request GET 'https://<SERVICE-DNS>>:<HTTPS-PORT>>/v1/calculatorsquareroot/<SOME-INTEGER>', example "https://calculatorgrpc.teste.com.br:31767/v1/calculatorsquareroot/81" --header 'Content-Type: application/json'
example:
curl --location --request GET 'https://calculatorgrpc.teste.com.br:31767/v1/calculatorsquareroot/81' --header 'Content-Type: application/json'
curl --location --request POST 'https://<SERVICE-DNS>:<HTTPS-PORT>/v1/calculatorsum' --header 'Content-Type: text/plain' \
--data-raw '[<ARRAY-INTEGER>]'
example:
curl --location --request POST 'https://calculatorgrpc.teste.com.br:31767/v1/calculatorsum' --header 'Content-Type: text/plain' \
--data-raw ' [
10,
20,
30,
30
]
'
curl --location --request POST 'https://<SERVICE-DNS>:<HTTPS-PORT>/v1/calculatorsquareroot/calculatoraverage' --header 'Content-Type: text/plain' \
--data-raw '[<ARRAY-INTEGER>]'
example:
curl --location --request POST 'https://calculatorgrpc.teste.com.br:31767/v1/calculatoraverage' --header 'Content-Type: text/plain' \
--data-raw ' [
10,
20,
30,
30,
10
]
'
curl --location --request GET 'https://<SERVICE-DNS>>:<HTTPS-PORT>>/v1/calculatorsquareroot/<SOME-INTEGER>', example "https://calculatorgrpc.teste.com.br:31767/v1/calculatorsquareroot/81" --header 'Content-Type: application/json'
example:
curl --location --request GET 'https://calculatorgrpc.teste.com.br:31767/v1/calculatorsquareroot/81' --header 'Content-Type: application/json'
curl --location --request POST 'https://<SERVICE-DNS>:<HTTPS-PORT>/v1/calculatorsum' --header 'Content-Type: text/plain' \
--data-raw '[<ARRAY-INTEGER>]'
example:
curl --location --request POST 'https://calculatorgrpc.teste.com.br:31767/v1/calculatorsum' --header 'Content-Type: text/plain' \
--data-raw ' [
10,
20,
30,
30
]
'
curl --location --request POST 'https://<SERVICE-DNS>:<HTTPS-PORT>/v1/calculatorsquareroot/calculatoraverage' --header 'Content-Type: text/plain' \
--data-raw '[<ARRAY-INTEGER>]'
example:
curl --location --request POST 'https://calculatorgrpc.teste.com.br:31767/v1/calculatoraverage' --header 'Content-Type: text/plain' \
--data-raw ' [
10,
20,
30,
30,
10
]
'