fix: add /healthz endpoint to prevent K8s crash loop
- Added dedicated /healthz route returning 200 OK - Skip API health check in hooks.server.ts for /healthz path - Updated K8s liveness/readiness probes to use /healthz instead of /login - The /login probe was returning 503 when the API was unreachable, causing Kubernetes to kill and restart the pod in a loop
This commit is contained in:
@@ -101,6 +101,11 @@ function apiUnreachablePage(): Response {
|
||||
}
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
// Let Kubernetes health probes pass without hitting the external API
|
||||
if (event.url.pathname === "/healthz") {
|
||||
return await resolve(event);
|
||||
}
|
||||
|
||||
// Health-check the API before doing anything else.
|
||||
// /v1/teapot returns 418 when the API is alive.
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const GET: RequestHandler = async () => {
|
||||
return new Response(JSON.stringify({ status: "ok" }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user