Should i create a API for readinessprobe to work kubernetes

4/18/2019

I am trying to create a RollingUpdate and trying to use below code to see if pod came up or not. Should i create explicit API path like /healthz in my application so that kubernetes pings it and gets 200 status back or else its internal url for kubernetes?

specs:
   containers:
   - name: liveness
     readinessProbe:
    httpGet:
      path: /healthz
      port: 80
-- Hacker
kubernetes
readinessprobe

2 Answers

4/18/2019

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/

-- Suresh Vishnoi
Source: StackOverflow

4/18/2019

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)

-- Thomas
Source: StackOverflow