Skip to content

Commit

Permalink
Add readiness probe
Browse files Browse the repository at this point in the history
  • Loading branch information
air-31 committed Jan 8, 2025
1 parent 55d9bf2 commit 224f768
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions operators/deploy/cloudimg-registry/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ spec:
- name: http
containerPort: 8080
protocol: TCP
readinessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 3
periodSeconds: 3
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
Expand Down
12 changes: 12 additions & 0 deletions operators/pkg/ciregistry/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,15 @@ func HandleDeleteTag(log klog.Logger) usecase.Interactor {

return u
}

// HealthzHandler is used for performing readiness probes.
func HealthzHandler() usecase.Interactor {
u := usecase.NewInteractor(func(_ context.Context, _ struct{}, out *BasicJSONReply) error {
out.Success = true
return nil
})

u.SetExpectedErrors(status.Unavailable)

return u
}
1 change: 1 addition & 0 deletions operators/pkg/ciregistry/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func NewRouter() http.Handler {
s.OpenAPISchema().SetDescription("API for managing cloudimage repositories and metadata.")
s.OpenAPISchema().SetVersion("1.0.0")

s.Get("/healthz", HealthzHandler())
s.Get("/{repo}", HandleGetImages(klog.LoggerWithName(log, "imagelist")))
s.Get("/{repo}/{image}", HandleGetImageTags(klog.LoggerWithName(log, "taglist")))
s.Get("/{repo}/{image}/{tag}", HandleGetImage(klog.LoggerWithName(log, "imagebin")), nethttp.SuccessfulResponseContentType("application/octet-stream"))
Expand Down

0 comments on commit 224f768

Please sign in to comment.