解救Kubernetes混乱:Descheduler快速实现资源平衡

By default, Kubernetes doesn’t recompute and rebalance workloads. You could have a cluster with fewer overutilized nodes and others with a handful of pods How can you fix this?
关注【云原生百宝箱】公众号,快速掌握云原生

默认情况下,Kubernetes不会重新计算和重新平衡工作负载。
你可能会遇到一些节点过度利用的集群,而其他节点只有少量的Pod。
你可以如何解决这个问题呢?

1:只有一个节点的集群

Let’s consider a cluster with a single node that can host 2 Pods You maxed out all available resources so you can scale the cluster to have a second node and spread the load

让我们考虑一个只有一个节点可以承载2个Pod的集群。
你已经使用了所有可用资源,所以你可以扩展集群,增加一个第二个节点来分担负载。

2:准备第二个节点

You provision a second node; what happens next? Does Kubernetes notice that there’s a space for your Pod? Does it move the second Pod and rebalance the cluster?
Unfortunately, it does not. But why?

你准备了第二个节点,接下来会发生什么?Kubernetes会注意到有一个Pod的空间吗?它会移动第二个Pod并重新平衡集群吗?
不幸的是,它不会这样做。但为什么呢?

3:部署Deployment

When you define a Deployment, you specify:

  • The template for the Pod
  • The number of copies (replicas)

当你定义一个部署(Deployment)时,你需要指定:

  • Pod的模板(template)
  • 副本数量(replicas)

4:Kubernetes不会自动重新平衡你的Pod

But nowhere in that file, you said you want one replica for each node! The ReplicaSet counts 2 Pods, and that matches the desired state Kubernetes won’t take any further action

但是在文件中你并没有指定每个节点一个副本!ReplicaSet 计数为2个Pod,这与期望的状态相匹配,Kubernetes 不会采取任何进一步的动作。

5:Descheduler定期扫描集群

In other words, Kubernetes does not rebalance your pods automatically But you can fix this with the descheduler The Descheduler scans your cluster at regular intervals, and if it finds a node that is more utilized than others, it deletes a pod in that node

换句话说,Kubernetes不会自动重新平衡你的Pod。但是你可以通过使用Descheduler来解决这个问题
Descheduler会定期扫描你的集群,如果发现某个节点的利用率高于其他节点,它会删除该节点上的一个Pod。

6:一个Pod被删除

What happens when a Pod is deleted? The ReplicaSet will create a new Pod, and the scheduler will likely place it in a less utilized node

当一个Pod被删除时会发生什么?
ReplicaSet会创建一个新的Pod,调度器(scheduler)很可能会将其放置在一个利用率较低的节点上。

7:Descheduler按策略驱逐

The Descheduler can evict pods based on policies such as:

  • Node utilization
  • Pod age
  • Failed pods
  • Duplicates
  • Affinity or taints violations

Descheduler可以根据以下策略驱逐Pod:

  • 节点利用率
  • Pod的年龄
  • 失败的Pod
  • 重复的Pod
  • 亲和性或污点违规

8:策略1:CPU、内存或Pod数量

If your cluster has been running long, the resource utilization is not very balanced The following two strategies can be used to rebalance your cluster based on CPU, memory or number of pods

如果你的集群已经运行了一段时间,资源利用可能不太平衡。
以下两种策略可以根据CPU、内存或Pod数量来重新平衡你的集群。

9:策略2:删除超过特定时间阈值的Pod

Another practical policy is deleting pods older than a certain threshold In this example, pods running for more than seven days are deleted

另一个实用的策略是删除超过特定时间阈值的Pod。在这个例子中,运行超过七天的Pod将被删除。

10:策略3:RemoveDuplicate插件

Or you can use the RemoveDuplicate plugin to remove similar Pods from running on the same node This is useful to ensure higher availability if a node is lost

或者你可以使用RemoveDuplicate插件来删除在同一个节点上运行的相似Pod。
这对于确保更高的可用性非常有用,特别是当一个节点丢失时。

11:集成Node Problem Detector

And lastly, you can combine the Descheduler with Node Problem Detector and Cluster Autoscaler to automatically remove Nodes with problems Let me explain with an example

最后,你可以将Descheduler与Node Problem Detector和Cluster Autoscaler结合使用,以自动删除出现问题的节点。
让我通过一个例子来解释。

