Skip to content

Commit

Permalink
add ping healthz and readyz for yurt-manager component (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
rambohe-ch authored Oct 24, 2023
1 parent 3db24a6 commit e7c4804
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions charts/yurt-manager/templates/yurt-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
10 changes: 10 additions & 0 deletions cmd/yurt-manager/app/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/cmd/init/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e7c4804

Please sign in to comment.