How to increase the time that Openshift/kubernetes need for run script database with flyway during pod start? Error failed liveness probe

12/15/2020

During the microservices deployment, I use openshift, docker, with springboot and flyway. If flyway take a lot of minutes with script database during then deploy Health Check throw this error:

Killing container with id docker//app:Conainter failed liveness probe. Container will be killed and recreated.

How to avoid this error?

-- davidleongz
flyway
kubernetes
openshift
spring-boot

1 Answer

12/15/2020

You can use startup probe for applications that might require an additional startup time on their first initialization

ports:
- name: liveness-port
  containerPort: 8080
  hostPort: 8080

livenessProbe:
  httpGet:
    path: /healthz
    port: liveness-port
  failureThreshold: 1
  periodSeconds: 10

startupProbe:
  httpGet:
    path: /healthz
    port: liveness-port
  failureThreshold: 30
  periodSeconds: 10

The application will have a maximum of 5 minutes (30 * 10 = 300s) to finish its startup. Once the startup probe has succeeded once, the liveness probe takes over to provide a fast response to container deadlocks. If the startup probe never succeeds, the container is killed after 300s and subject to the pod's restartPolicy

-- Arghya Sadhu
Source: StackOverflow