diff --git a/kubernetes/ingress.yml b/kubernetes/ingress.yml index 060b378..68da4ce 100644 --- a/kubernetes/ingress.yml +++ b/kubernetes/ingress.yml @@ -3,17 +3,6 @@ kind: Ingress metadata: name: ai-ha-elixir namespace: ai-ha-elixir - # annotations: - # # WebSocket support for LiveView - # nginx.ingress.kubernetes.io/proxy-read-timeout: "86400" - # nginx.ingress.kubernetes.io/proxy-send-timeout: "86400" - # nginx.ingress.kubernetes.io/proxy-http-version: "1.1" - # nginx.ingress.kubernetes.io/configuration-snippet: | - # proxy_set_header Upgrade $http_upgrade; - # proxy_set_header Connection "upgrade"; - # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # proxy_set_header X-Forwarded-Proto $scheme; - # proxy_set_header X-Forwarded-Host $host; spec: ingressClassName: nginx rules: diff --git a/kubernetes/statefulset.yml b/kubernetes/statefulset.yml index 09a4984..e82ed79 100644 --- a/kubernetes/statefulset.yml +++ b/kubernetes/statefulset.yml @@ -48,14 +48,14 @@ spec: key: AI_TOKEN readinessProbe: httpGet: - path: / + path: /health port: 4000 initialDelaySeconds: 10 periodSeconds: 5 failureThreshold: 3 livenessProbe: httpGet: - path: / + path: /health port: 4000 initialDelaySeconds: 20 periodSeconds: 10 @@ -67,4 +67,3 @@ spec: limits: memory: "512Mi" cpu: "500m" - diff --git a/lib/elixir_ai_web/controllers/health_controller.ex b/lib/elixir_ai_web/controllers/health_controller.ex new file mode 100644 index 0000000..52bc43e --- /dev/null +++ b/lib/elixir_ai_web/controllers/health_controller.ex @@ -0,0 +1,7 @@ +defmodule ElixirAiWeb.HealthController do + use ElixirAiWeb, :controller + + def index(conn, _params) do + json(conn, %{status: "ok"}) + end +end diff --git a/lib/elixir_ai_web/endpoint.ex b/lib/elixir_ai_web/endpoint.ex index f5bd0c5..0c685c6 100644 --- a/lib/elixir_ai_web/endpoint.ex +++ b/lib/elixir_ai_web/endpoint.ex @@ -38,6 +38,9 @@ defmodule ElixirAiWeb.Endpoint do cookie_key: "request_logger" plug Plug.RequestId + + plug Plug.Logger, log: :info, filter: &ElixirAiWeb.Endpoint.filter_health_check/1 + plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] plug Plug.Parsers, @@ -49,4 +52,8 @@ defmodule ElixirAiWeb.Endpoint do plug Plug.Head plug Plug.Session, @session_options plug ElixirAiWeb.Router + + # Filter health check requests from logs + def filter_health_check(%{request_path: "/health"}), do: false + def filter_health_check(_), do: :info end diff --git a/lib/elixir_ai_web/router.ex b/lib/elixir_ai_web/router.ex index d091cb3..bd6c330 100644 --- a/lib/elixir_ai_web/router.ex +++ b/lib/elixir_ai_web/router.ex @@ -14,6 +14,12 @@ defmodule ElixirAiWeb.Router do plug :accepts, ["json"] end + scope "/", ElixirAiWeb do + pipe_through :api + + get "/health", HealthController, :index + end + scope "/", ElixirAiWeb do pipe_through :browser