diff --git a/charts/yurt-manager/templates/yurt-manager.yaml b/charts/yurt-manager/templates/yurt-manager.yaml index 7fe5908b353..7547599b91c 100644 --- a/charts/yurt-manager/templates/yurt-manager.yaml +++ b/charts/yurt-manager/templates/yurt-manager.yaml @@ -92,10 +92,22 @@ spec: - containerPort: {{ .Values.ports.healthProbe }} name: health protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: {{ .Values.ports.healthProbe }} + initialDelaySeconds: 60 + timeoutSeconds: 2 + periodSeconds: 10 + failureThreshold: 3 readinessProbe: httpGet: path: /readyz port: {{ .Values.ports.healthProbe }} + initialDelaySeconds: 60 + timeoutSeconds: 2 + periodSeconds: 10 + failureThreshold: 2 serviceAccountName: yurt-manager {{- if .Values.affinity }} affinity: {{ toYaml .Values.affinity | nindent 8 }} diff --git a/cmd/yurt-manager/app/manager.go b/cmd/yurt-manager/app/manager.go index 9c11a76449a..0bf88e1b5fe 100644 --- a/cmd/yurt-manager/app/manager.go +++ b/cmd/yurt-manager/app/manager.go @@ -33,6 +33,7 @@ import ( "k8s.io/klog/v2" "k8s.io/klog/v2/klogr" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/healthz" "github.com/openyurtio/openyurt/cmd/yurt-manager/app/config" "github.com/openyurtio/openyurt/cmd/yurt-manager/app/options" @@ -196,6 +197,15 @@ func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error { os.Exit(1) } + if err := mgr.AddHealthzCheck("health", healthz.Ping); err != nil { + setupLog.Error(err, "unable to set up health check") + os.Exit(1) + } + if err := mgr.AddReadyzCheck("check", healthz.Ping); err != nil { + setupLog.Error(err, "unable to set up ready check") + os.Exit(1) + } + for path, handler := range profile.GetPprofHandlers() { if err := mgr.AddMetricsExtraHandler(path, handler); err != nil { setupLog.Error(err, "unable to add pprof handler") diff --git a/test/e2e/cmd/init/constants/constants.go b/test/e2e/cmd/init/constants/constants.go index 3e3504ec57b..034e2d5b280 100644 --- a/test/e2e/cmd/init/constants/constants.go +++ b/test/e2e/cmd/init/constants/constants.go @@ -118,10 +118,22 @@ spec: - containerPort: 10272 name: health protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: 10272 + initialDelaySeconds: 60 + timeoutSeconds: 2 + periodSeconds: 10 + failureThreshold: 3 readinessProbe: httpGet: path: /readyz port: 10272 + initialDelaySeconds: 60 + timeoutSeconds: 2 + periodSeconds: 10 + failureThreshold: 2 serviceAccountName: yurt-manager affinity: nodeAffinity: