I have a simple pod and has readiness probe configured. All it is doing is checking for the service running at a NodePort 30080. When I run the pod it fails due to readiness check:-
Readiness probe failed: Connecting to localhost:30080 (127.0.0.1:30080)
wget: can't connect to remote host (127.0.0.1): Connection refused
I can curl the pod and get the response back.
curl http://localhost:30080
If I use the same command in the readiness probe I get the error. Following is the deployment descriptor. Any assistance would be of great help.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-app
image: nginx:1.16.1-alpine
readinessProbe:
exec:
command: ["wget", "-T2", "-O-", "http://localhost:30080"]
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
3
Answers
I was able to figure out the correct syntax to ping a Node port service as part of readiness probe.
The command of the
readinessProbe
is executed inside of the container, so you need to specify the port that your nginx is running on. It is the same as the target port of your Service. Here is the documentation:With this info, you can configure a ReadinessProbe like e.g.:
Your ReadinessProbe should be for the Pod, not the Service. Multiple pods will be behind a Service, e.g. during a new deployment. It is important that the ReadinessProbe only checks a single replica – not all behind a Service.