Guarantee application availability with OpenShift readiness probes
Readiness probes allow Kubernetes to inspect the health of your application pod and use it only if it's ready for traffic. This activity will enable you to reduce or eliminate downtime with the simple addition of a readiness probe.

Red Hat OpenShift allows you to perform rolling updates of existing running applications. This feature, which is native to Kubernetes, means you can spin up a different version of an application—newer or older—and automatically route traffic to different versions as appropriate. When done correctly, this can be used to create a zero downtime deployment.
That last part—done correctly—is the focus of this sandbox activity. We'll guide you through the process of deploying an application, adding a Readiness Check to the application, actively using the application, and then initiating a rolling update of the application.
Expected time to completion: Five minutes
Prerequisites
You must first complete the OpenShift Sandbox Activity entitled Code deployment with Kubernetes rolling update.
Working environment for this activity
This activity will require you to work at the command line, using either bash or PowerShell.
What you'll be doing
- Log in to your OpenShift Sandbox at the command line
- Create a readiness probe for an existing deployment
- Run a curl command loop to view the application output
- Change deployment image to version 3
- Observe rolling deployment results
Part 1: Log in to your OpenShift Sandbox at the command line
Step 1.1
Log in to your OpenShift Sandbox by following these instructions.
Create a readiness probe for an existing deployment
Step 1.1
Run the following command to create the readiness probe:
oc set probe deploy/myboot --readiness --get-url=http://:8080/health
Part 2: Run a curl command loop to view the application output
Step 2.1
Run the following command to see the URL of the application:
oc get routes
You will see output similar to the following:
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
myboot myboot-rhn-engineering-dschenck-dev.apps.sandbox.x8i5.p1.openshiftapps.com myboot http None
Step 2.2
We will now run a curl command loop against this URL to see the application output. Replace the URL in the following command based on the results of the previous command (oc get routes) and enter it at a command line.
If you are using bash:
for ((i=1;i<=10000;i++)); do curl http://myboot-rhn-engineering-foo-dev.apps.sandbox.x8i5.p1.openshiftapps.com; sleep .01; done;
If you are using PowerShell:
while ($true) { (curl myboot-rhn-engineering-foo-dev.apps.sandbox.x8i5.p1.openshiftapps.com).content;start-sleep -Milliseconds 200; }
Figure 1 shows an example of the kind of output you can expect.
[myboot_curl_powershell_output.png] Figure 1: curl command loop output.
Part 3: Change deployment image to version 3
Step 3.1
Run the following command to switch to the version 3 image for the myboot application:
oc set image deploy/myboot myboot=quay.io/rhdevelopers/myboot:v3
Part 4: Observe rolling deployment results
Step 4.1
As the command in step 3.1 is processed, you will see the output of the curl loop change. This is a result of the rolling update with zero downtime.
Learn more
Learn more about Kubernetes probes from these Red Hat resources: