How to set the frequency of a liveness/readiness probe in Kubernetes

8/8/2015

Is probe frequency customizable in liveness/readiness probe?

Also, how many times readiness probe fails before it removes the pod from service load-balancer? Is it customizable?

-- Sunil Kumar
google-cloud-platform
google-kubernetes-engine
kubernetes

3 Answers

2/1/2019

To customize the liveness/readiness probe frequency and other parameters we need to add liveness/readiness element inside the containers element of the yaml associated with that pod. A simple example of the yaml file is given below :

apiVersion: v1
kind: Pod
metadata:
  name: liveness-exec
spec:
  containers:
  - name: liveness-ex
    image: ubuntu
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy;sleep 600
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5

the initialDelaySeconds parameter ensure that liveness probe is checked after 5sec of container start and periodSeconds ensures that it is checked after every 5 sec. For more parameters you can go to link : https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/

-- Manya Tripathi
Source: StackOverflow

3/24/2017

You can easily customise the probes failure threshold and the frequency, all parameters are defined here. For example:

      livenessProbe:
        failureThreshold: 3
        httpGet:
          path: /health
          port: 9081
          scheme: HTTP
        initialDelaySeconds: 180
        timeoutSeconds: 10
        periodSeconds: 10
        successThreshold: 1

That probe will run the first time after 3 mins, it will run every 10 seconds and the pod will be restarted after 3 consecutives failures.

-- carlomas
Source: StackOverflow

8/9/2015

The probe frequency is controlled by the sync-frequency command line flag on the Kubelet, which defaults to syncing pod statuses once every 10 seconds.

I'm not aware of any way to customize the number of failed probes needed before a pod is considered not-ready to serve traffic.

If either of these features is important to you, feel free to open an issue explaining what your use case is or send us a PR! :)

-- Alex Robinson
Source: StackOverflow