Skip to content

Commit

Permalink
use httpGet as liveness/readiness probe method (#4945)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian authored Feb 7, 2025
1 parent 7f30313 commit 57b3733
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 147 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ kind-install-chart: kind-load-image kind-untaint-control-plane
--set global.images.kubeovn.tag=$(VERSION) \
--set networking.NET_STACK=$(shell echo $${NET_STACK:-ipv4} | sed 's/^dual$$/dual_stack/') \
--set networking.ENABLE_SSL=$(shell echo $${ENABLE_SSL:-false}) \
--set func.SECURE_SERVING=$(shell echo $${SECURE_SERVING:-false}) \
--set func.ENABLE_BIND_LOCAL_IP=$(shell echo $${ENABLE_BIND_LOCAL_IP:-true}) \
--set func.ENABLE_OVN_IPSEC=$(shell echo $${ENABLE_OVN_IPSEC:-false}) \
--set func.ENABLE_ANP=$(shell echo $${ENABLE_ANP:-false}) \
Expand All @@ -535,6 +536,7 @@ kind-upgrade-chart: kind-load-image
--set global.images.kubeovn.tag=$(VERSION) \
--set networking.NET_STACK=$(shell echo $${NET_STACK:-ipv4} | sed 's/^dual$$/dual_stack/') \
--set networking.ENABLE_SSL=$(shell echo $${ENABLE_SSL:-false}) \
--set func.SECURE_SERVING=$(shell echo $${SECURE_SERVING:-false}) \
--set func.ENABLE_BIND_LOCAL_IP=$(shell echo $${ENABLE_BIND_LOCAL_IP:-true}) \
--set func.ENABLE_OVN_IPSEC=$(shell echo $${ENABLE_OVN_IPSEC:-false}) \
--set func.ENABLE_ANP=$(shell echo $${ENABLE_ANP:-false}) \
Expand Down
20 changes: 8 additions & 12 deletions charts/kube-ovn/templates/controller-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,17 @@ spec:
- mountPath: /var/run/tls
name: kube-ovn-tls
readinessProbe:
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10660
- --tls={{- .Values.func.SECURE_SERVING }}
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
httpGet:
port: 10660
path: /readyz
scheme: '{{ ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}'
periodSeconds: 3
timeoutSeconds: 5
livenessProbe:
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10660
- --tls={{- .Values.func.SECURE_SERVING }}
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
httpGet:
port: 10660
path: /livez
scheme: '{{ ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}'
initialDelaySeconds: 300
periodSeconds: 7
failureThreshold: 5
Expand Down
20 changes: 8 additions & 12 deletions charts/kube-ovn/templates/monitor-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,20 @@ spec:
initialDelaySeconds: 30
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10661
- --tls={{- .Values.func.SECURE_SERVING }}
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
httpGet:
port: 10661
path: /livez
scheme: '{{ ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}'
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10661
- --tls={{- .Values.func.SECURE_SERVING }}
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
httpGet:
port: 10661
path: /readyz
scheme: '{{ ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}'
timeoutSeconds: 5
nodeSelector:
kubernetes.io/os: "linux"
Expand Down
20 changes: 8 additions & 12 deletions charts/kube-ovn/templates/ovncni-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,20 @@ spec:
failureThreshold: 3
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10665
- --tls={{- .Values.func.SECURE_SERVING }}
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
httpGet:
port: 10665
path: /readyz
scheme: '{{ ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}'
timeoutSeconds: 5
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10665
- --tls={{- .Values.func.SECURE_SERVING }}
- --enable-metrics={{- .Values.networking.ENABLE_METRICS }}
httpGet:
port: 10665
path: /livez
scheme: '{{ ternary "HTTPS" "HTTP" .Values.func.SECURE_SERVING }}'
timeoutSeconds: 5
resources:
requests:
Expand Down
4 changes: 0 additions & 4 deletions cmd/cmdmain.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"k8s.io/klog/v2"

"github.com/kubeovn/kube-ovn/cmd/health_check"
"github.com/kubeovn/kube-ovn/cmd/ovn_ic_controller"
"github.com/kubeovn/kube-ovn/cmd/ovn_leader_checker"
"github.com/kubeovn/kube-ovn/cmd/ovn_monitor"
Expand All @@ -24,7 +23,6 @@ const (
CmdMonitor = "kube-ovn-monitor"
CmdSpeaker = "kube-ovn-speaker"
CmdWebhook = "kube-ovn-webhook"
CmdHealthCheck = "kube-ovn-healthcheck"
CmdOvnLeaderChecker = "kube-ovn-leader-checker"
CmdOvnICController = "kube-ovn-ic-controller"
)
Expand Down Expand Up @@ -97,8 +95,6 @@ func main() {
speaker.CmdMain()
case CmdWebhook:
webhook.CmdMain()
case CmdHealthCheck:
health_check.CmdMain()
case CmdOvnLeaderChecker:
ovn_leader_checker.CmdMain()
case CmdOvnICController:
Expand Down
6 changes: 5 additions & 1 deletion cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ func CmdMain() {
if err != nil {
util.LogFatalAndExit(err, "failed to listen on %s", util.JoinHostPort(metricsAddr, config.PprofPort))
}
mux := http.NewServeMux()
mux.HandleFunc("/healthz", util.DefaultHealthCheckHandler)
mux.HandleFunc("/livez", util.DefaultHealthCheckHandler)
mux.HandleFunc("/readyz", util.DefaultHealthCheckHandler)
svr := manager.Server{
Name: "health-check",
Server: &http.Server{
Handler: http.NewServeMux(),
Handler: mux,
MaxHeaderBytes: 1 << 20,
IdleTimeout: 90 * time.Second,
ReadHeaderTimeout: 32 * time.Second,
Expand Down
6 changes: 5 additions & 1 deletion cmd/daemon/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,14 @@ func main() {
if err != nil {
util.LogFatalAndExit(err, "failed to listen on %s", util.JoinHostPort(addr, config.PprofPort))
}
mux := http.NewServeMux()
mux.HandleFunc("/healthz", util.DefaultHealthCheckHandler)
mux.HandleFunc("/livez", util.DefaultHealthCheckHandler)
mux.HandleFunc("/readyz", util.DefaultHealthCheckHandler)
svr := manager.Server{
Name: "health-check",
Server: &http.Server{
Handler: http.NewServeMux(),
Handler: mux,
MaxHeaderBytes: 1 << 20,
IdleTimeout: 90 * time.Second,
ReadHeaderTimeout: 32 * time.Second,
Expand Down
58 changes: 0 additions & 58 deletions cmd/health_check/health_check.go

This file was deleted.

6 changes: 5 additions & 1 deletion cmd/ovn_monitor/ovn_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ func CmdMain() {
if err != nil {
util.LogFatalAndExit(err, "failed to listen on %s", util.JoinHostPort(metricsAddr, config.MetricsPort))
}
mux := http.NewServeMux()
mux.HandleFunc("/healthz", util.DefaultHealthCheckHandler)
mux.HandleFunc("/livez", util.DefaultHealthCheckHandler)
mux.HandleFunc("/readyz", util.DefaultHealthCheckHandler)
svr := manager.Server{
Name: "health-check",
Server: &http.Server{
Handler: http.NewServeMux(),
Handler: mux,
MaxHeaderBytes: 1 << 20,
IdleTimeout: 90 * time.Second,
ReadHeaderTimeout: 32 * time.Second,
Expand Down
1 change: 0 additions & 1 deletion dist/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ COPY kube-ovn-controller /kube-ovn/kube-ovn-controller
RUN ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-monitor && \
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-speaker && \
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-webhook && \
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-healthcheck && \
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-leader-checker && \
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-ic-controller && \
ln -s /kube-ovn/kube-ovn-controller /kube-ovn/kube-ovn-pinger && \
Expand Down
65 changes: 29 additions & 36 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ OVSDB_CON_TIMEOUT=${OVSDB_CON_TIMEOUT:-3}
OVSDB_INACTIVITY_TIMEOUT=${OVSDB_INACTIVITY_TIMEOUT:-10}
ENABLE_LIVE_MIGRATION_OPTIMIZE=${ENABLE_LIVE_MIGRATION_OPTIMIZE:-true}

PROBE_HTTP_SCHEME="HTTP"
if [ "$SECURE_SERVING" = "true" ]; then
PROBE_HTTP_SCHEME="HTTPS"
fi

# debug
DEBUG_WRAPPER=${DEBUG_WRAPPER:-}
RUN_AS_USER=65534 # run as nobody
Expand Down Expand Up @@ -4780,21 +4785,17 @@ spec:
- mountPath: /var/run/tls
name: kube-ovn-tls
readinessProbe:
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10660
- --tls=${SECURE_SERVING}
- --enable-metrics=$ENABLE_METRICS
httpGet:
port: 10660
path: /readyz
scheme: ${PROBE_HTTP_SCHEME}
periodSeconds: 3
timeoutSeconds: 5
livenessProbe:
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10660
- --tls=${SECURE_SERVING}
- --enable-metrics=$ENABLE_METRICS
httpGet:
port: 10660
path: /livez
scheme: ${PROBE_HTTP_SCHEME}
initialDelaySeconds: 300
periodSeconds: 7
failureThreshold: 5
Expand Down Expand Up @@ -5002,23 +5003,19 @@ spec:
initialDelaySeconds: 30
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10665
- --tls=${SECURE_SERVING}
- --enable-metrics=$ENABLE_METRICS
httpGet:
port: 10665
path: /livez
scheme: ${PROBE_HTTP_SCHEME}
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10665
- --tls=${SECURE_SERVING}
- --enable-metrics=$ENABLE_METRICS
httpGet:
port: 10665
path: /readyz
scheme: ${PROBE_HTTP_SCHEME}
timeoutSeconds: 5
resources:
requests:
Expand Down Expand Up @@ -5347,24 +5344,20 @@ spec:
initialDelaySeconds: 30
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10661
- --tls=${SECURE_SERVING}
- --enable-metrics=$ENABLE_METRICS
httpGet:
port: 10661
path: /livez
scheme: ${PROBE_HTTP_SCHEME}
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 7
successThreshold: 1
exec:
command:
- /kube-ovn/kube-ovn-healthcheck
- --port=10661
- --tls=${SECURE_SERVING}
- --enable-metrics=$ENABLE_METRICS
httpGet:
port: 10661
path: /readyz
scheme: ${PROBE_HTTP_SCHEME}
timeoutSeconds: 5
nodeSelector:
kubernetes.io/os: "linux"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/docker/docker v27.5.1+incompatible
github.com/emicklei/go-restful/v3 v3.12.1
github.com/evanphx/json-patch/v5 v5.9.11
github.com/go-logr/logr v1.4.2
github.com/go-logr/stdr v1.2.2
github.com/google/uuid v1.6.0
github.com/httprunner/httprunner/v4 v4.3.7-0.20240124083022-402b74876a59
Expand Down Expand Up @@ -118,7 +119,6 @@ require (
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
Expand Down
Loading

0 comments on commit 57b3733

Please sign in to comment.