<p>When watching a replication controller, it returns it’s most recent <code>replicas</code> count under <code>ReplicationControllerStatus</code>. I could not find anywhere in the documentation what the status of the pod needs to be, in order for it to be included there. Is it enough for the pod to be scheduled? I’ve noticed a replication controller reporting pods in it’s status even if the pods are still pending.</p>

<p>Very interesting question! For that to answer I believe we need to walk the Star Wars walk and <em>Use The Source</em>:</p>

<ul>
<li>The <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/replication/replication_controller.go#L62" rel="nofollow">ReplicationManager</a> has some hints concerning expectations</li>
<li>Then, there is <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/controller_utils.go" rel="nofollow">controller_utils.go</a> with some more indications </li>
<li>However, the core of the calculation seems to be in <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/replication/replication_controller_utils.go#L26" rel="nofollow">updateReplicaCount</a></li>
</ul>

<p><strong>UPDATE</strong>: My colleague Stefan Schimanski just pointed out to me that in fact the answer is a bit more complicated; key is <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/controller_utils.go#L394" rel="nofollow">FilterActivePods</a>:</p>

<pre><code>func FilterActivePods(pods []api.Pod) []*api.Pod {
var result []*api.Pod
for i := range pods {
    if api.PodSucceeded != pods[i].Status.Phase &amp;&amp;
        api.PodFailed != pods[i].Status.Phase &amp;&amp;
        pods[i].DeletionTimestamp == nil {
        result = append(result, &amp;pods[i])
    }
}
return result
}
</code></pre>

<p>This means the ultimate condition is: <strong>pods which have not terminated yet and are not in graceful termination</strong>.</p>

<p>Note that the definition of 'scheduled' in the context of Kubernetes is simply</p>

<pre><code>pod.spec.nodeName != ""
</code></pre>

<p>The Kubelet on a specific node watches the API Server for pods that have a matching <code>nodeName</code> and will then launch the pod on said node.</p>
