k8s readiness probe - command with http get

11/26/2019

this question is about k8s readiness probe. I am trying to add the command in readiness probe curl to the new pod that is creating.

I mean that I want to check that the new pod that is created is ready to accept traffic, before the old one is terminated. I alrady have a command that is execute in the readines probe, so it is not possible for me to add an httpGet in this way:

readinessProbe:
  httpGet:
    path: /health

because I saw that there is an issue that it is not possible to add httpGet & command that will be execute.

Therefore, I must add this curl to the script that is running each time before new pod is created.

status=$( curl -s -o -k /dev/null -w %{http_code} /health); echo "statusCode: $status" if [ "$status" -ne "200" ]; exit 1 fi

My problem is that that it is not working, and using kubectl describe po XXXXX I see this output:

 Readiness probe failed: statusCode: 000000 if [ 000000 -ne 200 ]

So, I'm not sure how to make request to the new pod, because the only thing that I know about the new pod in this level is that it include an api named health.

am I making the request correct?

-- Sariel
kubernetes

1 Answer

11/26/2019

You are missing some colons and a then.

You have:

status=$( curl -s -o -k /dev/null -w %{http_code} /health); echo "statusCode: $status" if [ "$status" -ne "200" ]; exit 1 fi

instead of

status=$( curl -s -o -k /dev/null -w %{http_code} /health); echo "statusCode: $status"; if [ "$status" -ne "200" ]; then exit 1; fi
-- vladmihaisima
Source: StackOverflow