My idea was to implement a liveness probe as a command, and use something like
$ grep something ERROR
from inside a pod, so that if in the output of a pod, a line containing ERROR exists, the liveness probe fails.
Is this possible? If not, is it possible if I add another container in the same pod, to monitor the first container?
You could query the Kubernetes API server.
The request looks like this:
GET /api/v1/namespaces/{namespace}/pods/{name}/log
To use the token that's usually mounted in a Pod, you can call it like this:
curl https://kubernetes/api/v1/namespaces/default/pods/$HOSTNAME/log -k \
-H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"