Middle
Why is a startup probe needed when starting a heavy Java application? What timeouts should be set?
sobes.tech AI
Answer from AI
A heavy Java application can take a long time to start due to class loading, cache initialization, database connections, etc. If Kubernetes does not wait for the application to be ready, it may mistakenly consider the container as failed and restart it.
The startup probe helps Kubernetes understand that the application is still starting and that liveness or readiness checks should not be applied until the startup is complete.
It is recommended to set the startupProbe with a timeout and period sufficient for a full startup. For example:
- initialDelaySeconds: 10-30 (depending on the application)
- timeoutSeconds: 5
- periodSeconds: 10
- failureThreshold: 30 (to allow up to 5 minutes for startup)
This will help avoid premature restarts and ensure proper lifecycle management of the container.