当前位置: 首页 > news >正文

79. 如何在 RKE2 或 K3s 集群中配置 CPU-manager-policy

Environment 环境
  • A Rancher-provisioned or standalone RKE2 or K3s cluster
    Rancher 配置或独立的 RKE2 或 K3s 集群
Procedure 程序

This article details how to configure Kubernetes CPU Manager Policy in an RKE2 or K3s cluster. The policy is configured via the kubelet--cpu-manager-policyflag, alongside the related --kube-reserved, --system-reserved, --reserved-cpus and --cpu-manager-policy-options flags.
本文详细介绍了如何在 RKE2 或 K3s 集群中配置 Kubernetes CPU Manager Policy。该策略通过 kubelet--cpu-manager-policy标志进行配置,同时还包括相关的 --kube-reserved、--system-reserved、--reserved-cpus 和 --cpu-manager-policy-options 标志。

Rancher-provisioned RKE2 or K3s clusters
牧场配置 RKE2 或 K3s 集群

Configuration at cluster creation time
集群创建时的配置

  1. After filling in all desired configuration via theCluster Configurationform, clickEdit as YAMLon the bottom section of the page.
    在通过集群配置表单填写所有所需配置后,点击页面底部的“编辑为 YAML”。
  2. Add the required kubelet-arg flags into the machineGlobalConfig block under rkeConfig, per the following example:
    按照以下示例,在 rkeConfig 下的 machineGlobalConfig 块中添加所需的 kubelet-arg 标志:
    <span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>[...] spec: [...] rkeConfig: [...] machineGlobalConfig: kubelet-arg: - cpu-manager-policy=static - system-reserved=cpu=1,memory=1548Mi,ephemeral-storage=30Gi [...]</code></span></span></span>
  3. Then clickCreateto create the cluster.
    然后点击创建集群。

Configuration after initial cluster creation
初始集群创建后的配置

  1. Navigate toClusterManagement
    导航至集群管理
  2. ClickEdit Configfor the desired downstream cluster
    点击编辑配置以查看所需的下游集群
  3. ClickEdit as YAML
    点击编辑为 YAML 代码
  4. Add the required kubelet-arg flags into the machineGlobalConfig block under rkeConfig, per the following example:
    按照以下示例,在 rkeConfig 下的 machineGlobalConfig 块中添加所需的 kubelet-arg 标志:
    <span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>[...] spec: [...] rkeConfig: [...] machineGlobalConfig: kubelet-arg: - cpu-manager-policy=static - system-reserved=cpu=1,memory=1548Mi,ephemeral-storage=30Gi [...]</code></span></span></span>
  5. ClickSaveto update the cluster with the new CPU Manager Policy.
    点击保存以更新集群,使用新的 CPU 管理器策略。
  6. The cluster will transition to an Updating status, and the cluster's nodes will get stuck in a Reconciling state with the message "Waiting for probes: kubelet"
    集群将切换为更新状态,节点会卡在“Reconciling”状态,提示“等待探针:kubelet”
  7. When a node enters this state, open an SSH session to it, and remove the old CPU Manager state file:
    当节点进入该状态时,打开一个 SSH 会话,并删除旧的 CPU 管理器状态文件:
    <span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code># rm -rf /var/lib/kubelet/cpu_manager_state</code></span></span></span>
  8. The node will then complete reconciling successfully.
    节点随后会成功完成对账。
  9. Repeat step 6 until all the nodes are successfully reconciled and the cluster returns to an Active state.
    重复步骤6,直到所有节点成功对账,集群恢复为活跃状态。

Standalone RKE2 or K3s clusters
独立的 RKE2 或 K3s 集群

Configuration at cluster creation time
集群创建时的配置

The required kubelet flags should be defined in the RKE2 or K3s configuration file on each node, before starting the rke2-server, rke2-agent or k3s service for the first time, e.g.:
在首次启动 rke2 服务器、rke2 代理或 k3s 服务之前,应在每个节点的 RKE2 或 K3s 配置文件中定义所需的 kubelet 标志,例如:

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>kubelet-arg: - cpu-manager-policy=static - system-reserved=cpu=1,memory=1548Mi,ephemeral-storage=30Gi </code></span></span></span>

Configuration after initial cluster creation
初始集群创建后的配置

