> For the complete documentation index, see [llms.txt](https://ibm-developer.gitbook.io/openshift101/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ibm-developer.gitbook.io/openshift101/workshop-openshift-3.11/workshop/exercise-05.md).

# Exercise 5: Health checks

In Kubernetes, liveness and readiness probes are essential for smoothly running applications. A probe is generally a REST `GET` call, but there are other types of probes available. Liveness probes are used to determine when to restart a container. For example, an application that is unhealthy and no longer responding to an API call would be restarted by OpenShift. Readiness probes determine when a container is ready to start receiving traffic. If a readiness probe fails, then the load balancer would deregister that service.

## Create Readiness and Liveness Probes

The `/info` endpoint on the Example Health application is a great way to check whether the application is running and responding to API calls -- it responds with a simple JSON payload.

Navigate to your deployment and choose `Actions > Edit Health Checks`.

![Health Checks](https://3116806241-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lo1CthFUNGt5R3JtwjG%2F-LpZs2v9MhvPXFGOm_bZ%2F-Lo6FR053W8MEqmRIIFu%2Fedit-health-checks.png?generation=1569355551959976\&alt=media)

Add a readiness probe:

![Readiness](https://3116806241-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lo1CthFUNGt5R3JtwjG%2F-LpZs2v9MhvPXFGOm_bZ%2F-Lo6FR07N7s4hYHfcVUO%2Fhealth-checks-ui.png?generation=1569355542316745\&alt=media)

Add a liveness probe:

![Liveness](https://3116806241-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lo1CthFUNGt5R3JtwjG%2F-LpZs2v9MhvPXFGOm_bZ%2F-Lo6FR09lH5vMYn6LubP%2Fliveness-probe.png?generation=1569355521525330\&alt=media)

Click Save.

If all works, everything should be the same. Let's check that the probes are really working though.

## Inject Failure

Let's edit the probe with a typo to see what happens when it fails. Edit the health check and change the path for the readiness probe to `/badpath`. Wait a few minutes and check your deployment - you'll notice that `0/1` containers are ready:

![Badpath](https://3116806241-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lo1CthFUNGt5R3JtwjG%2F-LpZs2v9MhvPXFGOm_bZ%2F-Lo6FR0BVQUQxq0m9usu%2Fbadpath.png?generation=1569355628354504\&alt=media)

Dive into your events and you'll see that the probe is failing, causing the platform to try and repeatedly restart your pod.

![Deeper Dive](https://3116806241-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lo1CthFUNGt5R3JtwjG%2F-LpZs2v9MhvPXFGOm_bZ%2F-Lo6FR0DC4GvPoNkh40D%2Fevents.png?generation=1569355554033585\&alt=media)

Using health checks gives your OpenShift service layer better reliability and helps you start with a strong foundation.
