【问题标题】:Container is not accessible via kubernetes readiness probe容器无法通过 kubernetes 就绪探针访问
【发布时间】:2018-01-30 12:02:22
【问题描述】:

我在kubectl describe podName 看到这个错误:

  9m        2s      118 kubelet, gke-wordpress-default-pool-2e82c1f4-0zpw   spec.containers{nginx}      Warning     Unhealthy       Readiness probe failed: Get http://10.24.0.27:80/: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

容器日志(nginx)如下:

10.24.1.1 - - [22/Aug/2017:11:09:51 +0000] "GET / HTTP/1.1" 499 0 "-" "Go-http-client/1.1"

但是,如果我通过 kubectl exec -it podName -c nginx sh 执行到容器中并执行 wget http://localhost,我能够成功获得 HTTP 200 响应。如果我通过 SSH 连接到主机(GCP 计算实例),我也能够成功获得 HTTP 200 响应。

我相信这个问题是在我用 NodePort 服务替换 LoadBalancer 服务后不久发生的。不知道是不是端口冲突?

有问题的服务: wordpress-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    app: wordpress
  name: wordpress
spec:
  type: NodePort
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  selector:
    app: wordpress

容器是一个 Nginx 容器,在端口 80 上提供内容。

准备就绪探测失败的原因可能是什么?


如果我在我的配置中删除就绪探测:

      readinessProbe:
        httpGet:
          path: /
          port: 80
        initialDelaySeconds: 5 
        periodSeconds: 5

一切正常,可以通过 LoadBalancer 服务访问 pod。

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    ARGHUGIHIRHHHHHH。

    我至少盯着这个错误看了一天,但由于某种原因我没有理解它。

    基本上错误net/http: request canceled (Client.Timeout exceeded while awaiting headers)意味着容器花费的时间比超时时间长(默认为1s)。

    【讨论】:

    • 所以探针的超时秒数是否需要增加...我也面临同样的问题..我的容器可以通过 ALB 从外部访问或直接从浏览器访问,但客户端的就绪探针总是失败.timeout 错误。
    • 非常感谢.. !
    猜你喜欢
    • 2019-07-22
    • 2021-05-24
    • 2021-12-03
    • 2019-03-28
    • 1970-01-01
    • 1970-01-01
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多