app: make _healthz a real API route, match on k8s healthcheck user-agent

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso 2024-10-03 09:56:51 -04:00
parent 0dabe6e399
commit de9f968d78
No known key found for this signature in database
3 changed files with 15 additions and 4 deletions

14
app/_healthz/route.ts Normal file
View File

@ -0,0 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
export const GET = async (req: NextRequest) => {
if (req.headers.get("user-agent") !== "healthz") {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
return new Response("OK", {
status: 200,
headers: {
"Content-Type": "text/plain",
},
});
};

View File

@ -47,9 +47,7 @@ spec:
path: /_healthz
port: 3000
httpHeaders:
- name: x-real-ip
value: "100.100.100.100"
- name: user-agent
value: "Kubernetes healthchecks"
value: "healthz"
initialDelaySeconds: 3
periodSeconds: 3

View File

@ -1 +0,0 @@
OK