Health checking gRPC servers on Kubernetes
Author:
Update (December 2021): Kubernetes now has built-in gRPC health probes starting in v1.23.
To learn more, see Configure Liveness, Readiness and Startup Probes.
This article was originally written about an external tool to achieve the same task.
If you're unfamiliar, Kubernetes health
checks
(liveness and readiness probes) is what's keeping your applications available
while you're sleeping. They detect unresponsive pods, mark them unhealthy, and
cause these pods to be restarted or rescheduled. Can we do better? Absolutely. To standardize the "exec probe" approach mentioned above, we need: Thankfully, gRPC has a . It
can be used easily from any language. Generated code and the utilities for
setting the health status are shipped in nearly all language implementations of
gRPC. The next thing you need is the "standard tool", and it's the
grpc-health-probe. With this tool, you can use the same health check configuration in all your gRPC
applications. This approach requires you to: In this case, executing "grpc_health_probe" will call your gRPC server over
grpc-health-probe project is still in its early days and it needs your
feedback. It supports a variety of features like communicating with TLS servers
and configurable connection/RPC timeouts. If you are running a gRPC server on Kubernetes today, try using the gRPC Health
Protocol and try the grpc-health-probe in your deployments, and give
feedback.
Introducing “grpc-health-probe”
localhost
, since they are in the same pod.What's next
Further reading