<p>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 <code>PodConditions</code> - <a href="https://pkg.go.dev/k8s.io/api/core/v1?tab=doc#PodCondition" rel="noreferrer">https://pkg.go.dev/k8s.io/api/core/v1?tab=doc#PodCondition</a>.</p>
<p>This is well aligned with the official documentation of pod conditions - <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions" rel="noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions</a>. 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</p>
<pre><code>{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  }
</code></pre>
<p>As you can see that the given Pod has transitioned from <code>ContainersReady</code> to <code>Ready</code> just about at the same time <code>08:01:22 +0000 UTC</code>. But neither of them are in the first or last index.</p>
<p>So TLDR, the question is how to infer the latest Pod condition type and status, from this array of values?</p>

Inian
<p>The Pod didn't transition from <code>ContainersReady</code> to <code>Ready</code>, the <code>ConditionStatus</code> of those <code>PodConditionTypes</code> change from <code>False</code> to <code>True</code>.<br />
The <code>PodCondition</code> array holds the details about each ConditionType, but they are not correlated, and you shouldn't rely on the order of the PodCondition updates.<br />
Instead, you can monitor the details of each PodCondition that interests you.</p>
<p>If you just want to know if the pod is running or not, take a look at <a href="https://pkg.go.dev/k8s.io/api/core/v1?tab=doc#PodPhase" rel="nofollow noreferrer"><code>PodPhase</code></a>. It's also part of the <code>PodStatus</code> struct.</p>
