Repository navigation
Add support for gRPC health checks - #1054
Merged
ryanjbaxter merged 3 commits intoNov 24, 2026
Merged
ryanjbaxter merged 3 commits into
ryanjbaxter merged 3 commits into
Conversation
Services that expose a gRPC server could only be registered with an HTTP or TTL check, so their gRPC endpoint was never health checked by Consul. Add three discovery properties to register a Consul gRPC check instead of the HTTP check: - spring.cloud.consul.discovery.health-check-grpc-port enables the check and sets the port of the gRPC server. The check targets the discovery hostname, with IPv6 addresses enclosed in brackets. - spring.cloud.consul.discovery.health-check-grpc-service optionally names the service to check with the gRPC health checking protocol. The whole server is checked otherwise. - spring.cloud.consul.discovery.health-check-grpc-use-tls makes Consul connect to the gRPC server over TLS. The existing interval, timeout, critical timeout and TLS skip verify properties apply to the gRPC check too. A TTL check still takes precedence, since the heartbeat only updates TTL checks, and a separate management service keeps its HTTP check of the health endpoint. Fixes spring-cloudgh-625 Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
ryanjbaxter
requested changes
Nov 24, 2026
| check.setGrpcUseTLS(properties.isHealthCheckGrpcUseTls()); | ||
| check.setInterval(properties.getHealthCheckInterval()); | ||
| check.setTimeout(properties.getHealthCheckTimeout()); | ||
| check.setTlsSkipVerify(properties.getHealthCheckTlsSkipVerify()); |
Contributor
There was a problem hiding this comment.
tlsSkipVerify is passed through even with use-tls=false
Contributor
Author
There was a problem hiding this comment.
Fixed, tlsSkipVerify is now only set on the gRPC check when use-tls is true (7d21b6a).
| ---- | ||
|
|
||
| Set `spring.cloud.consul.discovery.health-check-grpc-use-tls` to `true` if the gRPC server uses TLS. | ||
| The `health-check-interval`, `health-check-timeout`, `health-check-critical-timeout` and `health-check-tls-skip-verify` properties apply to the gRPC check as well. |
Contributor
There was a problem hiding this comment.
Could you say which HTTP-specific properties don't apply?
Contributor
Author
There was a problem hiding this comment.
Added to the docs: health-check-path, health-check-url, health-check-headers and the scheme are ignored by the gRPC check, and tls-skip-verify only applies with use-tls.
Document which HTTP specific properties the gRPC check ignores. Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Services that run a gRPC server can only be registered with an HTTP or TTL check, so Consul never health checks their gRPC endpoint.
NewService.Checkalready has theGRPCandGRPCUseTLSfields, but nothing sets them.Solution
Three new discovery properties register a Consul gRPC check in place of the HTTP check:
spring.cloud.consul.discovery.health-check-grpc-portspring.cloud.consul.discovery.health-check-grpc-servicespring.cloud.consul.discovery.health-check-grpc-use-tlsfalse.host:port.health-check-interval,health-check-timeout,health-check-critical-timeoutandhealth-check-tls-skip-verifyalso apply to the gRPC check. Headers are not sent because they only apply to HTTP checks.heartbeat.enabled=true, because the heartbeat only updates TTL checks.ConsulAutoRegistration.createGrpcChecksits next tocreateCheck.The discovery docs have a new "gRPC Health Check" section, and the properties are listed in the appendix.
Testing
ConsulAutoRegistrationGrpcHealthCheckTests(new) runs against the Consul Testcontainer. It checks the registered check (target, TLS, interval, timeout, critical timeout, TLS skip verify, and no HTTP check or headers) and that Consul has the service check.ConsulAutoRegistrationGrpcCheckTests(new) covers:register-health-check=falsegrpc.health.v1.Healthservice, using a temporary test that is not part of this PR:health-check-grpc-serviceset to aSERVINGservice turnedpassingwith outputgRPC check host.docker.internal:34499/my.package.MyService: success.NOT_SERVINGservice, the agent showed agrpccheck,critical, with outputserving status: NOT_SERVING.spring-javaformat:validatepass.Fixes #625