I have a container that has a ping endpoint (returns pong) and I want to probe the ping endpoint and see if I get a pong back. If it was just to check 200 , I could have added a liveliness check in my pod like this ->
livenessProbe:
initialDelaySeconds: 2
periodSeconds: 5
httpGet:
path: /ping
port: 9876 How do I modify this to check to see if I get a pong response back?
As the HTTP probe only checks the status code of the response, you need to use the exec probe to run a command on the container. Something like this, which requires curl being installed on the container:
livenessProbe:
initialDelaySeconds: 2
periodSeconds: 5
exec:
command:
- sh
- -c
- curl -s http://localhost:9876/ping | grep ponghttpGet livenessProbe and readinessProbe only care about http response code
Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure.
Better to change your pong message to set the appropriate http status code on the response.