0

I’m working with a Spring Boot application. And I have included the http liveness probe config using REST API endpoint. So, whenever the REST API is inaccessible, then Kubernetes will restart the pod.

The question is, I need identify if there is anyway to differentiate the pod restart activity was triggered by Liveness Probe against the manual restarts done by deployment team.

Is there any kind of log message included by Kubernetes in the Spring Boot log whenever it restarts the pod?

Tariv
  • 54
  • 7

1 Answers1

2

If you describe the pod you should see a message Liveness probe failed if there was a liveness probe failure.

kubectl describe pod liveness-exec

FirstSeen LastSeen    Count   From            SubobjectPath           Type        Reason      Message
--------- --------    -----   ----            -------------           --------    ------      -------
37s       37s     1   {default-scheduler }                    Normal      Scheduled   Successfully assigned liveness-exec to worker0
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Pulling     pulling image "k8s.gcr.io/busybox"
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Pulled      Successfully pulled image "k8s.gcr.io/busybox"
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Created     Created container with docker id 86849c15382e; Security:[seccomp=unconfined]
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Started     Started container with docker id 86849c15382e
2s        2s      1   {kubelet worker0}   spec.containers{liveness}   Warning     Unhealthy   Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory
Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107
  • How to include this message "Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory" into Spring Boot log, whenever pod restarts. – Tariv Feb 19 '21 at 09:32