I'm using the client-go API in Go to access the list of Pods under a given controller (Deployment). While querying the list of pods belonging to it using the selector labels, you get an array of PodConditions
- https://pkg.go.dev/k8s.io/api/core/v1?tab=doc#PodCondition.
This is well aligned with the official documentation of pod conditions - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions. But the documentation isn't clear how to access this array of entries. Is it sorted by most recent entry first? For e.g. if I want to access only the most recent status of the Pod, how should it be done? From one of the trials I did in my local cluster, I got updates (Pod Conditions array) for one of the controller's Pods as below
{Initialized True 0001-01-01 00:00:00 +0000 UTC 2020-07-29 08:01:15 +0000 UTC }
{Ready True 0001-01-01 00:00:00 +0000 UTC 2020-07-29 08:01:22 +0000 UTC }
{ContainersReady True 0001-01-01 00:00:00 +0000 UTC 2020-07-29 08:01:22 +0000 UTC }
{PodScheduled True 0001-01-01 00:00:00 +0000 UTC 2020-07-29 08:01:15 +0000 UTC }
As you can see that the given Pod has transitioned from ContainersReady
to Ready
just about at the same time 08:01:22 +0000 UTC
. But neither of them are in the first or last index.
So TLDR, the question is how to infer the latest Pod condition type and status, from this array of values?