How to monitor pod preemption event

629 Views Asked by At

I have a bunch of Rancher clusters I take care of and on some of them developers use PriorityClasses to ensure that some of the more important workloads get scheduled. The 3 PriorityClasses are in 3 digits range so they will not interfere with the default ones. However, at present none of the PriorityClasses is set as default and neither is the preemptionPolicy set so it defaults to PreemptLowerPriority.

None of the rancher, longhorn, prometheus, grafana, etc., workloads have priorityClassName set.

Long story short, I believe this causes havoc on the cluster when resources are in short supply.

Before I take my opinion to the developers I would like to collect some data to back up my story.

The question: How do I detect if the pod was Terminated due to Preemption?

I tried to google the subject but couldn't find anything. I was hoping kube state metrics would have something but I didn't find anything.

Any help would be greatly appreciated.

1

There are 1 best solutions below

3
On

You can try to look for convincing data like the pod termination reason with help of kubectl.

You can see the last restart logs of a container using the following command:

kubectl logs podname -c containername --previous

You can also use the following command to check the lifecycle events sent by the kubelet to the apiserver about the pod.

kubectl describe pod podname

Finally, You can also write a final message to /dev/termination-log, and this will show up as described in the docs.

To use kubectl commands with rancher kindly refer to this documentation page.