<p>I have a set of daemons I need to run, generally, they do not consume much memory or CPU and I have their <code>limits</code> to <code>cpu: 150m</code> and <code>memory: 150m</code>. </p>

<p>Occasionally they will spike to quite a bit higher than this and this seems to be causing evictions and unstable node.</p>

<p>It is critical that the daemons remain running 24/7, even if they are throttled by CPU and/or memory when they spike. Is it possible to prevent their eviction and to cap their resources?</p>

<p>As I understand the CPU usage is throttled but over memory use results in an OOM eviction, is there any way to prevent this eviction?</p>

AnyOne
<p>As of 1.11, you can set <a href="https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/" rel="nofollow noreferrer">pod priorities</a>. </p>

<ol>
<li>create priority class</li>
</ol>

<blockquote>
<pre><code>apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: high-priority
value: 1000000
globalDefault: false
description: "This priority class should be used for XYZ service pods only."
</code></pre>
</blockquote>

<ol start="2">
<li>set priority in pod</li>
</ol>

<blockquote>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  priorityClassName: high-priority
</code></pre>
</blockquote>
