The following pod definition successfully executes a readinessProbe
, which makes a request to the service service-am-i-ready
that connects to pods on the same cluster.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: ready-if-service-ready
name: ready-if-service-ready
spec:
containers:
- image: nginx:1.16.1-alpine
name: ready-if-service-ready
resources: {}
livenessProbe:
exec:
command:
- 'true'
readinessProbe:
exec:
command:
- sh
- -c
- 'wget -T2 -O- http://service-am-i-ready:80'
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
However, if I change the readinessProbe.exec.command
to readinessProbe.httpGet
it doesn't work anymore:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: ready-if-service-ready
name: ready-if-service-ready
spec:
containers:
- image: nginx:1.16.1-alpine
name: ready-if-service-ready
resources: {}
livenessProbe:
exec:
command:
- 'true'
readinessProbe:
httpGet: # Only changed this method
host: service-am-i-ready
path: /
port: 80
scheme: HTTP
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
This is the error message I get running kubectl po describe ready-if-service-ready
:
Warning Unhealty 3m10s (x139 over 23m) kubelet Readiness probe failed: Get "http://service-am-i-ready:80/": dial tcp: lookup service-am-i-ready: no such host
Running kubectl get po ready-if-service-ready
gives:
NAME READY STATUS RESTARTS AGE
ready-if-service-ready 0/1 Running 0 27m
Why is the first readinessProbe working, but not the second one? It looks like the second readinessProbe makes a request to the same endpoint as the wget -T2 -O- http://service-am-i-ready:80
command.