Node Problem Detector can detect specific Node problems such as PIDPressure, MemoryPressure, etc. and report them to the API server The node controller can be configured to apply a taint to a node for a given state (TaintNodeByCondition)

Node Problem Detector可以检测特定的节点问题,例如PIDPressure、MemoryPressure等,并将它们报告给API服务器。
节点控制器可以配置为根据给定状态对节点施加污点(TaintNodeByCondition)。

12:使用RemovePodsViolatingNodeTaints策略

After the taint is assigned to the node, you can have the Descheduler evict workloads from that tainted node using the RemovePodsViolatingNodeTaints strategy

在节点被标记(taint)之后,你可以使用RemovePodsViolatingNodeTaints策略让Descheduler从被标记的节点上驱逐工作负载(workload)。

The pods can’t be allocated to the same node since they don’t tolerate the taint So, they are scheduled elsewhere in the cluster

由于Pods不容忍(tolerate)该污点,它们无法分配到相同的节点上。
因此,它们会在集群中的其他地方进行调度。

Finally, the node is likely to fall below the Cluster Autoscaler’s scale-down threshold and become a scale-down candidate and can be removed by Cluster Autoscaler

最后,该节点很可能会低于Cluster Autoscaler的缩容阈值,成为一个缩容候选节点,并可以被Cluster Autoscaler移除。

13:总结

The Descheduler is an excellent choice to keep your cluster efficiency in check, but it isn’t installed by default It can be deployed as a Job, CronJob or Deployment More info:

Descheduler是一个很好的选择,可以保持集群的效率,但它不是默认安装的。
它可以作为Job、CronJob或Deployment部署。
更多信息:https://github.com/kubernetes-sigs/descheduler

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/116294.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Pyside6 QFileDialog

Pyside6 QFileDialog Pyside6 QFileDialog常用函数getOpenFileNamegetOpenFileNamesgetExistingDirectorygetSaveFileName 程序界面程序主程序 Pyside6 QFileDialog提供了一个允许用户选择文件或目录的对话框。关于QFileDialog的使用可以参考下面的文档 https://doc.qt.io/qtfo…

设计模式-备忘录模式

备忘录模式是一种行为设计模式,它允许在不破坏封装的情况下捕获和恢复对象的内部状态。该模式通常用于需要保存和恢复对象状态的情况,例如撤销操作或错误恢复。 在Java中实现备忘录模式通常需要以下几个关键组件: 1. Origina…

[架构之路-242]:目标系统 - 纵向分层 - 应用程序的类型与演进过程(单机应用程序、网络应用程序、分布式应用程序、云端应用程序、云原生应用程序)

目录 一、什么是计算机应用程序 1.1 什么是应用程序 1.2 应用程序的分类 二、应用程序架构分类详解与演进阶段 三、应用程序架构(Application Architecture) 3.1 基本类型 3.2 云应用程序架构 一、什么是计算机应用程序 1.1 什么是应用程序 计算…

操作系统学习笔记7-IO管理

文章目录 1、IO管理学什么(学习逻辑图)2、IO管理硬件知识-IO设备的分类(硬件分类)3、IO管理硬件知识-IO控制方式的发展过程4、IO管理硬件知识-IO控制方式-程序直接控制方式5、IO管理硬件知识-IO控制方式-中断控制方式6、IO管理硬件知识-IO控制方式-DMA控制方式7、IO管理硬件知识…

CMake

文章目录 前言一、快速开始编译C/C代码1. 只有源码的项目2. 包含库的项目3. 编译成库给他人使用使用cmake的流程1. 生成构建系统2. 执行构建3. 执行测试4. 安装 && 打包 二、cmake 语法简介1 变量2 条件语句3 脚本命令**消息打印****if-else**:**list命令**&#xff1a…

从VTI7064与W25Qxx了解SPI通信协议

在学习过程中记录。 学习背景 最近在做的项目需要设计电路包含外扩FLASH(W25Q128)与SRAM(VTI7064),二者都用到了SPI通信协议,之前没学过,学习记录一下。 顺便说一下这次学习中发现的好用工具WPS AI。可以对文档进行…

【STM32】时钟设置函数(寄存器版)

