<p>I'm trying to understand what happens when a container is configured with a CPU request and without a limit, and it tries to use more CPU than requested while the node is fully utilized, but there is another node with available resources.</p>
<p>Will k8s keep the container throttled in its current node or will it be moved to another node with available resources? do we know how/when k8s decides to move the container when its throttled in such a case?</p>
<p>I would appreciate any extra resources to read on this matter, as I couldn't find anything that go into details for this specific scenario.</p>

<p><strong>Q1) what happens when a container is configured with a CPU request and without a limit ?</strong></p>
<p><strong>ANS:</strong></p>
<p><strong>If you do not specify a CPU limit</strong></p>
<p>If you do not specify a CPU limit for a Container, then one of these situations applies:</p>
<p>The Container has no upper bound on the CPU resources it can use. The Container could use all of the CPU resources available on the Node where it is running.</p>
<p>The Container is running in a namespace that has a default CPU limit, and the Container is automatically assigned the default limit. Cluster administrators can use a LimitRange to specify a default value for the CPU limit.</p>
<p><strong>If you specify a CPU limit but do not specify a CPU request</strong></p>
<p>If you specify a CPU limit for a Container but do not specify a CPU request, Kubernetes automatically assigns a CPU request that matches the limit. Similarly, if a Container specifies its own memory limit, but does not specify a memory request, Kubernetes automatically assigns a memory request that matches the limit.</p>
<p><strong>Q2) it tries to use more CPU than requested while the node is fully utilized, but there is another node with available resources?</strong></p>
<p><strong>ANS:</strong></p>
<p>The <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-scheduler/#:%7E:text=kube%2Dscheduler-,kube%2Dscheduler,-Synopsis" rel="nofollow noreferrer">Kubernetes scheduler</a> is a control plane process which assigns Pods to Nodes. The scheduler determines which Nodes are valid placements for each Pod in the scheduling queue according to constraints and available resources. The scheduler then ranks each valid Node and binds the Pod to a suitable Node. Multiple different schedulers may be used within a cluster; kube-scheduler is the reference implementation. See scheduling for more information about scheduling and the kube-scheduler component.</p>
<p><strong>Scheduling, Preemption and Eviction</strong></p>
<p><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/#:%7E:text=Preemption%20and%20Eviction-,Scheduling%2C%20Preemption%20and%20Eviction,-In%20Kubernetes%2C%20scheduling" rel="nofollow noreferrer">In Kubernetes</a>, scheduling refers to making sure that Pods are matched to Nodes so that the kubelet can run them. Preemption is the process of terminating Pods with lower Priority so that Pods with higher Priority can schedule on Nodes. Eviction is the process of terminating one or more Pods on Nodes.</p>
<p><strong>Q3) Will k8s keep the container throttled in its current node or will it be moved to another node with available resources?</strong></p>
<p><strong>ANS:</strong></p>
<p><strong>Pod Disruption</strong></p>
<p>Pod disruption is the process by which Pods on Nodes are terminated either voluntarily or involuntarily.</p>
<p>Voluntary disruptions are started intentionally by application owners or cluster administrators. Involuntary disruptions are unintentional and can be triggered by unavoidable issues like Nodes running out of resources, or by accidental deletions.</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#voluntary-and-involuntary-disruptions" rel="nofollow noreferrer">Voluntary and involuntary disruptions</a>
Pods do not disappear until someone (a person or a controller) destroys them, or there is an unavoidable hardware or system software error.</p>
<p>We call these unavoidable cases involuntary disruptions to an application.</p>
<p><strong>Examples are:</strong></p>
<ul>
<li>a hardware failure of the physical machine backing the node</li>
<li>cluster administrator deletes VM (instance) by mistake</li>
<li>cloud provider or hypervisor failure makes VM disappear</li>
<li>a kernel panic</li>
<li>the node disappears from the cluster due to cluster network partition</li>
<li>eviction of a pod due to the node being <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/node-pressure-eviction/" rel="nofollow noreferrer">out-of-resources</a>.</li>
</ul>
<p><strong>Suggestion:</strong></p>
<p><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/" rel="nofollow noreferrer">Taints and tolerations</a> work together to ensure that pods are not scheduled onto inappropriate nodes. One or more taints are applied to a node; this marks that the node should not accept any pods that do not tolerate the taints.</p>
<p><strong>Command:</strong></p>
<pre><code>kubectl taint nodes node1 key1=value1:NoSchedule
</code></pre>
<p><strong><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/#taint-based-evictions" rel="nofollow noreferrer">Example</a>:</strong></p>
<pre><code>kubectl taint nodes node1 key1=node.kubernetes.io/disk-pressure:NoSchedule
</code></pre>
