Skip to content

mhamrah/grpc-example

Repository files navigation

The original code from my gRPC All The Things talk at Full Stack Fest 2018 is on the branch original-fullstackfest-2018. The master branch

tracks an upgraded project with the similar code.

Slides

TODOS

A grpc-based todo backend used to demonstrate gRPC Gateway and running microservices on Kubernetes. This is demo code used for

Install

brew cask install bloomrpc
brew install grpcurl
brew install minikube
brew install istioctl

Running Locally

Generate the required protobuf files with make protogen. This will run the protoc command in the namely/protoc-all docker container.

Kubernetes

This project has a skaffold.yaml file and can be run on a minikube-based environment. Install the istioctl and minikube dependencies to experiment then do the following:

  1. Start minikube (check for cpu/mem requirements): minikube start
  2. Install the demo profile of istio, with Grafana enabled: istioctl manifest apply --set profile=demo --set addonComponents.grafana.enabled=true
  3. In a separate terminal window, use Minikube tunnel to easily access services: minikube tunnel
  4. Apply the todos namespace definition: k apply -f k8s/setup/namespace.yaml
  5. Set istio to auto-inject on todos: kubectl label namespace todos istio-injection=enabled
  6. Run skaffold in dev mode: skaffold dev

Commands

grpcurl -plaintext localhost:50052 describe
grpcurl -plaintext -d '{ "id": "01E4Q00M7YPD06TX3YW8DMFF8B" }' localhost:50052 todos.Todos/GetTodo
curl  -X POST http://localhost:51051/todos -H 'Content-Type: application/json' -d '{ "id":  "01E4Q00M7YPD06TX3YW8DMFF8B" }'