<p>My idea was to implement a liveness probe as a command, and use something like</p>

<pre><code>$ grep something ERROR
</code></pre>

<p>from inside a pod, so that if in the output of a pod, a line containing ERROR exists, the liveness probe fails.</p>

<p>Is this possible? If not, is it possible if I add another container in the same pod, to monitor the first container?</p>

<p>You could query the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#read-log" rel="noreferrer">Kubernetes API server</a>.</p>

<p>The request looks like this:</p>

<p><code>GET /api/v1/namespaces/{namespace}/pods/{name}/log</code></p>

<p>To use the token that's usually mounted in a Pod, you can call it like this:</p>

<pre class="lang-sh prettyprint-override"><code>curl https://kubernetes/api/v1/namespaces/default/pods/$HOSTNAME/log -k \
     -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"
</code></pre>
