gRPC health checks in kubernetes scenario - unable to execute on demand only subset of healthchecks
See original GitHub issueWhat version of gRPC and what language are you using?
2.53.0
What operating system (Linux, Windows,…) and version?
macos
What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info
)
6.0.16
What did you do?
Trying to configure kubernetes grpc healthchecks for my service. I want to have different healthchecks executed on demand for startup and liveness probe.
I’ve tried to use the following configuration:
services
.AddGrpcHealthChecks(o =>
{
// startup probe checks dependencies
o.Services.MapService("startup", r => r.Tags.Contains("startup"));
// startup probe checks dependencies
o.Services.MapService( "liveness", r => r.Tags.Contains("liveness"));
o.Services.MapService("", r => r.Tags.Contains("liveness");
o.UseHealthChecksCache = false;
})
... //definitions here
//auto update just liveness ones
services.Configure<HealthCheckPublisherOptions>(options =>
{
options.Predicate = (r) => r.Tags.Contains("liveness");
});
What did you expect to see?
grpc_cli call IP:PORT grpc.health.v1.Health/Check "service: 'startup'"
will run only checks tagged with startup
grpc_cli call IP:PORT grpc.health.v1.Health/Check "service: 'liveness'"
will run only checks tagged with liveness
What did you see instead?
grpc_cli call IP:PORT grpc.health.v1.Health/Check "service: 'startup'"
doesnt not run startup
tagged checks at all!
Code hint
In the newest code I’ve found that the CheckHealthAsync is executed with different predicate than GetStatus. Is it by design?
HealthCheckResponse.Types.ServingStatus status;
if (_grpcHealthCheckOptions.Services.TryGetServiceMapping(service, out var serviceMapping))
{
var result = await _healthCheckService.CheckHealthAsync(_healthCheckOptions.Predicate, cancellationToken);
status = HealthChecksStatusHelpers.GetStatus(result, serviceMapping.Predicate);
}
Issue Analytics
- State:
- Created 4 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Health checking gRPC servers on Kubernetes
In this article, we will talk about grpc-health-probe, a Kubernetes-native way to health check gRPC apps. If you're unfamiliar, Kubernetes ...
Read more >Configuring gRPC probes with the latest versions ... - YouTube
Kubernetes introduces the native support of gRPC probes for health and readiness checks. Many Kubernetes users who used to run gRPC services ...
Read more >Container health checks (services) - Cloud Run
You can configure HTTP, TCP, and gRPC startup health check probes, along with HTTP and gRPC liveness probes for new and existing Cloud...
Read more >gRPC health checks in ASP.NET Core
The health checks service is added to the server app. ·.NET health checks registered with the app are periodically executed for health results....
Read more >Health checking your gRPC servers on GKE
Kubernetes natively supports some health check methods to assert readiness or liveness of a Pod: TCP socket open; HTTP GET request; executing a ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I understand.
Rather than have two predicates, what I’d like to do is:
ServiceMapping
that takes aHealthResult
.HealthCheckRegistration
andHealthResult
.CheckHealthAsync
to determine what health checks should run for a service name.Potential solution could be to:
Func<HealthCheckRegistration, bool> ExecutionPredicate { get; }
with default value to return always trueservice.ExecutionPredicate
and_healthCheckOptions.Predicate
inGetHealthCheckResponseAsync