Monitoring Health
Learn why it is important to monitor the health of services and how Kubernetes probes can help to achieve this.
Why to monitor health?
The go-demo-2
Docker image is designed to fail on the first sign of trouble. In cases like that, there is no need for any health checks. When things go wrong, the following things happen:
- The main process stops.
- The container hosting the main process stops as well.
- Kubernetes restarts the failed container.
However, not all services are designed to fail fast. Even those services that are designed to fail might still benefit from additional health checks. For example, a back-end API can be up and running but, serves requests much slower than expected due to a memory leak. Such a situation might benefit from a health check that would verify whether the service responds within, for example, two seconds.
Kubernetes probes
To monitor health, we can exploit Kubernetes liveness and readiness probes.