How do I know when a container in a kubernetes cluster is being restarted?

I have a kubernetes cluster in google container engine but container in a kubernetes cluster is being restarted.

Couple of times, hosted website went down.When I look at the container logs; I see that the normal startup sequence has recently completed, so I assume the container has died (or was it killed?) And restarted.

How I figure out how and why this is happening?

So I try to see, is there a way to get a warning or notification when the container starts / stops unexpectedly?

Here what I found a right solution –

To view the latest container restart logs, just type this command below.

kubectl logs podname -c container_name - previous

Or you can also try this, kubectl get pods will show the number of restarts,

kubectl describe under name
Avatar

About Shachindra Yadav

I, Shachindra Yadav, a Cloud Certified, DevOps and technology enthusiastic person, more passionate to learn and write blogs in my free time.

View all posts by Shachindra Yadav →