kubectl get pods -o wide
The output looks similar to
some-pod-name-with-numbers-123 1/1 Running 0 6d4h 192.168.0.23 node-name-abcdeft-host.domain <none> <none> some-pod-name-with-numbers-1234 1/1 Running 0 4h38m 192.168.0.24 node-name-abcdeft-host.domain <none> <none> some-pod-name-with-numbers-1235 1/1 Running 0 2m38s 192.168.0.25 node-name-abcdeft-host.domain <none> <none>
I get time elapsed for the pods in a format like: 4d3h15m3s (it looks like the most is two consecutive units, days and hours, hours minutes, minutes and seconds, but I can't guarantee that.
I need to check to see if a pod has been around longer than some threshold X.
I tried to find some way of extracting this field as seconds via kubectl, no luck there. I searched the internet for a pre-canned solution, could not find one.
I'm thinking that I can use awk to convert the string into a numeric seconds so I can then compare if it is > $X, this value is configurable.
6d, for example, might include a DST transition and so you might have a day in there that's 23 or 25 instead of 24 hours. There's also leap seconds as less of an issue. Should DST transitions be ignored or, if not, how should they be handled? Or does
6din your file really mean 6 * 24 hour periods rather than 6 calendar days?