首页 > 解决方案 > Liveness 和 Readiness 探针连接被拒绝

问题描述

当我尝试为我的 awx_web 容器设置 liveness & readiness prob 时,我不断收到此错误

Liveness probe failed: Get http://POD_IP:8052/: dial tcp POD_IP:8052: connect: connection refused

我的容器 awx_web 部署中的 Liveness & Readiness 部分

          ports:
          - name: http
            containerPort: 8052 # the port of the container awx_web
            protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: 8052
            initialDelaySeconds: 5
            periodSeconds: 5
          readinessProbe:
            httpGet:
              path: /
              port: 8052
            initialDelaySeconds: 5
            periodSeconds: 5

如果我测试端口 8052 是否从与包含容器 awx_web 的 pod 位于同一命名空间中的另一个 pod 中打开,或者如果我使用与容器 awx_web 部署在同一 pod 中的容器进行测试,我会得到这个(端口已打开)

/ # nc -vz POD_IP 8052
POD_IP  (POD_IP :8052) open

如果我从部署包含容器 awx_web 的 pod 的工作节点使用 netcat (nc),我会得到相同的结果(端口 8052 已打开)。

有关信息,我使用 NodePort 服务将流量重定向到该容器(awx_web)

type: NodePort
ports:
- name: http
  port: 80
  targetPort: 8052
  nodePort: 30100

标签: httpkubernetesansible-awxreadinessprobelivenesprobe

解决方案


我重新创建了您的问题,看起来您的问题是由initialDelaySecondsliveness probe 的值太小引起的。

awx 容器打开 8052 端口需要 5s 以上。您需要稍等片刻才能启动。我发现将其设置为 15 秒对我来说就足够了,但您可能需要进行一些调整。


推荐阅读