Kube-probe Probe failed: invalid content type

The application returned a response with an unexpected content type.

Understanding Kube-probe

Kube-probe is a diagnostic tool used within Kubernetes to monitor the health and readiness of applications running in a cluster. It helps ensure that applications are functioning correctly and can handle requests. Kube-probe can be configured to perform liveness, readiness, and startup checks on containers, which are crucial for maintaining the stability and reliability of applications.

Identifying the Symptom

When using Kube-probe, you might encounter an error message stating: Probe failed: invalid content type. This error indicates that the probe received a response from the application with a content type that does not match the expected format. This can lead to the probe failing to verify the application's health or readiness.

Exploring the Issue

The error invalid content type typically occurs when the application returns a response with a content type that the probe is not configured to handle. For instance, if the probe expects a JSON response but receives plain text or HTML, it will trigger this error. This mismatch can prevent the probe from parsing the response correctly, leading to a failure in the health check.

Common Causes

  • Misconfigured application response headers.
  • Incorrect probe configuration expecting a different content type.
  • Application logic errors leading to unexpected response formats.

Steps to Fix the Issue

To resolve the invalid content type error, follow these steps:

1. Verify Application Response

Check the application's response headers to ensure they include the correct content type. You can use tools like cURL to inspect the headers:

curl -I http://your-application-url

Look for the Content-Type header and ensure it matches the expected type (e.g., application/json).

2. Update Probe Configuration

Ensure that the probe configuration in your Kubernetes manifest matches the expected content type. For example, if the application returns JSON, your probe might look like this:

livenessProbe:
httpGet:
path: /health
port: 8080
httpHeaders:
- name: Accept
value: application/json

3. Modify Application Logic

If the application is returning an incorrect content type due to logic errors, update the application code to ensure the correct content type is set in the response headers. For example, in a Node.js application, you can set the content type using:

res.setHeader('Content-Type', 'application/json');

Additional Resources

For more information on configuring probes in Kubernetes, refer to the official Kubernetes documentation. Additionally, consider exploring container probes for a deeper understanding of how probes work.

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