Chapter 5. Migrating Application to OpenShift 4

5.1. Updating Liveness and Readiness Probe Configuration for OpenShift 4

The YAML configuration of probes must be adjusted when migrating to OpenShift 4.

On OpenShift 3.11, the default YAML configuration for liveness probes is similar to the following code example:

Example YAML Configuration for OpenShift 3.11 Liveness Probe

livenessProbe:
        exec:
          command:
            - /bin/bash
            - '-c'
            - /opt/eap/bin/livenessProbe.sh
        initialDelaySeconds: 60
        periodSeconds: 10
        successThreshold: 1
        failureThreshold: 3

In this example, the liveness probe is located at /opt/eap/bin/livenessProbe.sh within the JBoss EAP image. The probe is triggered the first time after a 60 second initial delay and then every 10 seconds after a pod is started on the JBoss EAP server.

The probe is considered a failure after 3 attempts to call the livenessProbe.sh script. The container is deemed unhealthy, and OpenShift will restart the JBoss EAP container in its respective pod.

On OpenShift 3.11, a single call lasts 5 seconds before it returns as a success or failure. On OpenShift 4, a single call lasts less than 1 second.

On OpenShift 3.11, a call to the probe lasts 5 seconds, followed by a 10 second waiting period. This means that 3 calls last approximately 35 seconds before the container inside the pod is restarted if the JBoss EAP image is unhealthy.

On OpenShift 4, 3 calls last approximately 23 seconds. The configuration of the probe for OpenShift 4 should be adjusted in the YAML configuration as follows:

Example YAML Configuration for OpenShift 4 Liveness Probe

livenessProbe:
        exec:
          command:
            - /bin/bash
            - '-c'
            - /opt/eap/bin/livenessProbe.sh
        initialDelaySeconds: 60
        periodSeconds: 16
        successThreshold: 1
        failureThreshold: 3

In this example, periodSeconds has been increased by 6 seconds. Now the first call lasts 1 second, followed by a 16 second waiting period. Three calls would last approximately 34 seconds, which is nearly equivalent to the OpenShift 3.11 behavior of the probe.

For readiness probes, a similar adjustment must be made to the YAML configuration:

Example YAML Configuration for OpenShift 4 Readiness Probe

readinessProbe:
        exec:
          command:
            - /bin/bash
            - '-c'
            - /opt/eap/bin/readinessProbe.sh
        initialDelaySeconds: 10
        periodSeconds: 16
        successThreshold: 1
        failureThreshold: 3

Additional Resources

Liveness and Readiness Probes