Configure health checks
Health checks allow you to configure tests to ensure maximum availability of your services. These health checks can be configured so that incoming traffic is only routed to available and healthy containers, and that containers which fail health checks are automatically terminated and restarted.
Health checks are important to ensure the processes running in your container are functioning correctly, and that they have had time to initialise before Northflank routes traffic to them. Without configured health checks Northflank will still try to warn about containers with failing processes, but as long as the container is able to run it will not be automatically restarted if there is an issue.
Health checks can be viewed and added on the health checks page of any service or job, excluding build services. Addons have pre-configured health checks.
A liveness probe will regularly test a given endpoint of a service to make sure that it is available and healthy. If the check fails the container will be marked for termination and a new container will be initialized.
A readiness probe will test whether a container is able to receive traffic after it has initialized. Upon success the new container will be marked ready, if the probe fails the container will be marked for termination and another initialized.
A startup probe is called during startup to make sure a new container has initialized successfully. Any configured liveness and readiness probes will not be called until the startup checks have succeeded. This allows you to check containers that may take a long time to startup while keeping more aggressive liveness and readiness probes for running containers. Consider using a startup probe if your containers are being terminated by failing liveness probes before they have a chance to initialize.
HTTP probes will send a GET request which passes if the response has a status code greater than or equal to 200 and less than 400.
The path should be defined relative to the root of the service, for example
/healthz to check the endpoint
TCP probes will test whether a connection can be made and gracefully terminated at the specified port.
CMD probes will execute the specified command inside the container which passes if command exits with a status code of 0.
The CMD is executed in the container and passes if the command succeeds, for example
/bin/sh -c "cat /tmp/healthz".
You can create a new health check from the health checks page of a combined or deployment service, or any job. You can also add a health check when creating a service or job in the advanced section.
Click add health check and select the type of health check you want to create. Only one of each type of health check can be added per service.
Choose which protocol to test the container by: HTTP, TCP, or CMD. If using HTTP, enter the endpoint to test, if using CMD, enter the command to run.
Use the dropdown menu to select the port to test (for HTTP and TCP), or enter it manually. The port must be exposed by your application, but does not need to be exposed in Northflank port configuration, as the request is made inside the container.
Click save changes to create or update the health checks, or add health check to add another.
You can also configure the following options by expanding the advanced menu in a health check:
- Initial delay: set the time (in seconds) to wait from container initialization before making the first check
- Interval: set the time (in seconds) to wait between checks
- Timeout: set the time (in seconds) to wait for a response from the container
- Max failures: specify the maximum number of attempts to check the container before failing.
- Success threshold: set the number of successful checks required for a readiness probe to pass
Container health checks can be viewed in:
- a combined or deployment service by selecting an entry from the containers list
- an addon by selecting an entry from the containers list
- a job by selecting an entry from the list of containers for a job run
The health check page displays each configured health check sorted by type, with the details of the result (such as latency and response), and the last time the status of the health check changed.
You can only view health checks for individual containers. Health checks for builds simply show the build status.
The list of containers will also include a column with the number of passing health checks.