How to control the status of openshift pod to running only when application inside the pod is actually started?

3/9/2020

The Tomcat server bundled inside the pod is actually taking around 10 mins to start, but the pod's status is getting changed to running withing few seconds. Can we control the status of the pod until the actual application is started?

-- Hanmandlu Junjur
docker
kubernetes
openshift
openshift-enterprise

1 Answer

3/9/2020

You will need you combination of startup probe and readiness probe for your use case.

Startup Probe

Readiness Probe

Example :

readinessProbe:
  tcpSocket:
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10
  timeoutSeconds: 2
  failureThreshold: 1
  successThreshold: 1
livenessProbe:
  tcpSocket:
    port: 8080
  initialDelaySeconds: 15
  periodSeconds: 20
  timeoutSeconds: 2
  failureThreshold: 1
  successThreshold: 1
startupProbe:
  tcpSocket:
    port: 8080
  failureThreshold: 30
  periodSeconds: 20

The application will have a maximum of 10 minutes (30 * 20 = 600s) to finish its startup.

-- DT.
Source: StackOverflow