# podBalancer **Repository Path**: yunwe/podBalancer ## Basic Information - **Project Name**: podBalancer - **Description**: 本项目旨在动态调度集群中的Pod,可以根据集群资源使用率随时调整Pod所处节点,尽可能使每个节点资源使用率相对均衡。 - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-23 - **Last Updated**: 2025-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: Kubernetes, 调度, Python ## README # podBalancer ## 介绍 本项目旨在动态调度集群中的Pod,可以根据集群资源使用率随时调整Pod所处节点,尽可能使每个节点资源使用率相对均衡。 ### 为什么不使用 descheduler [descheduler](https://github.com/kubernetes-sigs/descheduler) 数据来源为 metric-server,实际测试资源使用率不是很准确,另外不支持白名单策略(一部分资源不允许重启) ### 说明 现有的Kubernetes调度策略在调度完Pod后无论Pod资源使用率如何增长都不会再次重新分配,比如某个节点一开始资源使用率为60%,随着时间增长到90%, 此时只能通过手动删除一部分Pod触发重新调度,非常繁琐,而且手动重启后pod可能还停留在原节点。 poBalancer 会在过滤白名单后重启剩余pod中占用内存最高的那个 ## 部署 ### 部署依赖 PodBalancer 强依赖node-exporter,必须部署,可以使用k8s或者本地方式,这里使用k8s部署 ```shell kubectl apply -f https://gitee.com/yunwe/podBalancer/raw/master/doc/node-exporter.yaml ``` ### 使用已有镜像 ```shell kubectl apply -f https://gitee.com/yunwe/podBalancer/raw/master/doc/podBalancer.yaml ``` ### 镜像构建 ```shell git clone https://gitee.com/yunwe/podBalancer.git cd podBalancer docker build register.test.com/podbalancer:v0.1 . ``` ## 配置文件说明 ```yaml logging: level: INFO format: '%(asctime)s - %(levelname)s - %(message)s' whiteList: # 设置白名单,指定namespace不进行任何处理 kube-system: '*' # 支持指定deployment|StatefulSet|DaemonSet资源类型、资源名称添加到白名单 monitoring: deployment: '*' default: statefulset: "nginx" mem_threshold: 80 # 设置白名单,指定namespace不进行任何处理 aliases: node1: "http://192.168.111.141:9100" node2: "http://192.168.111.143:9100" # 添加主机,主机名称可随意 hosts: - "node1" - "node2" ```