kubernetes-pod驱逐机制
<h1><span style="font-family: 宋体">1.驱逐策略</span></h1><p><span style="font-family: 宋体"> kubelet持续监控主机的资源使用情况,并尽量防止计算资源被耗尽。一旦出现资源紧缺的迹象,kubelet就会主动终止部分pod的运行,以回收资源。</span></p>
<h1><span style="font-family: 宋体">2.驱逐信号</span></h1>
<p><span style="font-family: 宋体"> 以下是一些kubelet能用来做决策依据的信号,依据这些信号来做驱逐行为。</span></p>
<p> memory : 内存;</p>
<p> nodefs: 指node自身的存储,存储daemon的运行日志等,一般指root分区/;</p>
<p> imagefs: 指docker daemon用于存储image和容器可写层(writable layer)的磁盘;</p>
<p> </p>
<table style="-webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; border-spacing: 0; font-size: 16px; break-inside: avoid; margin-bottom: 0.85em; width: 1061px; overflow: auto; color: rgba(51, 51, 51, 1); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; letter-spacing: 0.2px; height: 255px">
<thead style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)"><th style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1); text-align: left"><span style="font-family: 宋体">Eviction Signal</span></th><th style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1); text-align: left"><span style="font-family: 宋体">Condition</span></th><th style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1); text-align: left"><span style="font-family: 宋体">Description</span></th></tr>
</thead>
<tbody style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">memory.available</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">MemoryPressue</span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">memory.available</code> := <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">node.status.capacity</code> - <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">node.stats.memory.workingSet</code> </span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; background-color: rgba(248, 248, 248, 1); border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">nodefs.available</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">DiskPressure</span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)">
<ul>
<li><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">nodefs.available</code> := <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">node.stats.fs.available</code>(Kubelet Volume以及日志等)</span></li>
</ul>
</td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">nodefs.inodesFree</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">DiskPressure</span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">nodefs.inodesFree</code> := <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">node.stats.fs.inodesFree</code></span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; background-color: rgba(248, 248, 248, 1); border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">imagefs.available</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">DiskPressure</span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">imagefs.available</code> := <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">node.stats.runtime.imagefs.available</code>(镜像以及容器可写层等)</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">imagefs.inodesFree</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">DiskPressure</span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">imagefs.inodesFree</code> := <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">node.stats.runtime.imagefs.inodesFree</code></span></td>
</tr>
</tbody>
</table>
<p><br> memory.available的值不是根据系统的free 收集,取值来自于cgroupfs,free -m命令不支持在容器中工作,</p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;"> cgroup.event_control #用于eventfd的接口
memory.usage_in_bytes #显示当前已用的内存
memory.limit_in_bytes #设置/显示当前限制的内存额度
memory.failcnt #显示内存使用量达到限制值的次数
memory.max_usage_in_bytes#历史内存最大使用量
memory.soft_limit_in_bytes #设置/显示当前限制的内存软额度
memory.stat #显示当前cgroup的内存使用情况
memory.use_hierarchy #设置/显示是否将子cgroup的内存使用情况统计到当前cgroup里面
memory.force_empty #触发系统立即尽可能的回收当前cgroup中可以回收的内存
memory.pressure_level #设置内存压力的通知事件,配合cgroup.event_control一起使用
memory.swappiness #设置和显示当前的swappiness
memory.move_charge_at_immigrate #设置当进程移动到其他cgroup中时,它所占用的内存是否也随着移动过去
memory.oom_control #设置/显示oom controls相关的配置
memory.numa_stat #显示numa相关的内存
</pre>
</div>
<p> 查看系统总memory:</p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">cat /proc/meminfo |grep MemTotal</pre>
</div>
<p> 查看当前已使用memory的方法:</p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">#cat /sys/fs/cgroup/memory/memory.usage_in_bytes
</pre>
</div>
<p> 查看当前cgroup使用memory情况:</p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">cat /sys/fs/cgroup/memory/memory.stat |grep total_inactive_file
</pre>
</div>
<p> </p>
<h1><span style="font-family: 宋体">3.软驱逐和硬驱逐</span></h1>
<p><span style="font-family: 宋体"> 如果一个节点有10Gi内存,我们希望在内存不足1Gi时候进行驱逐,可以用下面两种方式进行定位驱逐阈值:</span></p>
<p> </p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">memory.available<10%
memory.available<1Gi</pre>
</div>
<p> </p>
<p><span style="font-family: 宋体"> 1.</span><span style="font-family: 宋体">软驱逐(Soft Eviction):配合驱逐宽限期(eviction-soft-grace-period和eviction-max-pod-grace-period)一起使用。系统资源达到软驱逐阈值并在超过宽限期之后才会执行驱逐动作。</span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">--eviction-soft:描述驱逐阈值,例如:memory.available<1.5G
--eviction-soft-grace-period:驱逐宽限期,memory.available=1m30s
--eviction-max-pod-grace-period:终止pod最大宽限时间,单位s</pre>
</div>
<p> </p>
<p><span style="font-family: 宋体"> 2.</span><span style="font-family: 宋体">硬驱逐(Hard Eviction ):系统资源达到硬驱逐阈值时立即执行驱逐动作。</span></p>
<p> </p>
<p><code class="lang-sh"> 这些驱逐阈值可以使用百分比,也可以使用绝对值,如:</code></p>
<p> </p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">--eviction-hard=memory.available<500Mi,nodefs.available<1Gi,imagefs.available<100Gi
--eviction-minimum-reclaim="memory.available=0Mi,nodefs.available=500Mi,imagefs.available=2Gi"`
--system-reserved=memory=1.5Gi<br><br></pre>
</div>
<p><span style="font-family: 宋体"> </span></p>
<h1><span style="font-family: 宋体">4.回收Node级别资源</span></h1>
<ul>
<li><span style="font-family: 宋体">驱逐Node级别资源</span></li>
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">
<ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0 0 0 2em">
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">配置了 imagefs 阈值时
<ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0 0 0 2em">
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">达到 nodefs 阈值:删除已停止的 Pod</li>
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">达到 imagefs 阈值:删除未使用的镜像</li>
</ul>
</li>
</ul>
<ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0 0 0 2em">
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">未配置 imagefs 阈值时</li>
</ul>
<ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0 0 0 2em">
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit"></li>
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">达到 nodefs阈值时,按照删除已停止的 Pod 和删除未使用镜像的顺序清理资源</li>
</ul>
</li>
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit"><span style="font-family: 宋体">驱逐用户 Pod</span>
<ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0 0 0 2em">
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">驱逐顺序为:BestEffort、Burstable、Guaranteed</li>
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">配置了 imagefs 阈值时
<ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0 0 0 2em">
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">达到 nodefs 阈值,基于 nodefs 用量驱逐(local volume + logs)</li>
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">达到 imagefs 阈值,基于 imagefs 用量驱逐(容器可写层)</li>
</ul>
</li>
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">未配置 imagefs 阈值时
<ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; margin-top: 0; margin-right: 0; margin-bottom: 0; padding: 0 0 0 2em">
<li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">达到 nodefs阈值时,按照总磁盘使用驱逐(local volume + logs + 容器可写层)</li>
</ul>
</li>
</ul>
</li>
</ul>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit"> 除了驱逐之外,Kubelet 还支持一系列的容器和镜像垃圾回收选项,它们未来将会被驱逐替代:</p>
<table style="-webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; border-spacing: 0; font-size: 16px; break-inside: avoid; margin-bottom: 0.85em; width: 770px; overflow: auto; color: rgba(51, 51, 51, 1); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; letter-spacing: 0.2px">
<thead style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)"><th style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">垃圾回收参数</span></th><th style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">驱逐参数</span></th><th style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">解释</span></th></tr>
</thead>
<tbody style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit">
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--image-gc-high-threshold</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--eviction-hard</code> 或 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--eviction-soft</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">现存的驱逐回收信号可以触发镜像垃圾回收</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; background-color: rgba(248, 248, 248, 1); border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--image-gc-low-threshold</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--eviction-minimum-reclaim</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">驱逐回收实现相同行为</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--minimum-image-ttl-duration</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"> </span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">由于驱逐不包括TTL配置,所以它还会继续支持</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; background-color: rgba(248, 248, 248, 1); border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--maximum-dead-containers</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"> </span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">一旦旧日志存储在容器上下文之外,就会被弃用</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--maximum-dead-containers-per-container</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"> </span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">一旦旧日志存储在容器上下文之外,就会被弃用</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; background-color: rgba(248, 248, 248, 1); border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--minimum-container-ttl-duration</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"> </span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">一旦旧日志存储在容器上下文之外,就会被弃用</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--low-diskspace-threshold-mb</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--eviction-hard</code> or <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">eviction-soft</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">驱逐回收将磁盘阈值泛化到其他资源</span></td>
</tr>
<tr style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; break-inside: avoid; background-color: rgba(248, 248, 248, 1); border-top: 1px solid rgba(204, 204, 204, 1)">
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--outofdisk-transition-frequency</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体"><code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em; break-inside: avoid; direction: ltr; margin: 0; padding: 0.2em; border: none; color: inherit; background-color: rgba(247, 247, 247, 1)">--eviction-pressure-transition-period</code></span></td>
<td style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-size: inherit; padding: 6px 13px; border-color: rgba(221, 221, 221, 1)"><span style="font-family: 宋体">驱逐回收将磁盘压力转换到其他资源</span></td>
</tr>
</tbody>
</table>
<h1> 5.节点资源紧缺情况下系统行为</h1>
<p> 1.Scheduler行为</p>
<p> Master上的scheduler不再向该节点调度pod,节点状况与调度行为的对应关系如下:</p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">MemoryPressure:不再调度新的BestEffort pod到这个节点
DiskPressure:不再向这一节点调度pod
</pre>
</div>
<p> 2.Node的OOM行为</p>
<p> kubelet根据pod的Qos为每个容器设置一个oom_score_adj,如果kubelet无法在系统OOM之前回收足够的内存。则oom_killer会根据内存使用比例来计算oom_score,最后结果和oom_score_adj相加,得分最高的pod将会首先被驱逐。</p>
<div class="hljs-ln-code" style="box-sizing: border-box; outline: 0; margin: 0 0 0 8px; padding: 0; overflow-wrap: break-word; font-family: "Source Code Pro", "DejaVu Sans Mono", "Ubuntu Mono", "Anonymous Pro", "Droid Sans Mono", Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; float: left; height: 22px">
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
<div class="hljs-ln-line" style="box-sizing: border-box; outline: 0; margin: 0; padding: 0; overflow-wrap: break-word"> </div>
</div><br><br>
来源:https://www.cnblogs.com/yaohong/p/13245723.html
頁:
[1]