Skip to content

Add /healthz healthcheck endpoint to FastAPI backend for container orchestration monitoring #4

@chigwell

Description

@chigwell

User Story
As a DevOps engineer maintaining containerized services,
I want to implement a healthcheck endpoint in the backend API
so that container orchestration tools can monitor service availability and automate recovery.

Background
The current FastAPI implementation in backend/app/main.py lacks a dedicated health probe endpoint. This prevents Kubernetes/Docker from performing liveness/readiness checks, risking undetected service degradation during deployments or runtime failures. The existing GET / endpoint (line 14) only serves basic functionality without operational awareness capabilities. Missing healthchecks could lead to prolonged downtime if containers remain scheduled while the application is unresponsive.

Acceptance Criteria

  • Add /healthz endpoint to backend/app/main.py that returns HTTP 200 + JSON {"status": "healthy"}
  • Endpoint must execute within 2 seconds for Kubernetes probe timeouts
  • Update backend Dockerfile to expose healthcheck configuration if required
  • Verify endpoint accessibility via curl -I http://localhost:80/healthz
  • Confirm Kubernetes would interpret HTTP 200 as healthy status through manual testing
  • Ensure endpoint doesn't require authentication and has minimal dependencies
  • Add endpoint documentation to the API section of README.md
  • Maintain existing CORS configuration (lines 8-13) for the new endpoint
  • Test container restart behavior when intentionally breaking the healthcheck

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions