Just because a container is running in Kubernetes does not mean the application inside it is healthy.

The process might still be active while the application inside the container is stuck, waiting for a dependency, responding slowly, or simply not ready to handle traffic.

That is where Kubernetes health checks come into play.

Kubernetes uses probes to check an application’s status and determine what to do. Depending on the situation, Kubernetes can restart a container, stop sending traffic to a Pod, or give the application time to finish starting.

In this article, we will cover the three probe types, how to set them up, and how to fix Kubernetes health checks when something isn’t working.

What are Kubernetes health checks?

Kubernetes health checks are tests the kubelet runs against a container. To determine whether a running container is healthy, Kubernetes checks the application at regular intervals. These checks help answer three questions:

  • Has the application finished starting?
  • Is it ready to receive traffic?
  • Is it still working properly?

Kubernetes uses three types of probes for this:

  • Liveness probe checks whether the application’s still alive.
  • Readiness probe checks whether the application can handle traffic.
  • Startup probe checks whether the application has finished starting.

The important thing to understand is that each probe has a purpose and Kubernetes reacts differently depending on which one fails.

Liveness probe

A liveness probe checks if the application is still working.

For example, an application process may still be running. It could be stuck in a deadlock. From the container’s point of view, nothing has crashed. The application is no longer useful.

A liveness probe helps Kubernetes notice that kind of problem.

livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 10
  periodSeconds: 10
  timeoutSeconds: 2
  failureThreshold: 3

In this example, Kubernetes checks /health every ten seconds.

If the probe fails three times in a row, Kubernetes marks the container as unhealthy and restarts it following the Pod’s restart policy.

One thing to be careful about is making liveness checks depend too much on external services.

For example, if your application is healthy but the database is temporarily unavailable, restarting the container may not solve the problem. It could even make the situation worse.

A liveness probe should usually focus on whether the application itself is stuck or broken.

Readiness probe

A readiness probe answers a different question: Can this Pod receive traffic right now?

An application may be running normally but temporarily unable to serve requests because a database, cache, or another required dependency is unavailable.

In such cases, you may not need to restart the application. Instead, Kubernetes can stop sending traffic to that Pod for a little while.

readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  periodSeconds: 5
  timeoutSeconds: 2
  failureThreshold: 3

Kubernetes marks the Pod as not ready when the readiness probe fails.

The container is still running, but Services stop routing normal traffic to the container. Kubernetes probes continuously, and when it succeeds again, the Pod is ready and gets traffic.

Readiness probes are useful for conditions such as:

  • Database connectivity problems
  • Cache initialization
  • Temporary dependency failures
  • Maintenance operations
  • Application warm-up

Startup probe

Some applications take longer than usual to launch.

Some Java application launches require initialization. Others may require loading configuration, rebuilding caches, or even completing other tasks during application startup.

Liveness probes tend to restart Kubernetes containers before an application is able to complete its launch.

All of this can be avoided by utilizing a startup probe.

startupProbe:
  httpGet:
    path: /health
    port: 8080
  periodSeconds: 5
  failureThreshold: 30

This shows that the startup probe gives the application about 150 seconds to launch.

When a startup probe is enabled, Kubernetes disables liveness and readiness probes. All of these probes will function as expected only after the startup probe has returned a successful launch.

This is generally better than setting an extremely large initialDelaySeconds on a liveness probe. Startup, readiness, and liveness probes have different purposes. Using the right probe for the right condition helps Kubernetes distinguish between an application that is still starting, one that should temporarily stop receiving traffic, and one that needs to be restarted.

How Kubernetes performs health checks

After you have picked the probe type, you must decide how Kubernetes will carry out the health checks.

HTTP probes

HTTP probes are often used for web apps and APIs.

httpGet:
  path: /health
  port: 8080

Kubernetes sends an HTTP GET request to the endpoint you set. HTTP status codes between 200 and 399 count as success. These health checks are easy to test and work well if the app already has a health endpoint.

TCP probes

A TCP probe checks if Kubernetes can open a connection to a port.

tcpSocket:
  port: 3306

This helps when the application does not give an HTTP endpoint.

A successful TCP connection only shows that something is listening on the port. The result does not prove that the application works correctly.

Exec probes

An exec probe runs a command inside the container.

