Kube-probe Probe failed: invalid response code

The application returned an unexpected HTTP status code.

Understanding Kube-Probe

Kube-probe is an essential component of Kubernetes, designed to monitor the health of applications running in a cluster. It helps ensure that applications are running smoothly by periodically checking their status and taking corrective actions if necessary. Kube-probe can perform liveness, readiness, and startup checks to determine the state of an application.

Identifying the Symptom

One common issue encountered with Kube-probe is the error message: Probe failed: invalid response code. This indicates that the probe received an HTTP status code that was not expected, which can lead to the application being marked as unhealthy.

Exploring the Issue

Unexpected HTTP Status Code

The error arises when the application returns an HTTP status code that does not match the expected code defined in the probe configuration. For example, if the probe expects a 200 OK response but receives a 404 Not Found, it will trigger this error.

Impact on Application

When a probe fails due to an invalid response code, Kubernetes may restart the pod or mark it as unready, depending on the type of probe. This can disrupt the application's availability and performance.

Steps to Fix the Issue

Verify Probe Configuration

First, check the probe configuration in your Kubernetes deployment YAML file. Ensure that the httpGet path and expected successThreshold are correctly set. For example:

livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
successThreshold: 1
failureThreshold: 3

Make sure the path and port match the application's health endpoint.

Check Application Logs

Inspect the application logs to identify any issues that might cause it to return an unexpected status code. Use the following command to view logs:

kubectl logs <pod-name>

Look for errors or warnings that might indicate why the application is not responding as expected.

Test the Endpoint Manually

Manually test the application's health endpoint using curl or a similar tool to ensure it returns the expected status code:

curl -I http://<service-ip>:8080/healthz

Verify that the response code matches the expected value.

Update Application Code

If the application is not returning the correct status code, update the application code to ensure it responds with the expected code under normal conditions. This might involve handling specific routes or error conditions more gracefully.

Conclusion

By following these steps, you can resolve the "Probe failed: invalid response code" issue in Kube-probe. Ensuring that your application returns the correct HTTP status codes is crucial for maintaining its health and availability within a Kubernetes cluster. For more information on configuring probes, refer to the Kubernetes documentation.

Master

Kube-probe

in Minutes — Grab the Ultimate Cheatsheet

(Perfect for DevOps & SREs)

Most-used commands
Real-world configs/examples
Handy troubleshooting shortcuts
Your email is safe with us. No spam, ever.

Thankyou for your submission

We have sent the whitepaper on your email!
Oops! Something went wrong while submitting the form.

Kube-probe

Cheatsheet

(Perfect for DevOps & SREs)

Most-used commands
Your email is safe with us. No spam, ever.

Thankyou for your submission

We have sent the whitepaper on your email!
Oops! Something went wrong while submitting the form.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid