Should i create a API for readinessprobe to work kubernetes Should i create a API for readinessprobe to work kubernetes kubernetes kubernetes

Should i create a API for readinessprobe to work kubernetes


Kubernetes will make a request to the container on port 80 and path /healthz and expects a status code in the range of 2xx-3xx to be considered successful.If your application does not provide a mapping for the path and returns a 404, kubernetes assumes that the health check fails.Depending on your application you need to manually provide the API, if it is not done by your framework. (You can check using a curl or wget to the path from another pod and verify the result)


As@Thomas answered the Http probe, If application does not provide a endpoint to validate the success response. you can use TCP Probe

kubelet tries to establish a TCP connection on the container's port. If it can establish a connection, the container is considered healthy; if it can’t it is considered unhealthy

for example, in your case it would be like this

    ports:    - containerPort: 80    readinessProbe:      tcpSocket:        port: 80      initialDelaySeconds: 5      periodSeconds: 10    livenessProbe:      tcpSocket:        port: 80      initialDelaySeconds: 15      periodSeconds: 20

You can get further information over here configure-liveness-readiness-probes/