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

这篇具有很好参考价值的文章主要介绍了解救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的集群。
你已经使用了所有可用资源,所以你可以扩展集群,增加一个第二个节点来分担负载。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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并重新平衡集群吗?
不幸的是,它不会这样做。但为什么呢?
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

3:部署Deployment

When you define a Deployment, you specify:

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

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

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

解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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 不会采取任何进一步的动作。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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)很可能会将其放置在一个利用率较低的节点上。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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
  • 亲和性或污点违规

解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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数量来重新平衡你的集群。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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将被删除。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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。
这对于确保更高的可用性非常有用,特别是当一个节点丢失时。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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)。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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)。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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)该污点,它们无法分配到相同的节点上。
因此,它们会在集群中的其他地方进行调度。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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移除。
解救Kubernetes混乱:Descheduler快速实现资源平衡,公众号#云原生百宝箱,1024程序员节,kubernetes,Descheduler,sheduler,调度器

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文章来源地址https://www.toymoban.com/news/detail-721246.html

到了这里,关于解救Kubernetes混乱:Descheduler快速实现资源平衡的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 平衡小车学习教程1——硬件资源及其小车底层硬件介绍篇

    大家在学会了Stm32后,可以做一个项目来进行来进行练手, 平衡小车 就 是一个很好的练手项目,可以检验自己的学习成果 ,也可以对学习到的知识进行一个复习。再一个就是 通过做项目来锻炼自己的工程能力。 好啦,废话不多说, 本套教程预计分为两部分 , 硬件底层介

    2024年02月11日
    浏览(28)
  • Kubernetes(K8s)从入门到精通系列之十三:软件负载平衡选项

    当设置具有多个控制平面的集群时,可以通过将 API Server 实例置于负载均衡器后面并在运行 kubeadm init 以便新集群使用它时使用 --control-plane-endpoint 选项来实现更高的可用性。 当然,负载均衡器本身也应该具有高可用性。这通常是通过向负载均衡器添加冗余来实现的。为此,

    2024年02月14日
    浏览(34)
  • 【阅读笔记】一种暗通道优先的快速自动白平衡算法

    自动白平衡算法中存在白色区域检测错误导致白平衡失效的问题,作者提出了一种基于暗通道优先的白平衡算法。 图像中白色区域或者高饱和度区域的光线透射率较低,根据以上特性利用暗通道法计算图像中白色区域。 作者使用何凯明提出的基于暗通道优先的方法来估计光

    2024年02月15日
    浏览(36)
  • 【kubernetes系列】kubernetes之计算资源管理

    在 Kubernetes 中,Node 提供资源,而 Pod 使用资源。其中资源分为计算(CPU、Memory、GPU)、存储(Disk、SSD)、网络(Network Bandwidth、IP、Ports)。这些资源提供了应用运行的基础,正确理解这些资源以及集群调度如何使用这些资源,对于大规模的 Kubernetes 集群来说至关重要,不仅

    2024年02月17日
    浏览(31)
  • 【kubernetes系列】Kubernetes之资源限制ResourceQuota

    当多个用户或团队共享具有固定节点数目的集群时,人们会担心有人使用超过其基于公平原则所分配到的资源量。我们可以通过ResourceQuota来解决这个问题,对每个namespace的资源消耗总量提供限制。它可以限制命名空间中某种类型的对象的总数目上限,也可以限制命名空间中的

    2024年02月16日
    浏览(32)
  • kubernetes核心资源内容

    参考连接: https://blog.csdn.net/weixin_46703850/article/details/122922090 1.命令行的方式创建命名命名空间 1.1 查看命名空间 1.2 查看所有名称空间的pods信息 1.3 查看指定命名空间的pod信息 1.4 删除命名空间,会连带空间下的资源一期删除 2. yaml方式创建命名空间 2.1 创建命名空间yaml文件

    2024年02月05日
    浏览(26)
  • 19、Kubernetes核心技术 - 资源限制

    目录 一、概述 二、Kubernetes 中的资源单位 2.1、CPU资源单位 2.2、内存资源单位 三、Pod资源限制 四、namespace资源限制 4.1、为命名空间配置内存和 CPU 配额 4.2、为命名空间配置默认的内存请求和限制 4.3、为命名空间配置默认的CPU请求和限制 五、超过容器限制的内存 当定义 Po

    2024年01月20日
    浏览(34)
  • Kubernetes — 核心资源对象 — Controller

    Kubernetes 提供了多种 Controllers 来对 Pods 进行管理,包括:Deployment、ReplicaSet、DaemonSet、StatefuleSet、Job 等,以满足不同的业务需求。这些控制器都运行在 Master 上。 在 Kuberentes 的 kubernetes/pkg/controller/ 目录中包含了官方提供的一些常见控制器,可以通过下面这个函数看到所有需要

    2024年02月11日
    浏览(26)
  • kubernetes pod 资源限制 探针

    当定义 Pod 时可以选择性地为每个容器设定所需要的资源数量。 最常见的可设定资源是 CPU 和内存大小,以及其他类型的资源。 当为 Pod 中的容器指定了 request 资源时,代表容器运行所需的最小资源量,调度器就使用该信息来决定将 Pod 调度到哪个节点上。当还为容器指定了

    2024年02月13日
    浏览(27)
  • kubernetes Ingress资源管理

    k8s 对外服务之 Ingress //Ingress 简介 service的作用体现在两个方面,对集群内部,它不断跟踪pod的变化,更新endpoint中对应pod的对象,提供了ip不断变化的pod的服务发现机制;对集群外部,他类似负载均衡器,可以在集群内外部对pod进行访问。 在Kubernetes中,Pod的IP地址和service的

    2024年02月16日
    浏览(54)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包