cd ..
Kubernetes

Startup Probe in Kubernetes: Giving the Application Time to Start

Note: This content was produced from my class notes in the PICK – Intensive Container and Kubernetes Program, from LINUXtips, complemented by the official Kubernetes documentation.

Some applications need time to load configurations or prepare files before they start responding. A health check that starts too early can interrupt this process.

The Startup Probe allows you to define a specific check for initialization. In the notes from 05/10/2026, it appears with HTTP and TCP checks.

What does the Startup Probe check?

The startupProbe checks if the container has passed the configured startup test. As long as it hasn’t succeeded, the liveness and readiness probes for that container are not executed.

After the first success, the startup probe stops executing for that container’s run. If the container restarts, the process begins again. Reaching the failure threshold causes its termination; in a Deployment, it will be restarted according to the Always policy. Documentation on probes and lifecycle.

Therefore, the note that it is tested “only once” refers to the initialization phase: multiple attempts can occur until it passes or reaches the limit.

Comparing the three probes

ProbeGuiding question for configurationEffect of failure
StartupHas the application completed initialization?Upon reaching the limit, terminates the container.
LivenessIs the application still healthy?Upon reaching the limit, terminates the container.
ReadinessIs the application ready to receive traffic?Affects the Pod’s readiness for Services.

The articles on Liveness Probe and Readiness Probe detail the other two checks.

startupProbe parameters

startupProbe:
  httpGet:
    path: /
    port: 80
  initialDelaySeconds: 0
  periodSeconds: 5
  timeoutSeconds: 2
  failureThreshold: 24
FieldExample configuration
httpGetQueries / on port 80 of the Pod.
initialDelaySecondsDoes not add an initial wait.
periodSecondsConfigures 5-second intervals.
timeoutSecondsLimits each attempt to 2 seconds.
failureThresholdAllows up to 24 consecutive failures.

The product 24 × 5 represents an approximate budget of 120 seconds to initialize, not an exact timer. The startup’s successThreshold must be 1. Parameters documentation.

Lab: Nginx with delayed startup

To make the wait visible, the example adds a sleep 30 before starting Nginx. Save as nginx-startup-probe.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-startup-probe
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-startup-probe
  template:
    metadata:
      labels:
        app: nginx-startup-probe
    spec:
      containers:
        - name: nginx
          image: nginx:1.28.0
          command: ["/bin/sh", "-c"]
          args:
            - sleep 30; exec nginx -g 'daemon off;'
          ports:
            - name: http
              containerPort: 80
          startupProbe:
            httpGet:
              path: /
              port: http
            periodSeconds: 5
            timeoutSeconds: 2
            failureThreshold: 24
          livenessProbe:
            httpGet:
              path: /
              port: http
            periodSeconds: 10
            timeoutSeconds: 2
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /
              port: http
            periodSeconds: 5
            timeoutSeconds: 2
            failureThreshold: 3

The wait occurs inside the observed container. Using an init container for this delay would not demonstrate the same behavior, as it would execute before the Nginx container.

Applying and observing

kubectl apply -f nginx-startup-probe.yaml
kubectl get pods -l app=nginx-startup-probe -w

End the watch with Ctrl+C. Then, check the Pod’s name and its events:

kubectl get pods -l app=nginx-startup-probe
kubectl describe pod <nome-do-pod>
kubectl rollout status deployment/nginx-startup-probe

During the sleep, we expect the startup probe to find the port still closed. When Nginx starts and responds, it can pass, releasing the other checks. Observe READY and RESTARTS to verify the result.

Triggering a failure

In the manifest, only change the startupProbe port to 81 and reapply:

kubectl apply -f nginx-startup-probe.yaml
kubectl get pods -l app=nginx-startup-probe -w

Nginx will continue listening on port 80. Check the new Pod with describe to follow the failures and, after the limit, the restart. Repeated failures can result in CrashLoopBackOff.

Change the port back to http and apply the manifest again to recover the example. When finished:

kubectl delete -f nginx-startup-probe.yaml

These steps are a proposed practice based on the notes; the photos do not record the execution of this manifest.

TCP alternative

To check only for port opening, replace the httpGet block of the startup probe with:

tcpSocket:
  port: 80

Choose a single mechanism per probe. A TCP connection proves that the port accepts connections; an HTTP endpoint can represent a more specific application condition.

Conclusion

The Startup Probe creates its own stage for initialization, allowing liveness and readiness checks to remain appropriate for the application after it starts responding.

References

What did you think?