<p>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:</p>
<pre><code>Killing container with id docker//app:Conainter failed liveness probe. Container will be killed and recreated.
</code></pre>
<p>How to avoid this error?</p>

davidleongz
<p>You can use <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes" rel="nofollow noreferrer">startup probe</a> for applications that might require an additional startup time on their first initialization</p>
<pre><code>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
</code></pre>
<p>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 <code>restartPolicy</code></p>
