Search code examples
kubernetesreadinessprobe

Should i create a API for readinessprobe to work kubernetes


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

Solution

  • 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/