<p>I need to change the liveness probe we have for our Redis instances and make it fail in case it is not able to return keys (due to being overloaded). Currently, we are just checking if it accepts TCP connections.</p>
<pre><code>  livenessProbe:
    initialDelaySeconds: 20
    periodSeconds: 10
    tcpSocket:
      port: &quot;redis&quot;
</code></pre>
<p>One solution that I can think of is to set and fetch a key from the exec command. But I am not sure how to do that. The commands could be something like this:</p>
<pre><code>set test &quot;test&quot;
get &quot;test&quot;
</code></pre>
<p>If the set of commands fail or takes too much time, the liveness should fail.</p>
<p>What would be the best way to implement this?</p>

rishav
<p>You can make the liveness and readiness probes to execute a bash script:</p>
<pre><code>      livenessProbe:
        exec:
          command:
          - /bin/sh
          - /health.sh
        initialDelaySeconds: 60
        periodSeconds: 100
</code></pre>
<p>And add the part were you login to the Redis instance from inside with the redis cli and if fails exit code anything but 0</p>
