diff --git a/pkg/utils/expression_prom_default.go b/pkg/utils/expression_prom_default.go index 5155e23a6..96732182d 100644 --- a/pkg/utils/expression_prom_default.go +++ b/pkg/utils/expression_prom_default.go @@ -7,9 +7,9 @@ import ( // todo: later we change these templates to configurable like prometheus-adapter const ( // WorkloadCpuUsageExprTemplate is used to query workload cpu usage by promql, param is namespace,workload-name,duration str - WorkloadCpuUsageExprTemplate = `sum(irate(container_cpu_usage_seconds_total{namespace="%s",pod=~"^%s-.*$"}[%s]))` + WorkloadCpuUsageExprTemplate = `sum(irate(container_cpu_usage_seconds_total{namespace="%s",pod=~"^%s-.*$",container!=""}[%s]))` // WorkloadMemUsageExprTemplate is used to query workload mem usage by promql, param is namespace, workload-name - WorkloadMemUsageExprTemplate = `sum(container_memory_working_set_bytes{namespace="%s",pod=~"^%s-.*$"})` + WorkloadMemUsageExprTemplate = `sum(container_memory_working_set_bytes{namespace="%s",pod=~"^%s-.*$",container!=""})` // following is node exporter metric for node cpu/memory usage // NodeCpuUsageExprTemplate is used to query node cpu usage by promql, param is node name which prometheus scrape, duration str diff --git a/site/content/en/docs/Tutorials/Recommendation/idlenode-recommendation.md b/site/content/en/docs/Tutorials/Recommendation/idlenode-recommendation.md new file mode 100644 index 000000000..33e930fa7 --- /dev/null +++ b/site/content/en/docs/Tutorials/Recommendation/idlenode-recommendation.md @@ -0,0 +1,62 @@ +--- +title: "IdleNode Recommendation" +description: "Introduce for IdleNode Recommendation" +weight: 15 +--- + +By scanning the status and utilization of nodes, the idle node recommendation helps users to find idle Kubernetes nodes. + +## Motivation + +In Kubernetes cluster, some nodes often idle due to such factors as node taint, label selector, low packing rate and low utilization rate, which wastes a lot of costs. IdleNode recommendation tries to help users find these nodes to reduce cost. + +## Example + +```yaml +kind: Recommendation +apiVersion: analysis.crane.io/v1alpha1 +metadata: + name: idlenodes-rule-idlenode-5jxn9 + namespace: crane-system + labels: + analysis.crane.io/recommendation-rule-name: idlenodes-rule + analysis.crane.io/recommendation-rule-recommender: IdleNode + analysis.crane.io/recommendation-rule-uid: 8921a198-7082-11ed-8b7b-246e960a8d8c + analysis.crane.io/recommendation-target-kind: Node + analysis.crane.io/recommendation-target-name: worker-node-1 + analysis.crane.io/recommendation-target-version: v1 + beta.kubernetes.io/arch: amd64 + beta.kubernetes.io/instance-type: bareMetal + beta.kubernetes.io/os: linux + ownerReferences: + - apiVersion: analysis.crane.io/v1alpha1 + kind: RecommendationRule + name: idlenodes-rule + uid: 8921a198-7082-11ed-8b7b-246e960a8d8c + controller: false + blockOwnerDeletion: false +spec: + targetRef: + kind: Node + name: worker-node-1 + apiVersion: v1 + type: IdleNode + completionStrategy: {} +status: + targetRef: {} + action: Delete + lastUpdateTime: '2022-11-30T07:46:57Z' +``` + +In this example: + +- Recommendation's TargetRef Point to Node:worker-node-1 +- Recommendation type is IdleNode +- action is Delete,but offline a node is a complicated operation, we only give recommended advise. + +## Implement + +Perform the following steps to complete a recommendation process for idle nodes: + +1. Scan all nodes and pods in the cluster +2. If all Pods on a node are DaemonSet, the node is considered to be idle diff --git a/site/content/en/docs/Tutorials/Recommendation/recommendation-framework.md b/site/content/en/docs/Tutorials/Recommendation/recommendation-framework.md index bb7d4c40a..31e0bc76f 100644 --- a/site/content/en/docs/Tutorials/Recommendation/recommendation-framework.md +++ b/site/content/en/docs/Tutorials/Recommendation/recommendation-framework.md @@ -126,6 +126,8 @@ Currently, Crane support these Recommenders: - [**Resource Recommendation**](/docs/tutorials/recommendation/resource-recommendation): Use the VPA algorithm to analyze the actual usage of applications and recommend more appropriate resource configurations. - [**Replicas Recommendation**](/docs/tutorials/recommendation/replicas-recommendation): Use the HPA algorithm to analyze the actual usage of applications and recommend more appropriate replicas configurations. +- [**IdleNode Recommendation**](/docs/tutorials/recommendation/idlenode-recommendation): Find the idle nodes in cluster + ### Recommender Framework diff --git a/site/content/zh/docs/Tutorials/Recommendation/idlenode-recommendation.md b/site/content/zh/docs/Tutorials/Recommendation/idlenode-recommendation.md new file mode 100644 index 000000000..c057b7568 --- /dev/null +++ b/site/content/zh/docs/Tutorials/Recommendation/idlenode-recommendation.md @@ -0,0 +1,63 @@ +--- +title: "闲置节点推荐" +description: "闲置节点推荐功能介绍" +weight: 15 +--- + +闲置节点推荐通过扫描节点的状态和利用率,帮助用户找到闲置的 Kubernetes node。 + +## 动机 + +在使用 Kubernetes 的过程中,常常由于污点配置、label selector、低装箱率、低利用率等因素导致部分节点出现闲置状态,浪费了大量成本,闲置节点推荐尝试帮助用户找到这部分节点来实现成本优化。 + +## 推荐示例 + +```yaml +kind: Recommendation +apiVersion: analysis.crane.io/v1alpha1 +metadata: + name: idlenodes-rule-idlenode-5jxn9 + namespace: crane-system + labels: + analysis.crane.io/recommendation-rule-name: idlenodes-rule + analysis.crane.io/recommendation-rule-recommender: IdleNode + analysis.crane.io/recommendation-rule-uid: 8921a198-7082-11ed-8b7b-246e960a8d8c + analysis.crane.io/recommendation-target-kind: Node + analysis.crane.io/recommendation-target-name: worker-node-1 + analysis.crane.io/recommendation-target-version: v1 + beta.kubernetes.io/arch: amd64 + beta.kubernetes.io/instance-type: bareMetal + beta.kubernetes.io/os: linux + ownerReferences: + - apiVersion: analysis.crane.io/v1alpha1 + kind: RecommendationRule + name: idlenodes-rule + uid: 8921a198-7082-11ed-8b7b-246e960a8d8c + controller: false + blockOwnerDeletion: false +spec: + targetRef: + kind: Node + name: worker-node-1 + apiVersion: v1 + type: IdleNode + completionStrategy: {} +status: + targetRef: {} + action: Delete + lastUpdateTime: '2022-11-30T07:46:57Z' +``` + +在该示例中: + +- 推荐的 TargetRef 指向了 Node:worker-node-1 +- 推荐类型为闲置节点推荐 +- action 是 Delete,但是下线节点是复杂操作,这里只是给出建议 + +## 实现原理 + +闲置节点推荐按以下步骤完成一次推荐过程: + +1. 扫描集群中所有节点和节点上的 Pod +2. 如果节点上所有 Pod 都属于 DaemonSet,则判定为闲置节点 + diff --git a/site/content/zh/docs/Tutorials/Recommendation/recommendation-framework.md b/site/content/zh/docs/Tutorials/Recommendation/recommendation-framework.md index 0db829600..c8481c1dc 100644 --- a/site/content/zh/docs/Tutorials/Recommendation/recommendation-framework.md +++ b/site/content/zh/docs/Tutorials/Recommendation/recommendation-framework.md @@ -126,6 +126,7 @@ patchData=`kubectl get recommend workloads-rule-replicas-rckvb -n default -o jso - [**资源推荐**](/zh-cn/docs/tutorials/recommendation/resource-recommendation): 通过 VPA 算法分析应用的真实用量推荐更合适的资源配置 - [**副本数推荐**](/zh-cn/docs/tutorials/recommendation/replicas-recommendation): 通过 HPA 算法分析应用的真实用量推荐更合适的副本数量 +- [**闲置节点推荐**](/zh-cn/docs/tutorials/recommendation/idlenode-recommendation): 扫描集群中的闲置节点 ### Recommender 框架 diff --git a/site/content/zh/docs/Tutorials/Recommendation/replicas-recommendation.md b/site/content/zh/docs/Tutorials/Recommendation/replicas-recommendation.md index d07ffa3b8..4ca4ac79d 100644 --- a/site/content/zh/docs/Tutorials/Recommendation/replicas-recommendation.md +++ b/site/content/zh/docs/Tutorials/Recommendation/replicas-recommendation.md @@ -6,33 +6,120 @@ weight: 13 Kubernetes 用户在创建应用资源时常常是基于经验值来设置副本数。通过副本数推荐的算法分析应用的真实用量推荐更合适的副本配置,您可以参考并采纳它提升集群的资源利用率。 -## 实现原理 +## 动机 + +Kubernetes 工作负载的副本数可以控制 Pod 的数量进行快速的伸缩。然而,如何设置副本数量一直以来是困扰应用管理员的问题,副本数过多会导致大量的资源浪费,而过低的副本数又可能会存在稳定性问题。 + +社区的 HPA 提供了一种基于负载的动态伸缩机制,Crane 的 EHPA 基于 HPA 实现了基于预测的智能弹性。但是现实世界中,只有部分工作负载可以动态的水平伸缩,大量的工作负载需要在运行时保持固定的副本数。 + +下图展示了一个利用率过低的例子,该 Pod 的历史使用量的峰值与它的申请量 Request 之间,有30%的资源浪费。 + +![Resource Waste](/images/resource-waste.jpg) + +副本推荐尝试通过基于历史真实用量的分析降低用户配置工作负载副本数的复杂度。 + +## 推荐示例 + +一个简单的副本推荐 yaml 文件如下: + +```yaml +kind: Recommendation +apiVersion: analysis.crane.io/v1alpha1 +metadata: + name: workloads-rule-replicas-p84jv + namespace: kube-system + labels: + addonmanager.kubernetes.io/mode: Reconcile + analysis.crane.io/recommendation-rule-name: workloads-rule + analysis.crane.io/recommendation-rule-recommender: Replicas + analysis.crane.io/recommendation-rule-uid: 18588495-f325-4873-b45a-7acfe9f1ba94 + k8s-app: kube-dns + kubernetes.io/cluster-service: 'true' + kubernetes.io/name: CoreDNS + ownerReferences: + - apiVersion: analysis.crane.io/v1alpha1 + kind: RecommendationRule + name: workloads-rule + uid: 18588495-f325-4873-b45a-7acfe9f1ba94 + controller: false + blockOwnerDeletion: false +spec: + targetRef: + kind: Deployment + namespace: kube-system + name: coredns + apiVersion: apps/v1 + type: Replicas + completionStrategy: + completionStrategyType: Once + adoptionType: StatusAndAnnotation +status: + recommendedValue: + replicasRecommendation: + replicas: 1 + targetRef: { } + recommendedInfo: '{"spec":{"replicas":1}}' + currentInfo: '{"spec":{"replicas":2}}' + action: Patch + conditions: + - type: Ready + status: 'True' + lastTransitionTime: '2022-11-28T08:07:36Z' + reason: RecommendationReady + message: Recommendation is ready + lastUpdateTime: '2022-11-29T11:07:45Z' +``` -基于 Workload 历史 CPU 负载,找到过去七天内每小时负载最低的 CPU 用量,计算按50%(可配置)利用率和 Workload CPU Request 应配置的副本数 +在该示例中: -### Filter 阶段 +- 推荐的 TargetRef 指向 kube-system 的 Deployment:coredns +- 推荐类型为副本推荐 +- adoptionType 是 StatusAndAnnotation,表示将推荐结果展示在 recommendation.status 和 Deployment 的 Annotation +- recommendedInfo 显示了推荐的副本数(recommendedValue 已经 deprecated),currentInfo 显示了当前的副本数,格式是 Json ,可以通过 Kubectl Patch 将推荐结果更新到 + TargetRef -1. 低副本数的工作负载: 过低的副本数可能推荐需求不高,关联配置: `workload-min-replicas` -2. 存在一定比例非 Running Pod 的工作负载: 如果工作负载的 Pod 大多不能正常运行,可能不适合弹性,关联配置: `pod-min-ready-seconds` | `pod-available-ratio` +如何使用副本推荐请参考:[**推荐框架**](/zh-cn/docs/tutorials/recommendation/recommendation-framework) -### Prepare 阶段 +## 实现原理 -查询过去一周的 CPU 使用量 +副本推荐按以下步骤完成一次推荐过程: -### Recommend 阶段 +1. 通过监控数据,获取 Workload 过去一周的 CPU 和 Memory 历史用量。 +2. 用 DSP 算法预测未来一周 CPU 用量 +3. 分别计算 CPU 和 内存分别对应的副本数,取较大值 -1. 计算过去7天 workload 每小时使用量中位数的最低值(防止极小值影响): workload_cpu_usage_medium_min -2. 目标利用率对应的副本数: +### 计算副本算法 + +以 CPU 举例,假设工作负载 CPU 历史用量的 P99 是10核,Pod CPU Request 是5核,目标峰值利用率是50%,可知副本数是4个可以满足峰值利用率是50%。 ```go - replicas := int32(math.Ceil(workloadCpu / (rr.TargetUtilization * float64(requestTotal) / 1000.))) + replicas := int32(math.Ceil(workloadUsage / (TargetUtilization * float64(requestTotal) / 1000.))) ``` -3. 为了防止 replicas 过小,replicas 需要大于等于 default-min-replicas +### 排除异常的工作负载 + +以下类型的异常工作负载不进行推荐: -### Observe 阶段 +1. 低副本数的工作负载: 过低的副本数可能推荐需求不高,关联配置: `workload-min-replicas` +2. 存在一定比例非 Running Pod 的工作负载: 如果工作负载的 Pod 大多不能正常运行,可能不适合弹性,关联配置: `pod-min-ready-seconds` | `pod-available-ratio` -将推荐 replicas 记录到 Metric:crane_analytics_replicas_recommendation +### 通过 Prometheus Metric 监控推荐结果 + +副本推荐结果会记录到 Metric:crane_analytics_replicas_recommendation + +## 如何验证推荐结果的准确性 + +用户可以通过以下 Prom query 得到 Workload 的资源用量,将资源用量带入上面副本算法公式可验证推荐 TargetRef。 + +以 crane-system 的 Deployment Craned 为例,用户可以将 container, namespace, pod 换成希望验证的推荐结果。 + +```shell +sum(irate(container_cpu_usage_seconds_total{namespace="crane-system",pod=~"^craned-.*$",container!=""}[3m])) # cpu usage +``` + +```shell +sum(container_memory_working_set_bytes{namespace="crane-system",pod=~"^craned-.*$",container!=""}) # memory usage +``` ## 支持的资源类型 @@ -40,10 +127,15 @@ Kubernetes 用户在创建应用资源时常常是基于经验值来设置副本 ## 参数配置 -| 配置项 | 默认值 | 描述 | -| ------------- |-----|-----------------| -| workload-min-replicas| 1 | 小于该值的工作负载不做弹性推荐 | -| pod-min-ready-seconds| 30 | 定义了 Pod 是否 Ready 的秒数 | -| pod-available-ratio| 0.5 | Ready Pod 比例小于该值的工作负载不做弹性推荐 | -| default-min-replicas| 1 | 最小 minReplicas | -| cpu-target-utilization| 0.5 | 按该值计算最小副本数 | +| 配置项 | 默认值 | 描述 | +|------------------------|------|-----------------------------| +| workload-min-replicas | 1 | 小于该值的工作负载不做弹性推荐 | +| pod-min-ready-seconds | 30 | 定义了 Pod 是否 Ready 的秒数 | +| pod-available-ratio | 0.5 | Ready Pod 比例小于该值的工作负载不做弹性推荐 | +| default-min-replicas | 1 | 最小 minReplicas | +| cpu-percentile | 0.95 | 历史 CPU 用量的 Percentile | +| mem-percentile | 0.95 | 历史内存用量的 Percentile | +| cpu-target-utilization | 0.5 | CPU 目标峰值利用率 | +| mem-target-utilization | 0.5 | 内存目标峰值利用率 | + +如何更新推荐的配置请参考:[**推荐框架**](/zh-cn/docs/tutorials/recommendation/recommendation-framework) \ No newline at end of file diff --git a/site/content/zh/docs/Tutorials/Recommendation/resource-recommendation.md b/site/content/zh/docs/Tutorials/Recommendation/resource-recommendation.md index e1bf51f73..44bc09e4f 100644 --- a/site/content/zh/docs/Tutorials/Recommendation/resource-recommendation.md +++ b/site/content/zh/docs/Tutorials/Recommendation/resource-recommendation.md @@ -6,41 +6,198 @@ weight: 14 Kubernetes 用户在创建应用资源时常常是基于经验值来设置 request 和 limit。通过资源推荐的算法分析应用的真实用量推荐更合适的资源配置,您可以参考并采纳它提升集群的资源利用率。 +## 动机 + +Kubernetes 中 Request 定义了 Pod 运行需要的最小资源量,Limit 定义了 Pod 运行可使用的最大资源量,应用的资源利用率 Utilization = Request / 资源用量 Usage。不合理的资源利用率有以下两种情况: + +- 利用率过低:因为不清楚配置多少资源规格可以满足应用需求,或者是为了应对高峰流量时的资源消耗诉求,常常将 Request 设置得较大,这样就导致了过低的利用率,造成了浪费。 +- 利用率过高:由于高峰流量的业务压力,或者错误的资源配置,导致利用率过高,CPU 利用率过高时会引发更高的业务延时,内存利用率过高超过 Limit 会导致 Container 被 OOM Kill,影响业务的稳定。 + +下图展示了一个利用率过低的例子,该 Pod 的历史使用量的峰值与它的申请量 Request 之间,有30%的资源浪费。 + +![Resource Waste](/images/resource-waste.jpg) + +资源推荐尝试通过基于历史真实用量的分析降低用户配置容器规格的复杂度。 + +## 推荐示例 + +一个简单的资源推荐 yaml 文件如下: + +```yaml +kind: Recommendation +apiVersion: analysis.crane.io/v1alpha1 +metadata: + name: workloads-rule-resource-flzbv + namespace: crane-system + labels: + analysis.crane.io/recommendation-rule-name: workloads-rule + analysis.crane.io/recommendation-rule-recommender: Resource + analysis.crane.io/recommendation-rule-uid: 18588495-f325-4873-b45a-7acfe9f1ba94 + analysis.crane.io/recommendation-target-kind: Deployment + analysis.crane.io/recommendation-target-name: load-test + analysis.crane.io/recommendation-target-version: v1 + app: craned + app.kubernetes.io/instance: crane + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: crane + app.kubernetes.io/version: v0.7.0 + helm.sh/chart: crane-0.7.0 + ownerReferences: + - apiVersion: analysis.crane.io/v1alpha1 + kind: RecommendationRule + name: workloads-rule + uid: 18588495-f325-4873-b45a-7acfe9f1ba94 + controller: false + blockOwnerDeletion: false +spec: + targetRef: + kind: Deployment + namespace: crane-system + name: craned + apiVersion: apps/v1 + type: Resource + completionStrategy: + completionStrategyType: Once + adoptionType: StatusAndAnnotation +status: + recommendedValue: + resourceRequest: + containers: + - containerName: craned + target: + cpu: 150m + memory: 256Mi + - containerName: dashboard + target: + cpu: 150m + memory: 256Mi + targetRef: {} + recommendedInfo: >- + {"spec":{"template":{"spec":{"containers":[{"name":"craned","resources":{"requests":{"cpu":"150m","memory":"256Mi"}}},{"name":"dashboard","resources":{"requests":{"cpu":"150m","memory":"256Mi"}}}]}}}} + currentInfo: >- + {"spec":{"template":{"spec":{"containers":[{"name":"craned","resources":{"requests":{"cpu":"500m","memory":"512Mi"}}},{"name":"dashboard","resources":{"requests":{"cpu":"200m","memory":"256Mi"}}}]}}}} + action: Patch + conditions: + - type: Ready + status: 'True' + lastTransitionTime: '2022-11-29T04:07:44Z' + reason: RecommendationReady + message: Recommendation is ready + lastUpdateTime: '2022-11-30T03:07:49Z' +``` + +在该示例中: + +- 推荐的 TargetRef 指向 crane-system 的 Deployment:craned +- 推荐类型为资源推荐 +- adoptionType 是 StatusAndAnnotation,表示将推荐结果展示在 recommendation.status 和 Deployment 的 Annotation +- recommendedInfo 显示了推荐的资源配置(recommendedValue 已经 deprecated),currentInfo 显示了当前的资源配置,格式是 Json ,可以通过 Kubectl Patch 将推荐结果更新到 TargetRef + +如何使用资源推荐请参考:[**推荐框架**](/zh-cn/docs/tutorials/recommendation/recommendation-framework) + ## 实现原理 -算法模型采用了 VPA 的滑动窗口(Moving Window)算法进行推荐 +资源推荐按以下步骤完成一次推荐过程: + +1. 通过监控数据,获取 Workload 过去一周的 CPU 和 Memory 历史用量。 +2. 基于历史用量通过 VPA Histogram 取 P99 百分位后再乘以放大系数 +3. OOM 保护:如果容器存在历史的 OOM 事件,则考虑 OOM 时的内存适量增大内存推荐结果 +4. 资源规格规整:按指定的容器规格对推荐结果向上取整 -1. 通过监控数据,获取 Workload 过去一周(可配置)的 CPU 和 Memory 历史用量。 -2. 算法考虑数据的时效性,较新的数据采样点会拥有更高的权重。 -3. CPU 推荐值基于用户设置的目标百分位值计算,Memory 推荐值基于历史数据的最大值 +基本原理是基于历史的资源用量,将 Request 配置成略高于历史用量的最大值并且考虑 OOM,Pod 规格等因素。 -### Filter 阶段 +### VPA 算法 -没有 Pod 的工作负载: 如果工作负载没有 Pod,无法进行算法分析 +资源推荐的核心思想是基于历史资源用量推荐合理的资源配置,我们采用了社区 VPA Histogram 算法来实现。VPA 算法将历史的资源用量放到直方图中,找到资源用量的 P99 百分数,将百分数乘以放大系数作为推荐值。 -### Recommend 推荐 +VPA 算法的 output 是 cpu、内存指标的 P99 用量。为了给应用预留 buffer,推荐结果还会乘以放大系数。资源推荐支持两种方式配置放大系数: -采用 VPA 的滑动窗口(Moving Window)算法分别计算每个容器的 CPU 和 Memory 并给出对应的推荐值 +- 扩大比例:推荐结果=P99用量 * (1 + 放大系数),对应配置:cpu-request-margin-fraction 和 mem-request-margin-fraction +- 目标峰值利用率:以 P99用量为目标峰值用量计算,推荐结果=P99用量/目标峰值利用率,对应配置:cpu-target-utilization 和 mem-target-utilization -### Observe 推荐 +在您有应用的目标峰值利用率目标时,推荐使用**目标峰值利用率**方式放大推荐结果。 -将推荐资源配置记录到 Metric:crane_analytics_replicas_recommendation +### OOM 保护 -## 支持的资源类型 +Craned 运行了单独的组件 OOMRecorder ,它记录了集群中 container OOM 的事件,资源推荐会读取 OOM 事件获取 OOM 时刻的内存使用,将内存使用乘以放大系数后与 VPA 的内存推荐结果比较,取较大值 + +### 资源规格规整 + +在 Kubernetes Serverless 中,Pod 的 cpu、内存规格是预设的,资源推荐支持对推荐结果按预设的资源规格向上取整,例如,基于历史用量的 cpu 推荐值为0.125核,资源规格规整后向上取整后为 0.25核。用户也可以通过修改规格配置来满足自己环境的规格需求。 + +### 通过 Prometheus Metric 监控推荐结果 + +推荐资源的推荐结果会记录到 Metric:crane_analysis_resource_recommendation + +## 如何验证推荐结果的准确性 + +用户可以通过以下 Prom query 得到 Workload Container 的资源用量,推荐值会略高于历史用量的最大值并且考虑 OOM,Pod 规格等因素。 + +以 crane-system 的 Deployment Craned 为例,用户可以将 container, namespace, pod 换成希望验证的推荐 TargetRef。 + +```shell +irate(container_cpu_usage_seconds_total{container!="POD",namespace="crane-system",pod=~"^craned.*$",container="craned"}[3m]) # cpu usage +``` + +```shell +container_memory_working_set_bytes{container!="POD",namespace="crane-system",pod=~"^craned.*$",container="craned"} # memory usage +``` + +## 支持推荐的资源类型 默认支持 StatefulSet 和 Deployment,但是支持所有实现了 Scale SubResource 的 Workload。 ## 参数配置 -| 配置项 | 默认值 | 描述 | -|-----------------------------|------|--------------------------------| -| cpu-sample-interval | 1m | 请求 CPU 监控数据的 Metric 采样点时间间隔 | -| cpu-request-percentile | 0.99 | CPU 百分位值 | -| cpu-request-margin-fraction | 0.15 | CPU 推荐值扩大系数,0.15指推荐值乘以 1.15 | -| cpu-target-utilization | 1 | CPU 目标利用率,0.8 指推荐值除以 0.8 | -| cpu-model-history-length | 168h | CPU 历史监控数据的时间 | -| mem-sample-interval | 1m | 请求 Memory 监控数据的 Metric 采样点时间间隔 | -| mem-request-percentile | 0.99 | Memory 百分位值 | -| mem-request-margin-fraction | 0.15 | Memory 推荐值扩大系数,0.15指推荐值乘以 1.15 | -| mem-target-utilization | 1 | Memory 目标利用率,0.8 指推荐值除以 0.8 | -| mem-model-history-length | 168h | Memory 历史监控数据的时间 | +| 配置项 | 默认值 | 描述 | +|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------| +| cpu-sample-interval | 1m | 请求 CPU 监控数据的 Metric 采样点时间间隔 | +| cpu-request-percentile | 0.99 | CPU 百分位值 | +| cpu-request-margin-fraction | 0.15 | CPU 推荐值扩大系数,0.15指推荐值乘以 1.15 | +| cpu-target-utilization | 1 | CPU 目标利用率,0.8 指推荐值除以 0.8 | +| cpu-model-history-length | 168h | CPU 历史监控数据的时间 | +| mem-sample-interval | 1m | 请求 Memory 监控数据的 Metric 采样点时间间隔 | +| mem-request-percentile | 0.99 | Memory 百分位值 | +| mem-request-margin-fraction | 0.15 | Memory 推荐值扩大系数,0.15指推荐值乘以 1.15 | +| mem-target-utilization | 1 | Memory 目标利用率,0.8 指推荐值除以 0.8 | +| specification | false | 是否开启资源规格规整 | +| specification-config | "" | 资源规格,注意格式,详细的默认配置请见下方表格 | +| oom-protection | true | 是否开启资源规格规整 | +| oom-history-length | 168h | OOM 历史事件的事件,过期事件会被忽略 | +| oom-bump-ratio | 1.2 | OOM 内存放大系数 | + +如何更新推荐的配置请参考:[**推荐框架**](/zh-cn/docs/tutorials/recommendation/recommendation-framework) + +## 默认的资源机型规格配置 + +| CPU(核) | Memory(GBi) | +|--------|-------------| +| 0.25 | 0.25 | +| 0.25 | 0.5 | +| 0.25 | 1 | +| 0.5 | 0.5 | +| 0.5 | 1 | +| 1 | 1 | +| 1 | 2 | +| 1 | 4 | +| 1 | 8 | +| 2 | 2 | +| 2 | 4 | +| 2 | 8 | +| 2 | 16 | +| 4 | 4 | +| 4 | 8 | +| 4 | 16 | +| 4 | 32 | +| 8 | 8 | +| 8 | 16 | +| 8 | 32 | +| 8 | 64 | +| 16 | 32 | +| 16 | 64 | +| 16 | 128 | +| 32 | 64 | +| 32 | 128 | +| 32 | 256 | +| 64 | 128 | +| 64 | 256 | diff --git a/site/static/images/resource-waste.jpg b/site/static/images/resource-waste.jpg new file mode 100644 index 000000000..64c00a598 Binary files /dev/null and b/site/static/images/resource-waste.jpg differ