openshift101
workshop-openshift-3.11
workshop-openshift-3.11
  • Introduction
  • Getting Started
    • Create an IBM Cloud account / Access an OpenShift cluster
    • Accessing the IBM Cloud Shell
    • A General Docker Tutorial
  • Workshop
    • Exercise 1: Deploy a Node application with Source-to-Image
    • Exercise 2: Logging and monitoring
    • Exercise 3: Metrics and dashboards
    • Exercise 4: Scaling the application
    • Exercise 5: Health checks
    • Exercise 6: Deploy a Node application with Build Config (CLI version)
  • Alternates
    • Exercise 1: Deploy a Java application with a Docker Image
    • Exercise 6: Deploy a Java application with Build Config (CLI version)
  • Resources
    • FAQ
    • Setup CLI Access for the cluster
    • Certification on CognitiveClass.ai
    • IBM Developer
    • Docs: Red Hat OpenShift on IBM Cloud
  • Survey
    • Tell us how we did
Powered by GitBook
On this page
  • Create Readiness and Liveness Probes
  • Inject Failure

Was this helpful?

  1. Workshop

Exercise 5: Health checks

PreviousExercise 4: Scaling the applicationNextExercise 6: Deploy a Node application with Build Config (CLI version)

Last updated 5 years ago

Was this helpful?

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.

Add a readiness probe:

Add a liveness probe:

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:

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

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

Health Checks
Readiness
Liveness
Badpath
Deeper Dive