kubernetes - Command fails in probe but works in kubectl exec - Stack Overflow

admin2025-04-15  2

kubectl exec pod/my-pod -- wget -q -O- 127.0.0.1:3000

The above kubectl exec works.

But, when I run the same as a livenessProbe,

          livenessProbe:
            exec:
              command:
                - /usr/bin/wget
                - -q
                - -O-
                - 127.0.0.1:3000

it fails with wget: can't connect to remote host (127.0.0.1): Connection refused:

  Warning  Unhealthy  4s    kubelet            Liveness probe failed: wget: can't connect to remote host (127.0.0.1): Connection refused

I was expecting the same result from kubectl exec and the probe's exec:.

What differences in the execution environment are causing this?

转载请注明原文地址:http://www.anycun.com/QandA/1744722187a86714.html