Kube-probe HTTP probe failed with status code 301

The application is redirecting the probe request to a different URL.

Understanding Kube-probe

Kube-probe is a critical component of Kubernetes, used to check the health and readiness of applications running within a cluster. It ensures that containers are functioning correctly and can handle requests. By using probes, Kubernetes can automatically restart containers that are not responding or are unhealthy, thereby maintaining the stability and reliability of applications.

Identifying the Symptom

One common issue encountered with Kube-probe is the error message: HTTP probe failed with status code 301. This indicates that the probe request was redirected to a different URL, which the probe does not follow by default. As a result, Kubernetes may incorrectly determine that the application is unhealthy.

Exploring the Issue

The HTTP status code 301 signifies a permanent redirect. When a Kube-probe receives this status code, it means that the application is instructing the probe to access a different URL. However, Kube-probe does not automatically follow redirects, leading to a failed health check.

Why Redirects Occur

Redirects can occur for various reasons, such as changes in the application’s URL structure or the use of HTTPS instead of HTTP. It's essential to ensure that the probe is configured to access the correct endpoint.

Steps to Fix the Issue

To resolve the issue of a failed HTTP probe due to a 301 status code, follow these steps:

1. Verify the Correct URL

Ensure that the probe is configured with the correct URL. Check the application’s documentation or configuration to determine the appropriate endpoint. If the application has moved to a new URL, update the probe configuration accordingly.

livenessProbe:
httpGet:
path: /new-path
port: 80

2. Use HTTPS if Required

If the application has switched to HTTPS, update the probe to use the httpsGet method instead of httpGet:

livenessProbe:
httpGet:
scheme: HTTPS
path: /
port: 443

3. Allow Redirects (if necessary)

In some cases, you may want to configure the probe to follow redirects. This can be done by adjusting the application or server settings to handle the probe’s requests appropriately. However, Kubernetes probes do not natively support following redirects, so this should be handled at the application level.

Additional Resources

For more information on configuring Kube-probes, refer to the official Kubernetes documentation on Liveness, Readiness and Startup Probes. Additionally, understanding HTTP status codes can be beneficial, and resources like MDN Web Docs on HTTP 301 provide valuable insights.

By following these steps, you can ensure that your Kube-probe is correctly configured to handle redirects and maintain the health of your applications.

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