gRPC health probes with Kubernetes 1.24+

Mathieu Benoit
Google Cloud - Community
2 min readOct 31, 2022

Updated on June 21st, 2023 with the default support of the new native gRPC health probes for the Online Boutique sample apps.

Updated on December 8th, 2022 with the deployment of Online Boutique via its Helm chart.

Kubernetes uses liveness probes to know when to restart a container and readiness probes to know when a container is ready to start accepting traffic.

gRPC health probes are now natively supported in beta since Kubernetes 1.24+. Before that we needed to add the grpc_health_probe binary in each Dockerfile.

Since the v0.4.1 version, the Online Boutique sample provides an option to have its applications supporting this feature. This allows you to leverage the native Kubernetes feature, decrease the size of the container images by 4MB (virtual) and 11MB (on disk) as well as reduce the maintenance and surface of attack that this grpc_health_probe binary was adding.

And now on, since the v0.8.0 version, the Online Boutique sample provides this native gRPC health probes by default.

The old way versus the new native gRPC health probes

With Kubernetes’ new native gRPC health probes, you no longer need to add the grpc_health_probe binary (like we needed to previously) into the Dockerfile of your microservices:

RUN GRPC_HEALTH_PROBE_VERSION=v0.4.14 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe

In the Kubernetes manifests for your Deployments, here is the associated updates for both the readinessProbe and the livenessProbe:

+           grpc:
+ port: 9555
- exec:
- command:
- - /bin/grpc_health_probe
- - -addr=:9555

Deploy the Online Boutique sample with this new feature

Create a Google Kubernetes Engine (GKE) cluster in version 1.24+:

gcloud container clusters create tests \
--zone=us-east4-a \
--machine-type=e2-standard-2 \
--num-nodes=4 \
--release-channel=rapid

Note: as of November 1st, 2022, the default version of GKE in rapid channel is 1.24.

From there, let’s deploy the Online Boutique sample with the gRPC health probes support.

For that we will use the Online Boutique’s Helm chart:

helm upgrade onlineboutique oci://us-docker.pkg.dev/online-boutique-ci/charts/onlineboutique \
--install \
--create-namespace \
-n onlineboutique

Note: until the v0.7.0 version, the Online Boutique Helm chart had this option --set nativeGrpcHealthCheck=true. in order to use the *service:v0.7.0-native-grpc-probes images.

If you wait a little bit until all the Pods are running, you should have your Online Boutique website working successfully.

That’s how easily we were able to leverage the new native gRPC health probes with Kubernetes 1.24+ with the Online Boutique sample.

Hope you liked it and that you will be able to take inspiration of this for your own apps!

Originally posted at mathieu-benoit.github.io.

--

--

Mathieu Benoit
Google Cloud - Community

Customer Success Engineer at Humanitec | CNCF Ambassador | GDE Cloud