You can perform the configuration update on each node in the cluster, following the process outlined in the Kubernetes CPU Manager Policy documentation:
你可以按照 Kubernetes CPU Manager 策略文档中描述的流程 ,对集群中的每个节点进行配置更新:

  1. Drain the node 排空节点
  2. Stop the RKE2 or K3s processes:
    停止 RKE2 或 K3s 进程:
    1. On RKE2 server nodes runsystemctl stop rke2-serverandrke2-killall.sh
      在 RKE2 服务器节点上运行systemctl,stop rke2-serverrke2-killall.sh
    2. On RKE2 worker nodes runsystemctl stop rke2-agentandrke2-killall.sh
      在 RKE2 上,工作节点运行systemctl、stop rke2-agentrke2-killall.sh
    3. On K3s server nodes runsystemctl stop k3sandk3s-killall.sh
      在 K3s 服务器节点上运行systemctl,停止 k3sk3s k3s-killall.sh
    4. On K3s agent nodes runsystemctl stop k3s-agentandk3s-killall.sh
      在 K3s 上,代理节点运行systemctl、stop k3s-agentk3s-killall.sh
  3. Remove the CPU Manager state file:rm -rf /var/lib/kubelet/cpu_manager_state
    移除 CPU 管理器状态文件:rm -rf /var/lib/kubelet/cpu_manager_state
  4. Define the required kubelet flags in the RKE2 or K3s configuration file on the node, e.g.:
    在节点上的 RKE2 或 K3s 配置文件中定义所需的 kubelet 标志 ,例如:
    <span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>kubelet-arg: - cpu-manager-policy=static - system-reserved=cpu=1,memory=1548Mi,ephemeral-storage=30Gi </code></span></span></span>
  5. Start the RKE2 or K3s service:
    启动 RKE2 或 K3s 服务:
    1. On RKE2 server nodes runsystemctl start rke2-server
      在 RKE2 服务器节点上运行systemctl start rke2-server
    2. On RKE2 agent nodes runsystemctl start rke2-agent
      在 RKE2 代理节点上运行systemctl start rke2-agent
    3. On K3s server nodes runsystemctl start k3s
      在 K3s 上,服务器节点运行systemctl start k3s
    4. On K3s agents nodes runsystemctl start k3s-agent

访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009

http://www.jsqmd.com/news/529966/

相关文章:

  • Linux系统优化Baichuan-M2-32B推理性能的10个技巧
  • DeepSeek API实战指南:从零开始,随心所欲集成你的AI助手
  • 制造业的中枢神经:MES系统如何驱动智慧工厂从“自动化”迈向“自主化”(PPT)
  • DeepSeek-R1-Distill-Qwen-1.5B政务咨询应用:合规问答系统搭建教程
  • EI 论文复现:基于净能力及二阶锥规划的分布式光储多场景协同优化策略
  • FLUX.1-dev效果验证:第三方评测机构对120亿参数模型的真实打分
  • OFA图像语义蕴含Web应用作品集:图文匹配AI精彩案例分享
  • 如何解决transformers库导入错误:Gemma3ForConditionalGeneration缺失的实战指南
  • Mac开发者必备:PlistEdit Pro 1.9.1最新版安装与JSON编辑避坑指南
  • 新手也能搞定的1kHz正弦波发生器:用运放和文氏电桥从仿真到洞洞板的完整避坑指南
  • 二极管选型避坑指南:从锗管到肖特基,5种常见类型优缺点对比
  • 3步突破安卓截图限制:Xposed-Disable-FLAG_SECURE终极指南
  • 163MusicLyrics:一站式音乐歌词获取与管理工具完全指南
  • Stable Diffusion XL 1.0部署案例:灵感画廊在Mac M2/M3芯片上的Metal加速适配
  • 集团数字化建设里程碑:DMS/TMS与LIMS系统全面启动,赋能质量管理体系
  • 突破视频监控壁垒:WVP-GB28181-Pro开源平台实战指南
  • Linux AXI-DMA 驱动调试与实战排错指南
  • 总结一下断言与防御式编程
  • 揭秘MCP Sampling接口RT飙升300%的真相:从gRPC拦截器到异步缓冲的7层调用链深度剖析
  • JS射线法实战:5分钟搞定电子围栏与快递区域判断(附完整代码)
  • 深入解析 G1 垃圾收集器核心机制:Region、记忆集、SATB、TAMS 与浮动垃圾
  • 探索Fusion Pixel Font:多尺寸像素字体解决方案在数字设计中的创新应用
  • PnetCDF 不支持 HDF5:你需要知道的全部事实
  • C++ 默认参数:彻底搞懂引用默认参数的核心用法
  • html每个层列出对应层的所有代码
  • 别再为创新点发愁!计算机视觉领域5个冷门但高效的研究方向
  • Spring Security 6.x认证机制深度解析:为什么你的/oauth/token接口在新版本中消失了?
  • 3个突破性步骤:跨平台虚拟化让Windows用户实现macOS无缝体验
  • Arduino小白必看:HC-SR505人体红外传感器的5个常见问题及解决方法
  • ILSpy深度解析:专业.NET反编译工具的实战进阶指南