feat(probe): add Kubernetes probe support with liveness, readiness, and startup checks#3213
feat(probe): add Kubernetes probe support with liveness, readiness, and startup checks#3213Alanxtl merged 6 commits intoapache:developfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3213 +/- ##
===========================================
+ Coverage 46.76% 47.92% +1.16%
===========================================
Files 295 467 +172
Lines 17172 34042 +16870
===========================================
+ Hits 8031 16316 +8285
- Misses 8287 16403 +8116
- Partials 854 1323 +469 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
AlexStocks
left a comment
There was a problem hiding this comment.
需要调整初始化路径:probe 现在在 config/metric_config.go 和 server/options.go 两处都可能触发 Init。虽然有 sync.Once,但会带来隐式优先级(谁先初始化谁生效),容易导致配置行为不一致。建议收敛为单一入口,另一处只做参数构造或删除。
all done |
|
CAICAIIs
left a comment
There was a problem hiding this comment.
lgtm
my test result:
Commands executed
- Core verification:
- go test ./metrics/probe/...
- go test -race ./metrics/probe/...
- go test ./server/...
- Sample linkage/build:
- go mod edit -replace=dubbo.apache.org/dubbo-go/v3=(******)
- go mod tidy
- go build ./metrics/probe/go-server/cmd
- go build ./metrics/probe/go-client/cmd
- End-to-end run:
- go run ./metrics/probe/go-server/cmd/main.go
- go run ./metrics/probe/go-client/cmd/main.go
Verified results
- Core tests
- metrics/probe tests: pass
- metrics/probe race tests: pass
- server tests: pass
- Runtime behavior
- Server startup log confirms probe server is listening on :22222 and Triple service on :20000
- Client integration log confirms probe endpoints and RPC all pass
Key log excerpts
Server startup
- /tmp/review-2039-server.log
2026-03-09 17:48:08 INFO probe/server.go:101 [kubernetes probe] probe server listening on :22222
2026-03-09 17:48:08 INFO cmd/main.go:136 Probe sample server started, triple=20000 probe=22222
2026-03-09 17:48:23 INFO cmd/main.go:78 Warmup completed, readiness/startup should be healthy
Client integration
- /tmp/review-2039-client.log
2026-03-09 17:48:15 INFO /live is healthy
2026-03-09 17:48:23 INFO /ready is healthy
2026-03-09 17:48:23 INFO /startup is healthy
2026-03-09 17:48:23 INFO greet rpc succeeded: hello probe-check
2026-03-09 17:48:23 INFO probe sample integration checks passed
Warm-up phase probe behavior
- /tmp/review-2039-precheck.log
HTTP/1.1 200 OK
...
ok
HTTP/1.1 503 Service Unavailable
...
probe warmup: warmup not complete
HTTP/1.1 503 Service Unavailable
...
probe warmup: startup warmup not complete
Post warm-up probe behavior
- /tmp/review-2039-postcheck.log
HTTP/1.1 200 OK
...
ok
HTTP/1.1 200 OK
...
ok
HTTP/1.1 200 OK
...
ok



This is the implemention of #2039
which is the rewritten of #3047
usage are demonstrated in apache/dubbo-go-samples#1033
docs are written in apache/dubbo-website#3193
Kubernetes 探针(Probe)功能说明
本模块提供独立的 HTTP 探针服务,面向 Kubernetes 的
liveness、readiness、startup三类探针。它支持用户自定义健康检查逻辑,并可选择性地与 Dubbo Server 生命周期进行内部状态对齐。
设计目标
liveness默认不带内部逻辑,避免不当重启。readiness/startup可选用内部状态。默认 HTTP 路径
当启用 probe 后,默认在22222端口下暴露以下路径:
GET /live:liveness 探针GET /ready:readiness 探针GET /startup:startup 探针响应规则:
200503new api 配置方式
通过
metrics.NewOptions(...)传入以下 Option 配置:old api 配置方式
在
metrics配置下新增probe子配置:配置项说明:
enabled:是否开启 probe 服务port:probe HTTP 端口liveness-path:liveness 路径readiness-path:readiness 路径startup-path:startup 路径use-internal-state:是否启用内部生命周期状态检查,默认启用内部状态(UseInternalState)
当
use-internal-state: true时,探针会附加内部状态检查:readiness依赖probe.SetReady(true/false)startup依赖probe.SetStartupComplete(true/false)默认行为:
Server.Serve()成功执行)会设置ready=true、startup=trueready=false如果设置为
false,则完全由用户注册的回调决定探针结果。自定义健康检查(推荐)
通过注册回调即可扩展探针逻辑:
注意事项
Kubernetes 示例
Description
Fixes # (issue)
Checklist
develop