exec:
  command:
    - sh
    - -c
    - test -f /tmp/healthy

The probe succeeds if the command returns exit code 0.

Any other exit code is considered a failure.

Exec probes are flexible. The command should stay lightweight because Kubernetes may run it frequently.

gRPC probes

Kubernetes also supports native gRPC health checks.

readinessProbe:
  grpc:
    port: 50051

This works for applications that implement the gRPC Health Checking Protocol.

Probe timing settings

Probe failures are often caused by timing rather than an actual application failure.

The main settings are:

  • initialDelaySeconds
    . Delay before the first probe runs.
  • periodSeconds
    . How often the probe runs.
  • timeoutSeconds
    . How long Kubernetes waits for a response.
  • failureThreshold
    . Failures allowed before Kubernetes takes action.
  • successThreshold
    . Successful checks required before the probe is considered healthy again.

These values should match the behavior of the application.

A small API that starts within a few seconds should not use the same settings as an application that requires a minute to initialize.

If a Pod keeps restarting or remains in Running without becoming ready, first check the status of the Pod.

kubectl get pods

Then inspect the Pod with the command:

kubectl describe pod <pod-name>

Check the Events section for messages such as:

  • Liveness probe failed
  • Readiness probe failed
  • Startup probe failed

These messages usually show whether the failure is caused by a timeout, connection refusal, incorrect HTTP response or another issue.

Next check the application logs with kubectl:

kubectl logs <pod-name>

If the container has restarted, check the instance with kubectl:

kubectl logs <pod-name> --previous

For an HTTP probe, test the endpoint directly from inside the container with kubectl:

kubectl exec -it <pod-name> -- curl -v http://localhost:8080/health

Verify the following with kubectl:

  • Correct URL path
  • Correct port
  • Correct HTTP or HTTPS scheme
  • Application listening on the expected interface
  • Endpoint response time
  • Probe timeout settings

Resource pressure can also affect probes. A health endpoint that normally responds quickly may start timing out when the Pod’s under high CPU or memory load.

Debugging failing health checks

If a Pod keeps restarting or remains in Running without becoming ready, first check the status of the Pod.

kubectl get pods

Then inspect the Pod with the command:

kubectl describe pod <pod-name>

Check the Events section for messages such as:

  • Liveness probe failed
  • Readiness probe failed
  • Startup probe failed

These messages usually show whether the failure is caused by a timeout, connection refusal, incorrect HTTP response or another issue.

Next check the application logs with kubectl:

kubectl logs <pod-name>

If the container has restarted, check the instance with kubectl:

kubectl logs <pod-name> --previous

For an HTTP probe, test the endpoint directly from inside the container with kubectl:

kubectl exec -it <pod-name> -- curl -v http://localhost:8080/health

Verify the following with kubectl:

  • Correct URL path
  • Correct port
  • Correct HTTP or HTTPS scheme
  • Application listening on the expected interface
  • Endpoint response time
  • Probe timeout settings

Resource pressure can also affect probes. A health endpoint that normally responds quickly may start timing out when the Pod’s under high CPU or memory load.

Common mistakes

One common mistake is using the same health check for both readiness and liveness.

The two probes have different jobs.

A readiness check may depend on services required to handle requests. A liveness check should mainly determine whether the application itself is stuck or unusable.

Another problem is setting probes too aggressively.

For example, a one-second timeout combined with frequent checks and a low failure threshold can turn a short performance issue into repeated container restarts.

Health endpoints should also remain simple. Inside them, do not perform expensive database queries or heavy application logic.

For applications that take a long time to initialize, use a startup probe rather than increasing liveness delays unnecessarily.

The easiest way to remember the three probes is:

Startup: Has the application started?

Readiness: Can it receive traffic?

Liveness: Is it still alive?

If a probe fails, start by running kubectl describe and looking at the events and logs. Then do a manual check of the health endpoint. Finally, check the probe configuration and timing.

Conclusion

Kubernetes health checks help ensure that applications are not only running but also ready to handle requests and recover when problems occur. Liveness, readiness, and startup probes each serve a different purpose, so choosing the right probe and configuring its timing carefully is important. When a health check fails, reviewing Pod events, application logs, resource usage, and probe settings can help identify the cause and restore normal application behavior.