Kube-probe HTTP probe failed with status code 302

The application is redirecting the probe request temporarily.

Understanding Kube-probe

Kube-probe is an essential component of Kubernetes, responsible for checking the health of containers running within a pod. It helps ensure that applications are running smoothly by performing periodic checks and taking corrective actions if necessary. Kube-probe supports three types of probes: HTTP, TCP, and command-based (exec) probes.

Identifying the Symptom

When using Kube-probe, you might encounter an error message stating: HTTP probe failed with status code 302. This indicates that the HTTP probe sent to the application received a 302 status code in response, which is a temporary redirect.

Exploring the Issue

The HTTP status code 302 is a common response indicating that the resource requested has been temporarily moved to a different URL. In the context of Kube-probe, this means that the probe request is being redirected, which is not handled by default. This can occur if the application is configured to redirect requests for authentication or other purposes.

Why Redirects Occur

Redirects can occur due to several reasons, such as:

  • Application-level redirects for load balancing or maintenance.
  • Security configurations requiring HTTPS, redirecting HTTP requests to HTTPS.
  • URL restructuring or changes in the application.

Steps to Resolve the Issue

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

Step 1: Verify the Application's Redirect Behavior

Check the application's configuration to understand why the redirect is occurring. You can use tools like curl to manually test the endpoint:

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

This command will show you the HTTP headers, including any Location headers indicating a redirect.

Step 2: Update the Probe Configuration

Modify the Kubernetes probe configuration to handle the redirect or point to the correct URL. If the redirect is intentional and necessary, consider updating the probe to follow redirects:

livenessProbe:
httpGet:
path: /new-path
port: 80
initialDelaySeconds: 3
periodSeconds: 3

Ensure the path is updated to the correct endpoint that does not redirect.

Step 3: Consider Using HTTPS

If the redirect is due to HTTP to HTTPS redirection, update the probe to use HTTPS:

livenessProbe:
httpGet:
scheme: HTTPS
path: /
port: 443
initialDelaySeconds: 3
periodSeconds: 3

Additional Resources

For more detailed information on configuring probes in Kubernetes, refer to the official Kubernetes documentation. Understanding how to configure and troubleshoot probes can significantly enhance the reliability 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