From de9f968d78fc1cd1eba53298d93244c4366737b9 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Thu, 3 Oct 2024 09:56:51 -0400 Subject: [PATCH] app: make _healthz a real API route, match on k8s healthcheck user-agent Signed-off-by: Xe Iaso --- app/_healthz/route.ts | 14 ++++++++++++++ manifest/deployment.yaml | 4 +--- public/_healthz | 1 - 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 app/_healthz/route.ts delete mode 100644 public/_healthz diff --git a/app/_healthz/route.ts b/app/_healthz/route.ts new file mode 100644 index 0000000..59f4c8c --- /dev/null +++ b/app/_healthz/route.ts @@ -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", + }, + }); +}; \ No newline at end of file diff --git a/manifest/deployment.yaml b/manifest/deployment.yaml index 205764c..59961ba 100644 --- a/manifest/deployment.yaml +++ b/manifest/deployment.yaml @@ -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 \ No newline at end of file diff --git a/public/_healthz b/public/_healthz deleted file mode 100644 index a0aba93..0000000 --- a/public/_healthz +++ /dev/null @@ -1 +0,0 @@ -OK \ No newline at end of file