diff --git a/api/v1/health/router.go b/api/v1/health/router.go new file mode 100644 index 0000000..d46fc25 --- /dev/null +++ b/api/v1/health/router.go @@ -0,0 +1,16 @@ +package health + +import ( + "net/http" + + "github.com/go-chi/chi/v5" +) + +func Router() chi.Router { + r := chi.NewRouter() + r.Get("/", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte("OK")) + }) + return r +} diff --git a/api/v1/v1.go b/api/v1/v1.go index 296ed63..e4ffe1b 100644 --- a/api/v1/v1.go +++ b/api/v1/v1.go @@ -2,6 +2,7 @@ package v1 import ( "reverse-watch/api/v1/admin" + "reverse-watch/api/v1/health" "reverse-watch/api/v1/marketplace" "reverse-watch/api/v1/reversals" "reverse-watch/api/v1/users" @@ -11,6 +12,7 @@ import ( func Router() chi.Router { r := chi.NewRouter() + r.Mount("/health", health.Router()) r.Mount("/marketplace", marketplace.Router()) r.Mount("/reversals", reversals.Router()) r.Mount("/users", users.Router()) diff --git a/deploy/reverse-watch-service.yaml b/deploy/reverse-watch-service.yaml index 2cc1cad..8614a68 100644 --- a/deploy/reverse-watch-service.yaml +++ b/deploy/reverse-watch-service.yaml @@ -71,6 +71,14 @@ spec: failureThreshold: 1 tcpSocket: port: 80 + livenessProbe: + initialDelaySeconds: 5 + timeoutSeconds: 1 + periodSeconds: 10 + failureThreshold: 3 + httpGet: + path: /api/v1/health + port: 80 traffic: - percent: 100 latestRevision: true