<p>I have configured a liveness probe for my Redis instances that makes sure that the Redis is able to retrieve keys for it to be able to be called 'alive'.</p>
<pre><code>  livenessProbe:
    initialDelaySeconds: 20
    periodSeconds: 10
    exec:
      command:
        {{- include &quot;liveness_probe&quot; . | nindent 16 }}
</code></pre>
<p>_liveness.tpl</p>
<pre><code>{{/* Liveness probe script. */}}
{{- define &quot;liveness_probe&quot; -}}

- &quot;redis-cli&quot;
- &quot;set&quot;
- &quot;liveness_test_key&quot;
- &quot;\&quot;SUCCESS\&quot;&quot;
- &quot;&amp;&amp;&quot;
- &quot;redis-cli&quot;
- &quot;get&quot;
- &quot;liveness_test_key&quot;
- &quot;|&quot;
- &quot;awk&quot;
- &quot;'$1 != \&quot;SUCCESS\&quot; {exit 1}'&quot;
{{- end }}
</code></pre>
<p>The pod is able to start after doing the change. However, I would like to make sure that the probe is working as expected. For that I just added a delete command before the get command.</p>
<pre><code>{{/* Liveness probe script. */}}
{{- define &quot;liveness_probe&quot; -}}

- &quot;redis-cli&quot;
- &quot;set&quot;
- &quot;liveness_test_key&quot;
- &quot;\&quot;SUCCESS\&quot;&quot;
- &quot;&amp;&amp;&quot;
- &quot;redis-cli&quot;
- &quot;del&quot;
- &quot;liveness_test_key&quot;
- &quot;&amp;&amp;&quot;
- &quot;redis-cli&quot;
- &quot;get&quot;
- &quot;liveness_test_key&quot;
- &quot;|&quot;
- &quot;awk&quot;
- &quot;'$1 != \&quot;SUCCESS\&quot; {exit 1}'&quot;
{{- end }}
</code></pre>
<p>I get the expected exit codes when I execute this command directly in my command prompt.</p>
<p>But the thing is that my pod is still able to start.</p>
<p>Is the liveness probe command I am using okay? If so, how do I verify this?</p>

rishav
<p>Try this for your liveness probe it is working fine and you can try the same in readinessProbe:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: redis
  name: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: redis
    spec:
      containers:
      - image: redis
        name: redis
        livenessProbe:
          exec:
            command:
            - sh
            - -c
            - |            
                #!/usr/bin/env bash -e
                #export REDISCLI_AUTH=&quot;$REDIS_PASSWORD&quot;

                set_response=$(
                  redis-cli set liveness_test_key &quot;SUCCESS&quot;
                )

                del_response=$(
                    redis-cli del liveness_test_key
                )

                response=$(
                  redis-cli get liveness_test_key
                )

                if [ &quot;$response&quot; != &quot;SUCCESS&quot; ] ; then
                  echo &quot;Unable to get keys, something is wrong&quot;
                  exit 1
                fi               

          initialDelaySeconds: 5
          periodSeconds: 5
          
status: {}

</code></pre>
<p><strong>You will need to edit these values in your template</strong></p>
