Marcio Cunha

Kubernetes deploy failing? How to create resilient probes

Learn how to correctly configure liveness and readiness probes in Kubernetes to prevent unnecessary restarts and production instability.

Marcio Cunha•4 min
Also available in:PortuguêsEspañol
Summary
  • Configuring health checks requires separating liveness testing from traffic readiness validation.
  • Aggressive timeout values usually take down applications under legitimate load instead of fixing real issues.
  • Dedicated health endpoints prevent overloading the main database during automated system checks.
  • Initial grace periods protect heavy services that take time to load dependencies at startup.
  • Adjusting tolerance parameters ensures smooth traffic transitions without killing valid pods in production.

What probes are and why your applications keep restarting

Managing containers in enterprise environments requires the orchestrator to know precisely when an application is healthy, ready to receive traffic, or completely frozen. Kubernetes handles this using inspection routines called probes, which periodically test pod health. When these checks fail due to misconfiguration, the system enters a destructive cycle of unnecessary restarts, often taking down services that were merely experiencing a momentary latency spike.

In practice, this means a perfectly functional application can be killed by its own monitoring system if tolerance limits are set too strictly. Understanding the conceptual and operational difference between liveness and readiness checks is the first step to shielding your infrastructure against phantom failures. If you have ever investigated advanced adjustments in liveness probes, you know that balancing resilience and strictness is delicate and requires detailed technical planning.

Understanding the difference between liveness and readiness probes

Kubernetes divides health monitoring into two distinct missions that should never be confused or treated the same way. The liveness probe has the sole and exclusive function of deciding whether a container needs to be destroyed and recreated from scratch. If this check fails repeatedly, the container runtime terminates the current process in hopes that a new instance will start without the previous error. It should be used strictly for unrecoverable crashes, such as deep deadlocks in threads that freeze the entire application.

On the other hand, the readiness probe answers a completely different question: is the container ready to accept client requests right now? When the readiness check fails, Kubernetes does not kill the container; it temporarily removes the pod from the service load balancer, preventing external traffic from reaching it. This frequently happens during traffic spikes or cache warming phases, where the system remains alive and processing background tasks but needs a few seconds of breathing room before handling new connections.

Common pitfalls when configuring health endpoints

A classic mistake made by engineering teams when structuring probes is pointing checks to heavy application routes. If your health endpoint performs deep database queries, validates multiple external microservices, and scans the file system every few seconds, you have built a chaos generator. Under high real traffic load, the database might respond with elevated latency, causing the health check to fail. Consequently, Kubernetes assumes the entire application has crashed, restarting the pod and further worsening the database overload.

The industry best practice is to isolate verification code into a lightweight route, dedicated exclusively to confirming that the web server or process main loop is running. This route should not validate deep external dependencies unless the unavailability of that dependency strictly requires instance destruction. For scenarios where distributed systems must handle network bottlenecks or temporary slowdowns, it is worth integrating robust mitigation strategies, aligned with the concepts we discuss when analyzing how to optimize network and kernel performance in enterprise clusters.

Step-by-step guide to configuring resilient probes in production

Adjusting temporal parameters in the Kubernetes YAML manifest requires close attention to operational details and the actual behavior of your workload under stress. Fundamental attributes controlling this dynamic include the initial delay before the first check, the interval between attempts, and the acceptable consecutive failure threshold. To explore these architectural concepts further in production, see our related technical analysis on Unstable AI? How to use DSPy to structure prompts.

  1. Define an appropriate initial grace period (initialDelaySeconds) to allow heavy frameworks to load dependencies and open connections without rush.
  2. Establish consistent intervals (periodSeconds) that avoid saturating the container CPU with repetitive and unnecessary internal HTTP requests.
  3. Configure a consecutive failure threshold (failureThreshold) greater than one, allowing minor network hiccups or momentary memory spikes to pass without triggering the destruction trigger.
apiVersion: v1
kind: Pod
metadata:
  name: resilient-app
spec:
  containers:
  - name: web
    image: my-api:v2
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      initialDelaySeconds: 30
      periodSeconds: 10
      failureThreshold: 3
    readinessProbe:
      httpGet:
        path: /ready
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 5
      failureThreshold: 2

Final considerations on container stability

Maintaining a container orchestration architecture requires constant vigilance over how infrastructure components interact with application code. Intelligently configuring health probes protects the system against destructive restart cycles and ensures an uninterrupted user experience during traffic peaks. The secret lies in observing real software behavior in staging environments before applying restrictive policies in production.

By aligning expected response times with Kubernetes tolerance limits, your team gains operational predictability and eliminates false positives in on-call alerts. Spending time refining these minor details in the manifest file drastically reduces friction between code under development and the stability required in the real world.