0
0
KubernetesConceptBeginner · 3 min read

Startup Probe in Kubernetes: What It Is and How It Works

A startupProbe in Kubernetes is a special check that tells the system when an application inside a container has started successfully. It helps Kubernetes wait longer for slow-starting apps before marking them as failed, avoiding premature restarts.
⚙️

How It Works

Imagine you have a slow cooker that takes a long time to prepare a meal. You wouldn’t want to open the lid too soon and think the meal is not ready. Similarly, some applications inside Kubernetes containers take longer to start up. The startupProbe acts like a timer and a check to see if the app has started properly.

When a container starts, Kubernetes uses the startupProbe to check if the app is ready. If the app takes a long time, Kubernetes keeps checking without restarting the container too early. Once the app passes the startup check, Kubernetes switches to using other probes like livenessProbe to monitor if the app stays healthy.

💻

Example

This example shows a startupProbe that checks if a web server is ready by trying to connect to port 8080. It waits 5 seconds before starting checks and tries every 3 seconds, failing after 10 tries.

yaml
apiVersion: v1
kind: Pod
metadata:
  name: startup-probe-example
spec:
  containers:
  - name: slow-start-app
    image: nginx
    startupProbe:
      tcpSocket:
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 3
      failureThreshold: 10
    livenessProbe:
      httpGet:
        path: /
        port: 8080
      initialDelaySeconds: 30
      periodSeconds: 10
Output
Pod 'startup-probe-example' starts and Kubernetes waits up to 35 seconds (5 + 3*10) checking port 8080 before restarting the container if it fails to start.
🎯

When to Use

Use startupProbe when your application takes a long time to start and might fail liveness checks before it is ready. This prevents Kubernetes from restarting the container too soon.

For example, apps that load large data, run migrations, or initialize complex services benefit from startup probes. It improves stability by giving the app enough time to become healthy.

Key Points

  • Startup probe checks if the app has started successfully.
  • It delays liveness checks until startup is complete.
  • Prevents premature container restarts.
  • Useful for slow-starting applications.
  • Configured with initialDelaySeconds, periodSeconds, and failureThreshold.

Key Takeaways

Startup probe helps Kubernetes know when a slow-starting app is ready.
It prevents early restarts by delaying liveness checks until startup completes.
Configure startup probe with timing settings to match your app’s startup time.
Use startup probe for apps that need extra time to initialize before running.
Once startup probe succeeds, Kubernetes switches to regular health checks.