【问题标题】:OpenFaaS : Receiving Timeout errors during health check of function PodOpenFaaS:在功能 Pod 的健康检查期间接收超时错误
【发布时间】:2021-08-25 12:18:50
【问题描述】:

问题:

我们在函数中添加了健康检查配置。但是,由于活动性和就绪性检查中的超时错误,pod 变得不健康,因此会重新启动。 但是,如果我使用 CURL 或浏览器点击相同的健康检查 url,它会返回正确的响应。

健康检查configuration reference

我们正在使用 Kubernetes HPAv2 进行自动扩展 (Reference)。

test-function.yml

  test-function:
    lang: quarkus-java-with-fonts
    handler: ./test-function
    image: repo.azurecr.io/test-function:0.1
    labels:
      agentpool: openfaas
      com.openfaas.scale.min: "2"
      com.openfaas.scale.max: "10"
      com.openfaas.scale.factor: 0
    annotations:
     com.openfaas.health.http.path: "/health"
     com.openfaas.health.http.initialDelay: "30s"
    environment:
        secret_name: environment-variables
    secrets:
        - environment-variables 
    constraints:
        - agentpool=openfaas
    limits:
      cpu: 1500m
      memory: 1Gi
    requests:
      cpu: 500m
      memory: 500Mi

错误追踪:

Liveness probe failed: Get "http://XX.XXX.XX.XX:8080/health": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Readiness probe failed: Get "http://XX.XXX.XX.XX:8080/health": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

知道可能出了什么问题。

【问题讨论】:

  • Mikołaj Głodziak 已经提供了一个有效的答案。有用吗?如果是,请投票或接受答案,以提高社区成员的知名度。

标签: kubernetes kubernetes-health-check health-check openfaas


【解决方案1】:

这些错误:

Liveness probe failed: Get "http://XX.XXX.XX.XX:8080/health": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Readiness probe failed: Get "http://XX.XXX.XX.XX:8080/health": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

表示 HTTP 请求失败。为了使就绪和活跃度探测正常工作,这种类型的请求必须成功。

要找出问题所在,您需要获取 pod IP 地址。运行:

kubectl get pods -o wide

你应该会看到类似这样的输出:

NAME                        READY   STATUS    RESTARTS   AGE   IP          NODE                                       NOMINATED NODE   READINESS GATES
<my-pod-name>               1/1     Running   0          25d   10.92.3.4   <my-node-name>                             <none>           1/1

获取你的 IP 并运行:

kubectl exec -t <another_pod> -- curl -I <pod's cluster IP>

如果您收到 200 响应代码,则表示端点已正确创建和配置。任何其他答案都表明您的图像存在问题。

另见:

【讨论】:

  • 嗨 @Mikołaj Głodziak - 我使用 kubectl exec 收到了 200 个响应。我浏览了您提供的其他链接,建议使用 exec liveness probe 而不是 http liveness probe。然而 exec 探针也有其自身的缺点。我目前正在尝试执行探针。感谢您的帮助。
  • 嗨 Mikolaj,知道如何使用 OpenFaaS 启用 exec liveness probe。我尝试过浏览 OpenFaaS 文档,但找不到。
  • 收听this doc。您可以在 helm 图表中启用 httpProbe 并将 /_/health 实现为 HTTP 端点。
  • 它是否启用了 exec liveness 探测?我浏览了您提供的其他链接,建议使用 exec liveness probe 而不是 http liveness probe。
  • Exec 探针是默认的。 reference。如果你想从“exec” liveness and readiness probes 切换到 httpProbes 然后使用--set faasnetes.httpProbe=true,这只能与--set operator.create=false 一起使用。阅读更多here
猜你喜欢
  • 1970-01-01
  • 2022-01-18
  • 1970-01-01
  • 2020-01-18
  • 1970-01-01
  • 2020-06-25
  • 2021-06-15
  • 1970-01-01
  • 2018-12-25
相关资源
最近更新 更多