<p>I have a k8s cluster. Our service is queue based. Our pod subscribe to an event queue,fetch event and do tasks. So for this kind of service, how to define k8s liveness probe and readiness probe?</p>

Ruoxuan.Wang
<p>Assuming your problem is because is a processing worker consuming queue messages it doesn't expose any port to check.</p>
<p>In that case, you can define <code>livenessProbe</code> and <code>readinessProbe</code> custom command, next is an example from the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-command" rel="nofollow noreferrer">documnetation</a>:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-exec
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/busybox
    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
    readinessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5
</code></pre>
<p>Also, take in mind the time your process takes to be live and ready to adjust the <code>initialDelaySeconds</code> and <code>periodSeconds</code> to not kill the pod before it is fully loeaded.</p>
