I am using the following command to gracefully delete any stale pods in Pending state:
kubectl get pod -n my-namespace | grep Pending | awk '{print $1}' | xargs kubectl delete pod -n my-namespace
However, I would like to add a condition that deletes only those pods who have been in pending state for more than N hours. There is the AGE column returned with get pods but its time unit varies and I am assuming there is a better way.
Also would appreciate if anyone can mention any best practices around this as I aim to run this command periodically to cleanup the pending Pods.