Skip to content

Commit 97b399c

Browse files
committed
use httpGet as liveness/readiness probe method
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
1 parent 30e97c7 commit 97b399c

File tree

13 files changed

+121
-147
lines changed

13 files changed

+121
-147
lines changed

charts/kube-ovn/templates/controller-deploy.yaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,17 @@ spec:
191191
- mountPath: /var/run/tls
192192
name: kube-ovn-tls
193193
readinessProbe:
194-
exec:
195-
command:
196-
- /kube-ovn/kube-ovn-healthcheck
197-
- --port=10660
198-
- --tls={{- .Values.func.SECURE_SERVING }}
199-
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
194+
httpGet:
195+
port: 10660
196+
path: /readyz
197+
scheme: {{- ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}
200198
periodSeconds: 3
201199
timeoutSeconds: 5
202200
livenessProbe:
203-
exec:
204-
command:
205-
- /kube-ovn/kube-ovn-healthcheck
206-
- --port=10660
207-
- --tls={{- .Values.func.SECURE_SERVING }}
208-
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
201+
httpGet:
202+
port: 10660
203+
path: /livez
204+
scheme: {{- ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}
209205
initialDelaySeconds: 300
210206
periodSeconds: 7
211207
failureThreshold: 5

charts/kube-ovn/templates/monitor-deploy.yaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,20 @@ spec:
126126
initialDelaySeconds: 30
127127
periodSeconds: 7
128128
successThreshold: 1
129-
exec:
130-
command:
131-
- /kube-ovn/kube-ovn-healthcheck
132-
- --port=10661
133-
- --tls={{- .Values.func.SECURE_SERVING }}
134-
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
129+
httpGet:
130+
port: 10661
131+
path: /livez
132+
scheme: {{- ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}
135133
timeoutSeconds: 5
136134
readinessProbe:
137135
failureThreshold: 3
138136
initialDelaySeconds: 30
139137
periodSeconds: 7
140138
successThreshold: 1
141-
exec:
142-
command:
143-
- /kube-ovn/kube-ovn-healthcheck
144-
- --port=10661
145-
- --tls={{- .Values.func.SECURE_SERVING }}
146-
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
139+
httpGet:
140+
port: 10661
141+
path: /readyz
142+
scheme: {{- ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}
147143
timeoutSeconds: 5
148144
nodeSelector:
149145
kubernetes.io/os: "linux"

charts/kube-ovn/templates/ovncni-ds.yaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,20 @@ spec:
194194
failureThreshold: 3
195195
periodSeconds: 7
196196
successThreshold: 1
197-
exec:
198-
command:
199-
- /kube-ovn/kube-ovn-healthcheck
200-
- --port=10665
201-
- --tls={{- .Values.func.SECURE_SERVING }}
202-
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
197+
httpGet:
198+
port: 10665
199+
path: /readyz
200+
scheme: {{- ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}
203201
timeoutSeconds: 5
204202
livenessProbe:
205203
failureThreshold: 3
206204
initialDelaySeconds: 30
207205
periodSeconds: 7
208206
successThreshold: 1
209-
exec:
210-
command:
211-
- /kube-ovn/kube-ovn-healthcheck
212-
- --port=10665
213-
- --tls={{- .Values.func.SECURE_SERVING }}
214-
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
207+
httpGet:
208+
port: 10665
209+
path: /livez
210+
scheme: {{- ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}
215211
timeoutSeconds: 5
216212
resources:
217213
requests:

cmd/cmdmain.go

-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"k8s.io/klog/v2"
1313

14-
"github.com/kubeovn/kube-ovn/cmd/health_check"
1514
"github.com/kubeovn/kube-ovn/cmd/ovn_ic_controller"
1615
"github.com/kubeovn/kube-ovn/cmd/ovn_leader_checker"
1716
"github.com/kubeovn/kube-ovn/cmd/ovn_monitor"
@@ -24,7 +23,6 @@ const (
2423
CmdMonitor = "kube-ovn-monitor"
2524
CmdSpeaker = "kube-ovn-speaker"
2625
CmdWebhook = "kube-ovn-webhook"
27-
CmdHealthCheck = "kube-ovn-healthcheck"
2826
CmdOvnLeaderChecker = "kube-ovn-leader-checker"
2927
CmdOvnICController = "kube-ovn-ic-controller"
3028
)
@@ -97,8 +95,6 @@ func main() {
9795
speaker.CmdMain()
9896
case CmdWebhook:
9997
webhook.CmdMain()
100-
case CmdHealthCheck:
101-
health_check.CmdMain()
10298
case CmdOvnLeaderChecker:
10399
ovn_leader_checker.CmdMain()
104100
case CmdOvnICController:

cmd/controller/controller.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,14 @@ func CmdMain() {
9797
if err != nil {
9898
util.LogFatalAndExit(err, "failed to listen on %s", util.JoinHostPort(metricsAddr, config.PprofPort))
9999
}
100+
mux := http.NewServeMux()
101+
mux.HandleFunc("/healthz", util.DefaultHealthCheckHandler)
102+
mux.HandleFunc("/livez", util.DefaultHealthCheckHandler)
103+
mux.HandleFunc("/readyz", util.DefaultHealthCheckHandler)
100104
svr := manager.Server{
101105
Name: "health-check",
102106
Server: &http.Server{
103-
Handler: http.NewServeMux(),
107+
Handler: mux,
104108
MaxHeaderBytes: 1 << 20,
105109
IdleTimeout: 90 * time.Second,
106110
ReadHeaderTimeout: 32 * time.Second,

cmd/daemon/cniserver.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,14 @@ func main() {
159159
if err != nil {
160160
util.LogFatalAndExit(err, "failed to listen on %s", util.JoinHostPort(addr, config.PprofPort))
161161
}
162+
mux := http.NewServeMux()
163+
mux.HandleFunc("/healthz", util.DefaultHealthCheckHandler)
164+
mux.HandleFunc("/livez", util.DefaultHealthCheckHandler)
165+
mux.HandleFunc("/readyz", util.DefaultHealthCheckHandler)
162166
svr := manager.Server{
163167
Name: "health-check",
164168
Server: &http.Server{
165-
Handler: http.NewServeMux(),
169+
Handler: mux,
166170
MaxHeaderBytes: 1 << 20,
167171
IdleTimeout: 90 * time.Second,
168172
ReadHeaderTimeout: 32 * time.Second,

cmd/health_check/health_check.go

-58
This file was deleted.

cmd/ovn_monitor/ovn_monitor.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ func CmdMain() {
5151
if err != nil {
5252
util.LogFatalAndExit(err, "failed to listen on %s", util.JoinHostPort(metricsAddr, config.MetricsPort))
5353
}
54+
mux := http.NewServeMux()
55+
mux.HandleFunc("/healthz", util.DefaultHealthCheckHandler)
56+
mux.HandleFunc("/livez", util.DefaultHealthCheckHandler)
57+
mux.HandleFunc("/readyz", util.DefaultHealthCheckHandler)
5458
svr := manager.Server{
5559
Name: "health-check",
5660
Server: &http.Server{
57-
Handler: http.NewServeMux(),
61+
Handler: mux,
5862
MaxHeaderBytes: 1 << 20,
5963
IdleTimeout: 90 * time.Second,
6064
ReadHeaderTimeout: 32 * time.Second,

dist/images/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ COPY kube-ovn-controller /kube-ovn/kube-ovn-controller
1414
RUN ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-monitor && \
1515
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-speaker && \
1616
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-webhook && \
17-
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-healthcheck && \
1817
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-leader-checker && \
1918
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-ic-controller && \
2019
ln -s /kube-ovn/kube-ovn-controller /kube-ovn/kube-ovn-pinger && \

dist/images/install.sh

+29-36
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ OVSDB_CON_TIMEOUT=${OVSDB_CON_TIMEOUT:-3}
4747
OVSDB_INACTIVITY_TIMEOUT=${OVSDB_INACTIVITY_TIMEOUT:-10}
4848
ENABLE_LIVE_MIGRATION_OPTIMIZE=${ENABLE_LIVE_MIGRATION_OPTIMIZE:-true}
4949

50+
PROBE_HTTP_GET_SCHEMA="HTTP"
51+
if [ "$SECURE_SERVING" = "true" ]; then
52+
PROBE_HTTP_GET_SCHEMA="HTTPS"
53+
fi
54+
5055
# debug
5156
DEBUG_WRAPPER=${DEBUG_WRAPPER:-}
5257
RUN_AS_USER=65534 # run as nobody
@@ -4780,21 +4785,17 @@ spec:
47804785
- mountPath: /var/run/tls
47814786
name: kube-ovn-tls
47824787
readinessProbe:
4783-
exec:
4784-
command:
4785-
- /kube-ovn/kube-ovn-healthcheck
4786-
- --port=10660
4787-
- --tls=${SECURE_SERVING}
4788-
- --enable-metrics=$ENABLE_METRICS
4788+
httpGet:
4789+
port: 10660
4790+
path: /readyz
4791+
scheme: ${PROBE_HTTP_GET_SCHEMA}
47894792
periodSeconds: 3
47904793
timeoutSeconds: 5
47914794
livenessProbe:
4792-
exec:
4793-
command:
4794-
- /kube-ovn/kube-ovn-healthcheck
4795-
- --port=10660
4796-
- --tls=${SECURE_SERVING}
4797-
- --enable-metrics=$ENABLE_METRICS
4795+
httpGet:
4796+
port: 10660
4797+
path: /livez
4798+
scheme: ${PROBE_HTTP_GET_SCHEMA}
47984799
initialDelaySeconds: 300
47994800
periodSeconds: 7
48004801
failureThreshold: 5
@@ -5002,23 +5003,19 @@ spec:
50025003
initialDelaySeconds: 30
50035004
periodSeconds: 7
50045005
successThreshold: 1
5005-
exec:
5006-
command:
5007-
- /kube-ovn/kube-ovn-healthcheck
5008-
- --port=10665
5009-
- --tls=${SECURE_SERVING}
5010-
- --enable-metrics=$ENABLE_METRICS
5006+
httpGet:
5007+
port: 10665
5008+
path: /livez
5009+
scheme: ${PROBE_HTTP_GET_SCHEMA}
50115010
timeoutSeconds: 5
50125011
readinessProbe:
50135012
failureThreshold: 3
50145013
periodSeconds: 7
50155014
successThreshold: 1
5016-
exec:
5017-
command:
5018-
- /kube-ovn/kube-ovn-healthcheck
5019-
- --port=10665
5020-
- --tls=${SECURE_SERVING}
5021-
- --enable-metrics=$ENABLE_METRICS
5015+
httpGet:
5016+
port: 10665
5017+
path: /readyz
5018+
scheme: ${PROBE_HTTP_GET_SCHEMA}
50225019
timeoutSeconds: 5
50235020
resources:
50245021
requests:
@@ -5347,24 +5344,20 @@ spec:
53475344
initialDelaySeconds: 30
53485345
periodSeconds: 7
53495346
successThreshold: 1
5350-
exec:
5351-
command:
5352-
- /kube-ovn/kube-ovn-healthcheck
5353-
- --port=10661
5354-
- --tls=${SECURE_SERVING}
5355-
- --enable-metrics=$ENABLE_METRICS
5347+
httpGet:
5348+
port: 10661
5349+
path: /livez
5350+
scheme: ${PROBE_HTTP_GET_SCHEMA}
53565351
timeoutSeconds: 5
53575352
readinessProbe:
53585353
failureThreshold: 3
53595354
initialDelaySeconds: 30
53605355
periodSeconds: 7
53615356
successThreshold: 1
5362-
exec:
5363-
command:
5364-
- /kube-ovn/kube-ovn-healthcheck
5365-
- --port=10661
5366-
- --tls=${SECURE_SERVING}
5367-
- --enable-metrics=$ENABLE_METRICS
5357+
httpGet:
5358+
port: 10661
5359+
path: /readyz
5360+
scheme: ${PROBE_HTTP_GET_SCHEMA}
53685361
timeoutSeconds: 5
53695362
nodeSelector:
53705363
kubernetes.io/os: "linux"

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/docker/docker v27.5.1+incompatible
1616
github.com/emicklei/go-restful/v3 v3.12.1
1717
github.com/evanphx/json-patch/v5 v5.9.11
18+
github.com/go-logr/logr v1.4.2
1819
github.com/go-logr/stdr v1.2.2
1920
github.com/google/uuid v1.6.0
2021
github.com/httprunner/httprunner/v4 v4.3.7-0.20240124083022-402b74876a59
@@ -118,7 +119,6 @@ require (
118119
github.com/go-kit/kit v0.13.0 // indirect
119120
github.com/go-kit/log v0.2.1 // indirect
120121
github.com/go-logfmt/logfmt v0.6.0 // indirect
121-
github.com/go-logr/logr v1.4.2 // indirect
122122
github.com/go-ole/go-ole v1.3.0 // indirect
123123
github.com/go-openapi/jsonpointer v0.21.0 // indirect
124124
github.com/go-openapi/jsonreference v0.21.0 // indirect

0 commit comments

Comments
 (0)