Healthchecks are a way of checking the health of some resource.
Overview
At the end of this module, you will :
Learn to monitor resources
Learn to format it in a declarative mode
Learn the different type of scalability
Prerequisites
Create the directory data/highavailability in your home folder to manage the YAML file needed in this module.
mkdir~/data/highavailability
Liveness / Readiness Probe
Many applications running for long periods of time eventually transition to broken states, and cannot recover except by being restarted. Kubernetes provides liveness probes to detect and remedy such situations.
Sometimes, applications are temporarily unable to serve traffic. For example, an application might need to load large data or configuration files during startup, or depend on external services after startup. In such cases, the Pods must not be killed and no data has to be send. Kubernetes provides readiness probes to detect and mitigate these situations. A pod with containers reporting that they are not ready does not receive traffic through Kubernetes Services.
Readiness probes are configured similarly to liveness probes.
Command Check
This health check uses a command to attempt to get command return status. If the probe get a response from the specific path, the container is considered healthy, if it can't it is considered a failure.
Exercise n°1
Create an Pods based on the busybox Docker image to run a command and check his liveness.
Create a resource based on the previous yaml file definition.
kubectlapply-fdata/highavailability/01_pods.yaml
HTTP Request
This health check uses HTTP Request to attempt to get a website path on a specified port. If the probe get a response from the specific path, the container is considered healthy, if it can't it is considered a failure.
Exercise n°1
Create a Pods based on nginx Docker image and configure his liveness and readiness to check the HTTP response of the base path of the default nginx website on port 80.
Create a resource based on the previous yaml file definition.
kubectlapply-fdata/highavailability/02_pods.yaml
TCP Request
This healthcheck uses TCP Socket to attempt to open a socket to a container on a specified port. If a connection is established, the container is considered healthy, if it can't it is considered a failure.
Exercise n°1
Create a Pods based on nginx Docker image and configure his liveness and readiness to check the TCP response of the base path of the default nginx website on port 80.