一、STM32时钟设置函数移植 1.时钟模块回顾 一个疑问 前面代码并没有设置时钟为什么可以直接使用。 2.时钟树 3.时钟树分析 1.内部晶振(HSI) 内部晶振不稳定,当我们上电后,会自动产生振动,自动产生时钟,…

git常用的几条命令介绍

必须了解的命令整理 1,git init 初始化一个新的Git仓库。 这将在当前目录中创建一个名为".git"的子目录,Git会将所有仓库的元数据存储在其中。 2,git clone 克隆一个已存在的仓库。 这会创建一个本地仓库的副本,包…

【java爬虫】使用selenium获取某交易所公司半年报数据

引言 上市公司的财报数据一般都会进行公开,我们可以在某交易所的官方网站上查看这些数据,由于数据很多,如果只是手动收集的话可能会比较耗时耗力,我们可以采用爬虫的方法进行数据的获取。 本文就介绍采用selenium框架进行公司财…

2023年10月24日程序员节

这里写自定义目录标题 欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants 创建一个自定义列表如何创建一个…

SQL server中内连接和外连接的区别、表达(表的连接)

SQL server中内连接与外连接的区别、表达 区别表达内连接外连接 待续 首先,内连接和外连接都是对表的连接操作 区别 内连接:连接结果仅包含符合连接条件的行,其中至少一个属性是共同的;注意区分在嵌套查询时使用的any以及all的区…

基于Tucker分解的时序知识图谱补全10.23

基于Tucker分解的时序知识图谱补全 摘要引言相关工作静态知识图谱补全时序知识图谱补全 背景提出的模型学习时间复杂度和参数增长表达能力分析 实验 摘要 知识图谱已被证明是众多智能应用的有效工具。然而,大量有价值的知识仍然隐含在知识图谱中。为了丰富现有的知…

[python 刷题] 19 Remove Nth Node From End of List

[python 刷题] 19 Remove Nth Node From End of List 题目: Given the head of a linked list, remove the nth node from the end of the list and return its head. 题目说的是就是移除倒数第 n 个结点,如官方给的案例: 这里提供的 n 就是…

实时配送跟踪功能的实现:外卖跑腿小程序的技术挑战

在当今数字化时代,外卖和跑腿服务已经成为了生活中不可或缺的一部分。为了提供更好的用户体验,外卖跑腿小程序越来越注重实时配送跟踪功能的实现。这项技术挑战旨在确保顾客可以方便地跟踪他们的订单,以及配送员可以高效地完成送货任务。本文…

经典卷积神经网络 - VGG

使用块的网络 - VGG。 使用多个 3 3 3\times 3 33的要比使用少个 5 5 5\times 5 55的效果要好。 VGG全称是Visual Geometry Group,因为是由Oxford的Visual Geometry Group提出的。AlexNet问世之后,很多学者通过改进AlexNet的网络结构来提高自己的准确…

一年一度的1024程序员节

前言 1024 程序员节是中国程序员的节日,于每年的 10 月 24 日庆祝。这个节日旨在纪念和表彰程序员对科技和社会发展所做的贡献。 1024 程序员节最早由中国互联网公司 CSDN(中国软件开发者网)发起,自然而然地成为了中国程序员社区…

element-ui封装loading,便于在拦截请求或其他场景使用

loading.js import { Loading } from element-uilet loadingCount 0 let loadingconst startLoading () > {loading Loading.service({lock: true,text: 加载中,background: rgba(0, 0, 0, 0.7)}) }const endLoading () > {loading.close() }export const showLoadi…

TDengine小知识-数据文件命名规则

TDengine 时序数据库对数据文件有自己的命名规则,文件名中包含了vnodeID、时间范围、版本、文件类型等多种信息。了解数据文件命名规则,可以让运维工作更简单。 废话不多说,直接上图: v4:文件所属 Vgroup 组&#xf…

leetcode:2347. 最好的扑克手牌(python3解法)

难度:简单 给你一个整数数组 ranks 和一个字符数组 suit 。你有 5 张扑克牌,第 i 张牌大小为 ranks[i] ,花色为 suits[i] 。 下述是从好到坏你可能持有的 手牌类型 : "Flush":同花,五张相同花色的…

奶萨看到你那看到教大家

从前阿萨姆调换四大家各不卡速卡大家