From 7cf0bbcba9a95ab361f203437d319294622599e9 Mon Sep 17 00:00:00 2001 From: qmhu Date: Tue, 17 May 2022 17:25:15 +0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: zsnmwy <35299017+zsnmwy@users.noreply.github.com> --- .../tutorials/analytics-and-recommendation.md | 4 +-- docs/tutorials/hpa-recommendation.md | 35 ++++++++++++------- docs/tutorials/hpa-recommendation.zh.md | 31 ++++++++++------ docs/tutorials/resource-recommendation.md | 26 ++++++++++---- docs/tutorials/resource-recommendation.zh.md | 24 +++++++++---- ...ve-hpa-to-scaling-with-effectiveness.zh.md | 2 +- 6 files changed, 84 insertions(+), 38 deletions(-) diff --git a/docs/tutorials/analytics-and-recommendation.md b/docs/tutorials/analytics-and-recommendation.md index 31bbe6284..6d30ca5bf 100644 --- a/docs/tutorials/analytics-and-recommendation.md +++ b/docs/tutorials/analytics-and-recommendation.md @@ -15,8 +15,8 @@ Two Recommendations are currently supported: 1. Users create `Analytics` object and config ResourceSelector to select resources to be analyzed. Multiple types of resource selection (based on Group,Kind, and Version) are supported. 2. Analyze each selected resource in parallel and try to execute analysis and give recommendation. Each analysis process is divided into two stages: inspecting and advising: - 1. Inspecting: Filter resources that don't match the recommended conditions. For example, for hpa recommendation, the workload that have many not running pod is excluded - 2. Advising: Analysis and calculate based on algorithm model then provide the recommendation result. + 1. Inspecting: Filter resources that don't match the recommended conditions. For example, for hpa recommendation, the workload that has many not running pod is excluded + 2. Advising: Analysis and calculation based on algorithm model then provide the recommendation result. 3. If you paas the above two stages, it will create `Recommendation` object and display the result in `recommendation.Status` 4. You can find the failure reasons from `analytics.status.recommendations` 5. Wait for the next analytics based on the interval diff --git a/docs/tutorials/hpa-recommendation.md b/docs/tutorials/hpa-recommendation.md index 200bdbe54..6af738551 100644 --- a/docs/tutorials/hpa-recommendation.md +++ b/docs/tutorials/hpa-recommendation.md @@ -1,16 +1,27 @@ # HPA Recommendation -Using hpa recommendations, you can find resources in the cluster that are suitable for autoscaling, and use Crane's recommended result to create autoscaling object: [Effective HorizontalPodAutoscaler](tutorials/using-time-series-prediction.md) +Using hpa recommendations, you can find resources in the cluster that are suitable for autoscaling, and use Crane's recommended result to create an autoscaling object: [Effective HorizontalPodAutoscaler](using-time-series-prediction.md). ## Create HPA Analytics Create an **Resource** `Analytics` to give recommendation for deployment: `nginx-deployment` as a sample. -```bash -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-hpa.yaml -kubectl get analytics -``` +=== "Main" + + ```bash + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-hpa.yaml + kubectl get analytics + ``` + +=== "Mirror" + + ```bash + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/nginx-deployment.yaml?download=false + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/analytics-hpa.yaml?download=false + kubectl get analytics + ``` + ```yaml title="analytics-hpa.yaml" apiVersion: analysis.crane.io/v1alpha1 @@ -39,7 +50,7 @@ NAME AGE nginx-hpa 16m ``` -You can get created recommendation from analytics status: +You can get created recommendations from analytics status: ```bash kubectl get analytics nginx-hpa -o yaml @@ -47,7 +58,7 @@ kubectl get analytics nginx-hpa -o yaml The output is similar to: -```yaml +```yaml hl_lines="32" apiVersion: analysis.crane.io/v1alpha1 kind: Analytics metadata: @@ -154,10 +165,10 @@ status: ### Inspecting -1. Workload with low replicas: If the replicas is too low, may not be suitable for hpa recommendation. Associated configuration: ehpa.deployment-min-replicas | ehpa.statefulset-min-replicas | ehpa.workload-min-replicas -2. Workload with a certain percentage of not running pods: if the workload of Pod mostly can't run normally, may not be suitable for flexibility. Associated configuration: ehpa.pod-min-ready-seconds | ehpa.pod-available-ratio -3. Workload with low cpu usage: The low CPU usage workload means that there is no load pressure. In this case, we can't estimate it. Associated configuration: ehpa.min-cpu-usage-threshold -4. Workload with low fluctuation of cpu usage: dividing of the maximum and minimum usage is defined as the fluctuation rate. If the fluctuation rate is too low, the workload will not benefit much from hpa. Associated configuration: ehpa.fluctuation-threshold +1. Workload with low replicas: If the replicas is too low, may not be suitable for hpa recommendation. Associated configuration: `ehpa.deployment-min-replicas` | `ehpa.statefulset-min-replicas` | `ehpa.workload-min-replicas` +2. Workload with a certain percentage of not running pods: if the workload of Pod mostly can't run normally, may not be suitable for flexibility. Associated configuration: `ehpa.pod-min-ready-seconds` | `ehpa.pod-available-ratio` +3. Workload with low CPU usage: The low CPU usage workload means that there is no load pressure. In this case, we can't estimate it. Associated configuration: `ehpa.min-cpu-usage-threshold` +4. Workload with low fluctuation of CPU usage: dividing of the maximum and minimum usage is defined as the fluctuation rate. If the fluctuation rate is too low, the workload will not benefit much from hpa. Associated configuration: `ehpa.fluctuation-threshold` ### Advising diff --git a/docs/tutorials/hpa-recommendation.zh.md b/docs/tutorials/hpa-recommendation.zh.md index 5bdae2ec8..3590bfe47 100644 --- a/docs/tutorials/hpa-recommendation.zh.md +++ b/docs/tutorials/hpa-recommendation.zh.md @@ -6,11 +6,22 @@ 创建一个**弹性分析** `Analytics`,这里我们通过实例 deployment: `nginx` 作为一个例子 -```bash -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-hpa.yaml -kubectl get analytics -``` +=== "Main" + + ```bash + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-hpa.yaml + kubectl get analytics + ``` + +=== "Mirror" + + ```bash + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/nginx-deployment.yaml?download=false + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/analytics-hpa.yaml?download=false + kubectl get analytics + ``` + ```yaml title="analytics-hpa.yaml" apiVersion: analysis.crane.io/v1alpha1 @@ -47,7 +58,7 @@ kubectl get analytics nginx-hpa -o yaml 结果如下: -```yaml +```yaml hl_lines="32" apiVersion: analysis.crane.io/v1alpha1 kind: Analytics metadata: @@ -154,10 +165,10 @@ status: ### 筛选阶段 -1. 低副本数的工作负载: 过低的副本数可能弹性需求不高,关联配置: ehpa.deployment-min-replicas | ehpa.statefulset-min-replicas | ehpa.workload-min-replicas -2. 存在一定比例非 Running Pod 的工作负载: 如果工作负载的 Pod 大多不能正常运行,可能不适合弹性,关联配置: ehpa.pod-min-ready-seconds | ehpa.pod-available-ratio -3. 低 CPU 使用量的工作负载: 过低使用量的工作负载意味着没有业务压力,此时通过使用率推荐弹性不准,关联配置: ehpa.min-cpu-usage-threshold -4. CPU 使用量的波动率过低: 使用量的最大值和最小值的倍数定义为波动率,波动率过低的工作负载通过弹性降本的收益不大,关联配置: ehpa.fluctuation-threshold +1. 低副本数的工作负载: 过低的副本数可能弹性需求不高,关联配置: `ehpa.deployment-min-replicas` | `ehpa.statefulset-min-replicas` | `ehpa.workload-min-replicas` +2. 存在一定比例非 Running Pod 的工作负载: 如果工作负载的 Pod 大多不能正常运行,可能不适合弹性,关联配置: `ehpa.pod-min-ready-seconds` | `ehpa.pod-available-ratio` +3. 低 CPU 使用量的工作负载: 过低使用量的工作负载意味着没有业务压力,此时通过使用率推荐弹性不准,关联配置: `ehpa.min-cpu-usage-threshold` +4. CPU 使用量的波动率过低: 使用量的最大值和最小值的倍数定义为波动率,波动率过低的工作负载通过弹性降本的收益不大,关联配置: `ehpa.fluctuation-threshold` ### 推荐 diff --git a/docs/tutorials/resource-recommendation.md b/docs/tutorials/resource-recommendation.md index 6eb46324b..bbc50b077 100644 --- a/docs/tutorials/resource-recommendation.md +++ b/docs/tutorials/resource-recommendation.md @@ -6,11 +6,23 @@ Resource recommendation allows you to obtain recommended values for resources in Create an **Resource** `Analytics` to give recommendation for deployment: `nginx-deployment` as a sample. -```bash -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-resource.yaml -kubectl get analytics -n crane-system -``` + +=== "Main" + + ```bash + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-resource.yaml + kubectl get analytics -n crane-system + ``` + +=== "Mirror" + + ```bash + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/nginx-deployment.yaml?download=false + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/analytics-resource.yaml?download=false + kubectl get analytics -n crane-system + ``` + ```yaml title="analytics-resource.yaml" hl_lines="7 24 11-14 28-31" apiVersion: analysis.crane.io/v1alpha1 @@ -43,7 +55,7 @@ kubectl get analytics nginx-resource -o yaml The output is similar to: -```yaml +```yaml hl_lines="27" apiVersion: analysis.crane.io/v1alpha1 kind: Analytics metadata: @@ -85,7 +97,7 @@ The recommendation name presents on `status.recommendations[0].name`. Then you c ## Recommendation: Analytics result ```bash -kubectl get recommend -n crane-system craned-resource-resource-j7shb -o yaml +kubectl get recommend -n crane-system nginx-resource-resource-w45nq -o yaml ``` The output is similar to: diff --git a/docs/tutorials/resource-recommendation.zh.md b/docs/tutorials/resource-recommendation.zh.md index 2a1d65497..36fe16e29 100644 --- a/docs/tutorials/resource-recommendation.zh.md +++ b/docs/tutorials/resource-recommendation.zh.md @@ -6,11 +6,23 @@ 创建一个**资源分析** `Analytics`,这里我们通过实例 deployment: `nginx` 作为一个例子 -```bash -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml -kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-resource.yaml -kubectl get analytics -``` + +=== "Main" + + ```bash + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/nginx-deployment.yaml + kubectl apply -f https://raw.githubusercontent.com/gocrane/crane/main/examples/analytics/analytics-resource.yaml + kubectl get analytics + ``` + +=== "Mirror" + + ```bash + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/nginx-deployment.yaml?download=false + kubectl apply -f https://finops.coding.net/p/gocrane/d/crane/git/raw/main/examples/analytics/analytics-resource.yaml?download=false + kubectl get analytics + ``` + ```yaml title="analytics-resource.yaml" apiVersion: analysis.crane.io/v1alpha1 @@ -43,7 +55,7 @@ kubectl get analytics nginx-resource -o yaml 结果如下: -```yaml +```yaml hl_lines="27" apiVersion: analysis.crane.io/v1alpha1 kind: Analytics metadata: diff --git a/docs/tutorials/using-effective-hpa-to-scaling-with-effectiveness.zh.md b/docs/tutorials/using-effective-hpa-to-scaling-with-effectiveness.zh.md index 9037ac4a3..0347177ab 100644 --- a/docs/tutorials/using-effective-hpa-to-scaling-with-effectiveness.zh.md +++ b/docs/tutorials/using-effective-hpa-to-scaling-with-effectiveness.zh.md @@ -213,8 +213,8 @@ status: ``` 原因:不是所有的工作负载的 CPU 使用率都是可预测的,当无法预测时就会显示以上错误。 -reason: Not all workload's cpu metric are predictable, if predict your workload failed, it will show above errors. 解决方案: + - 等一段时间再看。预测算法 `DSP` 需要一定时间的数据才能进行预测。希望了解算法细节的可以查看算法的文档。 - EffectiveHorizontalPodAutoscaler 提供一种保护机制,当预测失效时依然能通过实际的 CPU 使用率工作。 \ No newline at end of file