Video in progress

Strong Junior 🧩 Microservices

Why do you need a startup probe in Kubernetes? What happens without one on a slow-starting Spring Boot service?

A startup probe delays the liveness and readiness checks until the application has fully started. Without it, liveness sees a service that takes 70 seconds to come up as "dead" and keeps restarting it before it can finish starting.

📖 Answer

The situation: the service runs a Flyway migration at startup, warms the cache, and is ready in 70 seconds. The liveness probe starts after 10 seconds and restarts it if it fails 3 times. The result is CrashLoopBackOff: the pod never comes up, and there's no error in the log.

People used to patch this with initialDelaySeconds: 120. The problem: now even a pod that has really frozen goes unchecked for 2 minutes after every restart.

A startup probe is more precise:

startupProbe:
  httpGet:
    path: /actuator/health/liveness
    port: 8080
  periodSeconds: 5
  failureThreshold: 30      # waits up to 5 × 30 = 150 seconds
livenessProbe:
  httpGet:
    path: /actuator/health/liveness
    port: 8080
  periodSeconds: 10

As soon as the startup probe succeeds, it stops and liveness takes over. If the start is fast, the wait is short too.

If Spring Boot detects it's running inside Kubernetes, it enables the /actuator/health/liveness and /readiness groups itself. Readiness becomes ACCEPTING_TRAFFIC only once the application is fully ready, so traffic doesn't arrive before startup finishes, either.