<p>I'm having trouble understanding what pod Eviction means mechanically in terms of K8s's actions -- what exactly does K8s do with the pod during eviction?</p>
<p>Specifically, my main question is this:
Under what conditions is an Evicted pod actually deleted from ETCD?
Under what conditions is an Evicted pod just killed without being deleted from the API server?</p>
<p>If I Evict a pod directly using the Eviction API, the pod object is actually deleted.
On the other hand, I've definitely seen pods hang in &quot;Evicted&quot; in the status column after I run &quot;kubectl get pod&quot;.</p>
<p>Edit:
Removed follow-up questions about Preemption and OOM-Killing to conform to the guideline of one question per post.
Might post a separate question about OOM management later.</p>

Dmitri Gekhtman
<p>I'm also confused by this lately. Here are some findings after a while of digging in the source code and the docs.</p>
<p>'Eviction' here actually means two slightly different concepts, which are both documented in the official docs: <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/node-pressure-eviction" rel="nofollow noreferrer">Node-Pressure Eviction</a> and <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/api-eviction" rel="nofollow noreferrer">API-Initiated Eviction</a>. They can really be mixed up when we just talk about 'Eviction' because they both do the same thing: evict pods from nodes.</p>
<p>Actually the doc of 'Node-Pressure Eviction' states:</p>
<blockquote>
<p>Node-pressure eviction is not the same as API-initiated eviction.</p>
</blockquote>
<p>The difference between these two is that 'API-Initiated Eviction' is, as the doc said:</p>
<blockquote>
<p>performing a policy-controlled DELETE operation on the Pod.</p>
</blockquote>
<p>So it will eventually delete the object stored in API server if the pod is evicted.</p>
<p>But 'Node-Pressure Eviction' is issued directly by the kubelet and what it does is set the PodPhase in pod's status to 'Failed' and the Reason to 'Evicted'</p>
<blockquote>
<p>During a node-pressure eviction, the kubelet sets the PodPhase for the selected pods to Failed. This terminates the pods.</p>
</blockquote>
<p>This will result in the <code>Evicted</code> pods shown when running <code>kubectl get pod</code>.</p>
<p>So the direct answer to your question is:
If the pod is evicted using the Eviction API, the pod object will be deleted.
If the pod is evicted by kubelet due to node pressure, the pod object will remain and will be in Failed status.</p>
