就绪探测失败:获取 http://10.32.1.71:80/setting s:net/http:请求已取消(Client.Timeout 在等待 headers 时超出)
Readiness probe failed: Get http://10.32.1.71:80/setting s: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
我的配置是Jenkins on Kubernetes,项目写在PHP.
这里的问题是 pod 附加到入口(而不是在使用 GCE 的 loadBalancer 上)并且当 pod 不健康时它不会添加它。
我第一次从 0 加载项目,它在我更新它后工作,但由于它不健康而失败。
当我描述 pod 时,我收到以下警告:
Readiness probe failed: Get http://10.32.1.71:80/setting s: net/http:
request canceled (Client.Timeout exceeded while awaiting headers)
我的生产配置:
# Configuration for the SQL connection
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: wobbl-main-backend-production
spec:
replicas: 1
template:
metadata:
name: backend
labels:
app: wobbl-main
role: backend
env: production
spec:
containers:
- name: backend
image: gcr.io/cloud-solutions-images/wobbl-mobile-backend:1.0.0
resources:
limits:
memory: "500Mi"
cpu: "100m"
imagePullPolicy: Always
readinessProbe:
httpGet: # make an HTTP request
port: 80 # port to use
path: /settings # endpoint to hit
scheme: HTTP # or HTTPS
initialDelaySeconds: 3 # how long to wait before checking
periodSeconds: 5 # how long to wait between checks
successThreshold: 1 # how many successes to hit before accepting
failureThreshold: 2 # how many failures to accept before failing
timeoutSeconds: 10 # how long to wait for a response
ports:
- name: backend
containerPort: 80
有关如何解决此问题的任何提示。
错误消息表明您的 HTTP 请求不成功。就绪探测需要成功才能将 pod 添加为公开它的服务的端点。
1) kubectl get po -o wide
这样您就可以获得 pod 的集群 IP
2) kubectl exec -t [another_pod] -- curl -I [pod's cluster IP]
如果您收到 200 响应,则您知道路径配置正确并且就绪探测应该通过。如果您收到的不是 200 响应,这就是就绪探测失败的原因,您需要检查您的图像。
来自github.com/kubernetes/kubernetes/issues/89898
的解决方法
您可能希望将 httpGet
更改为 exec
/ command
/ curl
:
...
readinessProbe:
exec:
command:
- "curl"
- "--fail"
- "-o"
- "/dev/null"
- "http://localhost/settings"
initialDelaySeconds: 3
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
timeoutSeconds: 10
我的配置是Jenkins on Kubernetes,项目写在PHP.
这里的问题是 pod 附加到入口(而不是在使用 GCE 的 loadBalancer 上)并且当 pod 不健康时它不会添加它。
我第一次从 0 加载项目,它在我更新它后工作,但由于它不健康而失败。
当我描述 pod 时,我收到以下警告:
Readiness probe failed: Get http://10.32.1.71:80/setting s: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
我的生产配置:
# Configuration for the SQL connection
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: wobbl-main-backend-production
spec:
replicas: 1
template:
metadata:
name: backend
labels:
app: wobbl-main
role: backend
env: production
spec:
containers:
- name: backend
image: gcr.io/cloud-solutions-images/wobbl-mobile-backend:1.0.0
resources:
limits:
memory: "500Mi"
cpu: "100m"
imagePullPolicy: Always
readinessProbe:
httpGet: # make an HTTP request
port: 80 # port to use
path: /settings # endpoint to hit
scheme: HTTP # or HTTPS
initialDelaySeconds: 3 # how long to wait before checking
periodSeconds: 5 # how long to wait between checks
successThreshold: 1 # how many successes to hit before accepting
failureThreshold: 2 # how many failures to accept before failing
timeoutSeconds: 10 # how long to wait for a response
ports:
- name: backend
containerPort: 80
有关如何解决此问题的任何提示。
错误消息表明您的 HTTP 请求不成功。就绪探测需要成功才能将 pod 添加为公开它的服务的端点。
1) kubectl get po -o wide
这样您就可以获得 pod 的集群 IP
2) kubectl exec -t [another_pod] -- curl -I [pod's cluster IP]
如果您收到 200 响应,则您知道路径配置正确并且就绪探测应该通过。如果您收到的不是 200 响应,这就是就绪探测失败的原因,您需要检查您的图像。
来自github.com/kubernetes/kubernetes/issues/89898
的解决方法您可能希望将 httpGet
更改为 exec
/ command
/ curl
:
...
readinessProbe:
exec:
command:
- "curl"
- "--fail"
- "-o"
- "/dev/null"
- "http://localhost/settings"
initialDelaySeconds: 3
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
timeoutSeconds: 10