Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes (K8s) - Can you check what time a pod restarts at?

I am trying to create a system health check. I would like to be able to determine how often the pods are restarting. Since the pods have liveness probes, they may continuously restart if something is wrong. Is there anyway to check the time a pod restarted at instead of just the number of restarts and the total time the pod has been alive?

like image 207
beanwa Avatar asked Aug 20 '18 20:08

beanwa


People also ask

How do I check the pod reset time in Kubernetes?

You can use kubectl get pod -o yaml to view your POD resource in the YAML format (or -o json if you prefer). You can also use kubectl explain pod to list and describe all possible fields associated with the pod API resource.

How do I check reboot history on pod?

To see what happened on the pod before it restarted, use kubectl logs your-pod-name --previous . You can pipe this to a file for inspection e.g.

Does Kubernetes restart pods?

Kubernetes Pods should usually run until they're replaced by a new deployment. As a result, there's no direct way to “restart” a single Pod. If one of your containers experiences an issue, aim to replace it instead of restarting.

How do I check my Kubernetes pod events?

To collect or watch the events, you can run kubectl get events --watch in deployment and collect the output with a third-party logging tool. To watch Kubernetes events, many free and paid third-party tools help provide visibility and reporting of events in a Kubernetes cluster resource.


1 Answers

You may want to use a monitoring tool, like cAdvisor/Heapster/Grafana/Prometheus.

Another option you have is to deploy the kube-state-metrics container.

Good articles to read: Monitoring Kubernetes and Get Kubernetes Cluster Metrics with Prometheus. Also, read a similar question on stackoverflow.

like image 83
Vit Avatar answered Oct 17 '22 04:10

Vit