File tree Expand file tree Collapse file tree 4 files changed +67
-0
lines changed
deployment/mcad-controller/templates Expand file tree Collapse file tree 4 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ type ServerOption struct {
56
56
QuotaRestURL string
57
57
HealthProbeListenAddr string
58
58
DispatchResourceReservationTimeout int64
59
+ ReadinessProbeListenAddr string
59
60
}
60
61
61
62
// NewServerOption creates a new CMServer with a default config.
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import (
38
38
"github.com/project-codeflare/multi-cluster-app-dispatcher/cmd/kar-controllers/app/options"
39
39
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/queuejob"
40
40
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/health"
41
+ ready "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/ready"
41
42
42
43
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
43
44
)
@@ -79,10 +80,12 @@ func Run(opt *options.ServerOption) error {
79
80
func listenHealthProbe (opt * options.ServerOption ) error {
80
81
handler := http .NewServeMux ()
81
82
handler .Handle ("/healthz" , & health.Handler {})
83
+ handler .Handle ("/readyz" , & ready.Handler {})
82
84
err := http .ListenAndServe (opt .HealthProbeListenAddr , handler )
83
85
if err != nil {
84
86
return err
85
87
}
86
88
87
89
return nil
88
90
}
91
+
Original file line number Diff line number Diff line change @@ -322,6 +322,18 @@ spec:
322
322
imagePullPolicy : {{ .Values.httpServerImage.pullPolicy }}
323
323
ports :
324
324
- containerPort : 80
325
+ livesnessProbe :
326
+ httpGet :
327
+ path : /healthz
328
+ port : 80
329
+ initialDelaySeconds : 30
330
+ timeoutSeconds : 5
331
+ readinessProbe :
332
+ httpGet :
333
+ path : /readyz
334
+ port : 80
335
+ initialDelaySeconds : 30
336
+ timeoutSeconds : 5
325
337
- name : " quota-management"
326
338
image : " {{ .Values.httpImage.repository }}:{{ .Values.httpImage.tag }}"
327
339
imagePullPolicy : {{ .Values.httpImage.pullPolicy }}
@@ -333,6 +345,18 @@ spec:
333
345
#{{ if .Values.volumes.hostPath }}
334
346
- name : agent-config-vol
335
347
mountPath : /root/kubernetes
348
+ livesnessProbe :
349
+ httpGet :
350
+ path : /healthz
351
+ port : 80
352
+ initialDelaySeconds : 30
353
+ timeoutSeconds : 5
354
+ readinessProbe :
355
+ httpGet :
356
+ path : /readyz
357
+ port : 80
358
+ initialDelaySeconds : 30
359
+ timeoutSeconds : 5
336
360
#{{ end }}
337
361
#{{ end }}
338
362
- name : {{ .Chart.Name }}
@@ -357,6 +381,18 @@ spec:
357
381
- name : agent-config-vol
358
382
mountPath : /root/kubernetes
359
383
#{{ end }}
384
+ livesnessProbe :
385
+ httpGet :
386
+ path : /healthz
387
+ port : 80
388
+ initialDelaySeconds : 30
389
+ timeoutSeconds : 5
390
+ readinessProbe :
391
+ httpGet :
392
+ path : /readyz
393
+ port : 80
394
+ initialDelaySeconds : 30
395
+ timeoutSeconds : 5
360
396
#{{ if .Values.configMap.name }}
361
397
envFrom :
362
398
- configMapRef :
Original file line number Diff line number Diff line change
1
+ package readiness
2
+
3
+ import (
4
+ "net/http"
5
+ "net/http/httptest"
6
+ "testing"
7
+ )
8
+
9
+ func TestReadinessProbe (t * testing.T ) {
10
+ req , err := http .NewRequest ("GET" , "/readyz" , nil )
11
+ if err != nil {
12
+ t .Fatal (err )
13
+ }
14
+
15
+ rr := httptest .NewRecorder ()
16
+ handler := Handler {}
17
+ handler .ServeHTTP (rr , req )
18
+ if status := rr .Code ; status != http .StatusOK {
19
+ t .Errorf ("handler returned unexpected status: %v" , status )
20
+ }
21
+
22
+ expected := "ok"
23
+ if rr .Body .String () != expected {
24
+ t .Errorf ("handler returned unexpected body: got %v expected %v" ,
25
+ rr .Body .String (), expected )
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments