在最近一次 K8s 环境的维护中,发现多个 Pod 使用相同镜像时,调度到固定节点的问题导致集群节点资源分配不均的情况。 启用调度器的打分日志后发现这一现象是由 ImageLocality 打分策略所引起的(所有的节点中,只有一个节点有运行该 pod 的镜像,所以这个节点调度器打分最高); 最终,通过禁用该插件成功解决调度不均匀的问题。在此,我想分享这一经验,希望能够对大家有所帮助!

1、自定义配置文件

# vi /etc/kubernetes/config.yaml
# 此处禁用 ImageLocality 打分插件(设置权重为 0)
...
apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
clientConnection:kubeconfig: /etc/kubernetes/scheduler.conf
profiles:- schedulerName: default-schedulerplugins:multiPoint:enabled:- name: ImageLocalityweight: 0
...

  • (可跳过)禁用打分插件的第二种方式,根据实际情况进行配置
# vi /etc/kubernetes/config.yaml 
apiVersion: kubescheduler.config.k8s.io/v1beta1
kind: KubeSchedulerConfiguration
clientConnection:kubeconfig: /etc/kubernetes/scheduler.conf
profiles:- schedulerName: default-schedulerplugins:score:disabled:- name: ImageLocality

2、配置 kube-scheduler

# 修改 kube-scheduler.yaml
# 在 spec.containers[0].command 添加参数;并挂载配置文件
vi /etc/kubernetes/manifests/kube-scheduler.yaml
...
- --config=/etc/kubernetes/config.yaml
...- mountPath: /etc/kubernetes/config.yaml      # 添加挂载name: configreadOnly: true
...- hostPath:path: /etc/kubernetes/config.yamltype: FileOrCreatename: config
...# 等待 kube-scheduler 自动重启
kubectl get pod -n kube-system# 完整 kube-scheduler.yaml 如下
apiVersion: v1
kind: Pod
metadata:creationTimestamp: nulllabels:component: kube-schedulertier: control-planename: kube-schedulernamespace: kube-system
spec:containers:- command:- kube-scheduler- --authentication-kubeconfig=/etc/kubernetes/scheduler.conf- --authorization-kubeconfig=/etc/kubernetes/scheduler.conf- --bind-address=127.0.0.1- --kubeconfig=/etc/kubernetes/scheduler.conf- --leader-elect=true- --config=/etc/kubernetes/config.yaml- --v=10image: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.31.0imagePullPolicy: IfNotPresentlivenessProbe:failureThreshold: 8httpGet:host: 127.0.0.1path: /healthzport: 10259scheme: HTTPSinitialDelaySeconds: 10periodSeconds: 10timeoutSeconds: 15name: kube-schedulerresources:requests:cpu: 100mstartupProbe:failureThreshold: 24httpGet:host: 127.0.0.1path: /healthzport: 10259scheme: HTTPSinitialDelaySeconds: 10periodSeconds: 10timeoutSeconds: 15volumeMounts:- mountPath: /etc/kubernetes/scheduler.confname: kubeconfigreadOnly: true- mountPath: /etc/kubernetes/config.yamlname: configreadOnly: truehostNetwork: truepriority: 2000001000priorityClassName: system-node-criticalsecurityContext:seccompProfile:type: RuntimeDefaultvolumes:- hostPath:path: /etc/kubernetes/scheduler.conftype: FileOrCreatename: kubeconfig- hostPath:path: /etc/kubernetes/config.yamltype: FileOrCreatename: config
status: {}

3、验证自定义配置生效

# kube-scheduler 日志如何开启可见博客
# https://blog.csdn.net/mm1234556/article/details/148686859# 通过日志查看配置文件
kubectl logs -n kube-system kube-scheduler-master |grep -A50 apiVersion:

# 手动创建一个 pod,查看 kube-scheduler 日志中调度的打分细节
kubectl logs kube-scheduler-master -n kube-system |grep -A10 score# 详细日志,最终调度到 node04 节点上
I0623 01:28:10.258309       1 resource_allocation.go:78] mysql-server-68468bcd96-j66bj -> node02: NodeResourcesBalancedAllocation, map of allocatable resources map[cpu:28000 memory:32772333568], map of requested resources map[cpu:3200 memory:5674337280] ,score 94,
I0623 01:28:10.258309       1 resource_allocation.go:78] mysql-server-68468bcd96-j66bj -> node01: NodeResourcesBalancedAllocation, map of allocatable resources map[cpu:28000 memory:32772333568], map of requested resources map[cpu:3820 memory:6427770880] ,score 94,
I0623 01:28:10.258312       1 resource_allocation.go:78] mysql-server-68468bcd96-j66bj -> node04: NodeResourcesBalancedAllocation, map of allocatable resources map[cpu:8000 memory:32122888192], map of requested resources map[cpu:1050 memory:1468006400] ,score 91,
I0623 01:28:10.258334       1 resource_allocation.go:78] mysql-server-68468bcd96-j66bj -> node02: NodeResourcesLeastAllocated, map of allocatable resources map[cpu:28000 memory:32772333568], map of requested resources map[cpu:3200 memory:5674337280] ,score 85,
I0623 01:28:10.258339       1 resource_allocation.go:78] mysql-server-68468bcd96-j66bj -> node04: NodeResourcesLeastAllocated, map of allocatable resources map[cpu:8000 memory:32122888192], map of requested resources map[cpu:1050 memory:1468006400] ,score 90,
I0623 01:28:10.258338       1 resource_allocation.go:78] mysql-server-68468bcd96-j66bj -> node01: NodeResourcesLeastAllocated, map of allocatable resources map[cpu:28000 memory:32772333568], map of requested resources map[cpu:3820 memory:6427770880] ,score 83,
I0623 01:28:10.258375       1 generic_scheduler.go:504] Plugin NodePreferAvoidPods scores on test-5/mysql-server-68468bcd96-j66bj => [{node01 1000000} {node04 1000000} {node02 1000000}]
I0623 01:28:10.258384       1 generic_scheduler.go:504] Plugin PodTopologySpread scores on test-5/mysql-server-68468bcd96-j66bj => [{node01 0} {node04 0} {node02 0}]
I0623 01:28:10.258389       1 generic_scheduler.go:504] Plugin TaintToleration scores on test-5/mysql-server-68468bcd96-j66bj => [{node01 100} {node04 100} {node02 100}]
I0623 01:28:10.258393       1 generic_scheduler.go:504] Plugin NodeResourcesBalancedAllocation scores on test-5/mysql-server-68468bcd96-j66bj => [{node01 94} {node04 91} {node02 94}]
I0623 01:28:10.258396       1 generic_scheduler.go:504] Plugin InterPodAffinity scores on test-5/mysql-server-68468bcd96-j66bj => [{node01 0} {node04 0} {node02 0}]
I0623 01:28:10.258400       1 generic_scheduler.go:504] Plugin NodeResourcesLeastAllocated scores on test-5/mysql-server-68468bcd96-j66bj => [{node01 83} {node04 90} {node02 85}]
I0623 01:28:10.258404       1 generic_scheduler.go:504] Plugin NodeAffinity scores on test-5/mysql-server-68468bcd96-j66bj => [{node01 0} {node04 0} {node02 0}]
I0623 01:28:10.258409       1 generic_scheduler.go:560] Host node01 => Score 1000277
I0623 01:28:10.258412       1 generic_scheduler.go:560] Host node04 => Score 1000281
I0623 01:28:10.258414       1 generic_scheduler.go:560] Host node02 => Score 1000279

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

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

相关文章

跟着AI学习C# Day21

📅 Day 21:动态类型与动态语言运行时(Dynamic Types & DLR) ✅ 学习目标: 理解什么是 dynamic 类型;掌握 dynamic 与 object 的区别;理解 DLR(Dynamic Language Runtime&#…

leetcode-3085.成为K字符串需要删除的最小字符串数

题目描述 解题思路 这题不难想到需要统计每个字母的出现频率,一共有26个字母,故cnt数组有26维。我们可以枚举其中一种作为「删除操作结束后出现频率最低的字符」,将其设置为 c,那么所有频率小于 c 的字符都会被删除,所…

Android 中 解析 XML 文件的几种方式

在 Android 开发中,解析 XML 文件有多种方式,每种方式都有其特点和适用场景。常见的 XML 解析方式有 DOM 解析、SAX 解析 和 XmlPullParser 解析。 一、xml 文件及数据类 1、xml 文件 将测试用 book.xml 文件放在项目的 app/src/main/assets 目录下,文件内容如下:<lib…

python里的abc库是什么东西

Python 中的 ABC&#xff1a;为什么你需要抽象基类&#xff1f;告别“假鸭子”&#xff0c;拥抱真抽象&#xff01; 你是不是经常在 Python 项目中感到困惑&#xff1a;我定义了一个类&#xff0c;希望它能被其他类继承并实现某些特定功能&#xff0c;但又不想它被直接实例化&…

设计模式精讲 Day 9:装饰器模式(Decorator Pattern)

【设计模式精讲 Day 9】装饰器模式&#xff08;Decorator Pattern&#xff09; 文章内容 在软件开发中&#xff0c;灵活扩展功能是提升系统可维护性和可复用性的关键。装饰器模式作为一种结构型设计模式&#xff0c;为对象动态地添加职责&#xff0c;而无需通过继承来实现。它…

浏览器无法访问:Nginx下的基于域名的虚拟主机

检查步骤如下&#xff1a; 1、nginx -t &#xff0c;检查配置文件是否有语法错误 [root89 ~]# nginx -t nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok nginx: configuration file /opt/nginx/conf/nginx.conf test is successful # 可以看到 配置…

【appium】6.appium遇到的问题

1.appium-python-client 修改版本1.5 为5.1.1,后执行python程序时&#xff0c;提示&#xff1a; raise TypeError( TypeError: missing 1 required keyword-only argument: options (instance of driver options.Options class) 你遇到的错误&#xff1a; TypeError: missing…

C++法则3:使用拷贝和交换的赋值运算符自动就是异常安全的,且能正确处理自赋值。

C法则3&#xff1a;使用拷贝和交换的赋值运算符自动就是异常安全的&#xff0c;且能正确处理自赋值。 这条法则强调了使用"拷贝和交换"(Copy-and-Swap)惯用法来实现赋值运算符()的优点&#xff1a; 关键点 异常安全&#xff1a;拷贝和交换方法天然提供了强异常安全…

纯血HarmonyOS5 打造小游戏实践:扫雷(附源文件)

鸿蒙扫雷游戏的核心架构设计 鸿蒙OS扫雷游戏采用了MVC&#xff08;模型-视图-控制器&#xff09;的架构思想&#xff0c;将游戏逻辑与UI展示分离&#xff0c;使得代码结构清晰且易于维护。整个游戏由以下几个核心部分构成&#xff1a; 数据模型设计 游戏的基础数据模型是Cel…

Linux C语言的opendir如何获取目录下的隐藏文件

在 Linux 文件系统中&#xff0c;所谓隐藏文件是文件名以 . 开头的文件&#xff08;例如 .bashrc、.git、.config 等&#xff09;。 在编程层面&#xff0c;opendir readdir 并不会自动排除隐藏文件。 只要你不在代码中手动过滤&#xff0c;readdir 会把目录下所有文件&#…

母线槽接头过热隐患难防?在线测温方案实时守护电力安全

近年来&#xff0c;由于各种设备对电力的大力需求&#xff0c;并有逐年增加的趋势&#xff0c;传统电路接线方式在施工时越来越力不从心。系统一旦定型&#xff0c;后续想要简化变更更是难上加难。母线槽方案因此兴起&#xff0c;凭借多点连接&#xff08;接头、插接头、插接箱…

Windows本地部署wordpress

一、下载wordpress 地址&#xff1a;Download – WordPress.org 下载后解压出来 二、下载小皮面板 地址&#xff1a;Windows版phpstudy下载 - 小皮面板(phpstudy) 下载后安装 三、打开小皮面板&#xff0c;安装对应内置应用 1、MySQL8&#xff08;注意要是8版本,卸载其他版本…

Android 性能优化

一、Android中检测性能工具 Profiler —— 使用Profiler的CPU分析功能。 Method Tracing ———— 通过该方法,我们可以记录应用运行过程中的方法调用情况,包括每个方法的执行时间、调用次数等。 Systrace 是Android平台提供的一款工具,用于记录短期内的设备活动。 Systra…

图片压缩工具 | Electron应用配合 commander 提供命令行调用功能

OPEN-IMAGE-TINY&#xff0c;一个基于 Electron VUE3 的图片压缩工具&#xff0c;项目开源地址&#xff1a;https://github.com/0604hx/open-image-tiny 功能描述 应用程序的命令行调用功能允许用户通过终端&#xff08;如Windows的CMD/PowerShell或Linux/macOS的Terminal&am…

Linux》》Shell脚本 基本语法

执行脚本的三种方式 查找变量的过程 变量引用的顺序》》先从当前进程查询变量&#xff0c;如果当前进程没有此变量&#xff0c;默认去父进程查找这个变量。如果查找到则返回&#xff0c;否则一直查找到 祖宗&#xff08;PID为1&#xff09;&#xff0c;还没有&#xff0c;则就…

C#.VB.NET多线程,多用户下独立锁和全局锁的区别

以下代码,每个客户端都分配了一个锁吗? 用户WebSocket信息类Public Class UserWebSocketInfoPublic Property SessionID As StringPublic Property WebSocket As WebSocketPublic Property LastResponseTime As DateTimePublic Property PendingHeartbeatCount As IntegerPubl…

无人机加速器模块技术解析

一、加速器模块的运行方式 1. 传感器数据采集与融合 加速度计核心作用&#xff1a;测量三维线性加速度&#xff08;X/Y/Z轴&#xff09;&#xff0c;结合陀螺仪&#xff08;角速度&#xff09;和磁力计&#xff08;方向&#xff09;构成九轴姿态传感器&#xff0c;实时输出…

用html实现数字生命

<!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>数学粒子动画</title><style>body {mar…

SQLite3 在嵌入式系统中的应用指南

SQLite3 在嵌入式系统中的应用指南 一、嵌入式系统中 SQLite3 的优势 SQLite3 是嵌入式系统的理想数据库解决方案&#xff0c;具有以下核心优势&#xff1a; 特性嵌入式系统价值典型指标轻量级适合资源受限环境库大小&#xff1a;500-700KB零配置无需数据库管理员开箱即用无…

通义大模型与现有企业系统集成实战《CRM案例分析与安全最佳实践》

1. 集成架构设计 &#xff08;1&#xff09;混合部署架构演进 #mermaid-svg-eW4YPoU2fdbnT4xp {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-eW4YPoU2fdbnT4xp .error-icon{fill:#552222;}#mermaid-svg-eW4YPoU2f…