Readiness Probe

Readiness probe is used to specify the information which kubernetes can use to check if containers in pods are ready to serve or not.

For a http server, it can be an endpoint like /api/ready. For a tcp, a tcp socket with port can be provided. For a cli application, some command can be provided using exec.

    containers:
        - name: http-server
          image: http-server
          readinessProbe:
              httpGet:
                  path: '/api/ready'
                  port: 8080
        - name: database
          image: db
          readinessProbe:
              tcpSocket:
                  port: 3306
        - name: cli-app
          image: cli-app
          readinessProbe:
              exec:
                  command:
                    - cat
                    - /is_ready.txt
        

We can provide additional options to readiness probe.

readinessProbe:
    httpGet:
        path: /api/ready
        port: 8080
    initialDelaySeconds: 5
    periodSeconds: 2
    failureThreshold: 8

initialDelaySeconds specifies time to wait before sending check requests. periodSeconds specifies duration to wait between repeating attempts to check. failureThreshold specifies count over which the pod is decided failured.