We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Startup Probes

Some apps take quite a while to start (not any I've written, but you know, some other people's). They might need to load a big cache or run a bunch of database migrations before they can serve requests.

That can actually be a problem for liveness probes. If an app takes 180 seconds to start, but its liveness probe gives up after 15, Kubernetes kills the container before it ever finishes starting up... over and over again! Sure, you could add a long initialDelaySeconds to the liveness probe, but that makes it wait the full delay on every container start, even when the app starts quickly.

A startup probe solves this. Until it succeeds, Kubernetes holds off on the liveness and readiness probes. If it doesn't succeed in time, the container is restarted, just like with a failed liveness probe. Once it succeeds, it stops running, and the other probes take over:

startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 2
  failureThreshold: 30
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 5
  failureThreshold: 3

The config above gives the app up to 60 seconds (30 checks, 2 seconds apart) to start up. But once it's running, a hung container is restarted within about 15 seconds.

Assignment

The crawler team is about to ship a version of the crawler that loads a big keyword database when it starts, which can take up to 45 seconds.

Add startup and liveness probes to the crawler.

Submit the shell checks.