skip to Main Content

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


  1. Chosen as BEST ANSWER

    I was able to figure out the correct syntax to ping a Node port service as part of readiness probe.

    apiVersion: v1
    kind: Pod
    metadata:
      name: my-pod
    spec:
      containers:
      - name: my-app
        image: nginx:1.16.1-alpine
        readinessProbe:
          httpGet:
            path: /
            port: 32044
            host: "localhost"
          initialDelaySeconds: 5
          periodSeconds: 10
          timeoutSeconds: 1
          successThreshold: 1
          failureThreshold: 3
    

  2. 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:

    To perform a probe, the kubelet executes the command … in the target container.

    Login or Signup to reply.
  3. 8080 is the pod port

    With readiness I am trying to check if a pod running on a 8080 port is accessible.

    With this info, you can configure a ReadinessProbe like e.g.:

    readinessProbe:
      httpGet:
        path: /my-path
        port: 8080
    

    Since pod is exposed via service I am trying to wget service

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search