Member-only story
gRPC for microservices in Kubernetes
I have been experimenting with gRPC for some time now. I wrote some articles to cover the basics like What is gRPC? SSL/TLS Auth in gRPC, and communication patterns used in gRPC. In these topics I went through some of the advantages of gRPC over traditional REST API for inter-service communication — especially in a distributed architecture. The crux is — gRPC offers great performance using Protobuf and natively supports uni and bi directional streaming.
I used an analogy of calculator server and clients calling out arithmetic operations from this server using gRPC protocol, in all the previous blogs. In this blog, I take the same example to take the next step — deploying these services on K8s cluster to demonstrate how you can use gRPC in Kubernetes context. Specifically, in this post I will:
- Containerize the client and server applications using Docker
- Prepare Kubernetes deployment YAMLs for these services
- Prepare Kubernetes service YAML to expose the calculator server
- Make sure uni and bidirectional communication is enabled between client and server
Please note that there are multiple ways gRPC is used like — in Ingress load balancers, service meshes, etc. In fact, K8s also uses gRPC to enable efficient communication between kubelet and CRI (Container…