16.1.1.15. Healthcheck endpoints

This module is intended to ensure the application can be monitored effectively and provide insights into whether the application and its dependencies are operational. A primary intention was to create a way for Kubernetes to check on containers.

Endpoints:
  • /healthz : Combined health check for liveness and readiness.

  • /healthz/startupz : Startup check to confirm if the app has started.

  • /healthz/livez : Liveness check to verify if the app is running.

  • /healthz/readyz : Readiness check to confirm if the app is ready to serve requests.

  • /healthz/resolversz : Resolver check to test the connection to all LDAP and SQL resolvers.

The corresponding code is tested in tests/test_api_healthcheck.py.

For information on the current standard and how to configure these probes, see the Kubernetes documentations:

https://kubernetes.io/docs/reference/using-api/health-checks/

https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/

GET /healthz

Checks the liveness and readiness of the application by verifying both the /livez and /readyz endpoints.

resheader Content-Type:

application/json

status 200:

Application is live and ready.

status 503:

Application is live but not ready.

Example Request:

GET /healthz HTTP/1.1
Host: example.com
Accept: application/json

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": "ready",
    "hsm": "OK"
}
GET /healthz/startupz

Startup check endpoint that indicates if the app has started.

resheader Content-Type:

application/json

status 200:

Application has started.

status 503:

Application has not started yet.

Example Request:

GET /healthz/startupz HTTP/1.1
Host: example.com
Accept: application/json

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": "started"
}
GET /healthz/livez

Liveness check endpoint that indicates if the app is running.

resheader Content-Type:

application/json

status 200:

Application is live.

Example Request:

GET /healthz/livez HTTP/1.1
Host: example.com
Accept: application/json

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": "OK"
}
GET /healthz/readyz

Readiness check endpoint that indicates if the app is ready to serve requests. This endpoint checks the readiness of the app and its dependencies, including the Hardware Security Module (HSM).

resheader Content-Type:

application/json

status 200:

Application is ready.

status 503:

Application is not ready or HSM is not ready.

Example Request:

GET /healthz/readyz HTTP/1.1
Host: example.com
Accept: application/json

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": "ready",
    "hsm": "OK"
}
GET /healthz/resolversz

Resolver check endpoint that tests the connection to all LDAP and SQL resolvers. Tests the connectivity to both LDAP and SQL resolvers, returning their individual connection statuses.

resheader Content-Type:

application/json

status 200:

All resolvers have been successfully checked.

status 503:

Failed to check resolvers or an error occurred.

Example Request:

GET /healthz/resolversz HTTP/1.1
Host: example.com
Accept: application/json

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": "ready",
    "ldapresolvers" {
        "ldapresolver1": "OK",
        "ldapresolver2": "OK"
    },
    "sqlresolvers": {
        "sqlresolver1": "OK",
        "sqlresolver2": "OK"
    },
}