【发布时间】:2019-12-05 02:27:21
【问题描述】:
这发生在我做了一个:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
在 apache 中,它实际上基于 HTTP 标头进行 301 重定向。
从这个 curl 开始:
curl -vk -H 'Host: example.com' 172.17.0.2/api/v1/ping
* Expire in 0 ms for 6 (transfer 0x1af6470)
* Trying 172.17.0.2...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x1af6470)
* Connected to 172.17.0.2 (172.17.0.2) port 80 (#0)
> GET /api/v1/ping HTTP/1.1
> Host: example.com
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Fri, 26 Jul 2019 18:14:09 GMT
< Server: Apache/2.4.38 (Debian)
< Location: https://example.com/api/v1/ping
< Content-Length: 239
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://example.com/api/v1/ping">here</a>.</p>
</body></html>
* Connection #0 to host 172.17.0.2 left intact
为什么这个 pod 会因为这个错误而失败?
Warning Unhealthy 99m (x7 over 100m) kubelet, minikube Readiness probe failed: Get https://172.17.0.9:80/api/v1/ping: http: server gave HTTP response to HTTPS client
【问题讨论】:
-
这将有助于查看探针的定义。特别是
scheme(默认为http)和httpHeaders(如果已配置)。否则,根据文档 (kubernetes.io/docs/tasks/configure-pod-container/…):“...任何大于或等于 200 且小于 400 的代码都表示成功。任何其他代码都表示失败”。顺便说一句,curl的测试没有在 URL 中指定方案,因此它默认为http。
标签: kubernetes kubernetes-health-check