-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #579 from qmhu/rf-docs
bugfix: Add docs for recommend, revert expression change
- Loading branch information
Showing
21 changed files
with
414 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
--- | ||
title: "Recommendation" | ||
weight: 10 | ||
description: > | ||
Docs for Recommendation. | ||
--- |
99 changes: 99 additions & 0 deletions
99
site/content/en/docs/Tutorials/Recommendation/how-to-develop-recommender.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
title: "How to develop Recommender" | ||
description: "Introduce how to develop and extend Recommender based on framework" | ||
weight: 100 | ||
--- | ||
|
||
Recommendation Framework provides an extensible framework for Recommender and supports several built-in Recommender. Users can implement a self-defined Recommender or modify the existing Recommenders. | ||
|
||
## Recommender Interface | ||
|
||
```go | ||
type Recommender interface { | ||
Name() string | ||
framework.Filter | ||
framework.PrePrepare | ||
framework.Prepare | ||
framework.PostPrepare | ||
framework.PreRecommend | ||
framework.Recommend | ||
framework.PostRecommend | ||
framework.Observe | ||
} | ||
|
||
// Phase: Filter | ||
|
||
// Filter interface | ||
type Filter interface { | ||
// The Filter will filter resource can`t be recommended via target recommender. | ||
Filter(ctx *RecommendationContext) error | ||
} | ||
|
||
// Phase: Prepare | ||
|
||
// PrePrepare interface | ||
type PrePrepare interface { | ||
CheckDataProviders(ctx *RecommendationContext) error | ||
} | ||
|
||
// Prepare interface | ||
type Prepare interface { | ||
CollectData(ctx *RecommendationContext) error | ||
} | ||
|
||
type PostPrepare interface { | ||
PostProcessing(ctx *RecommendationContext) error | ||
} | ||
|
||
// PreRecommend interface | ||
type PreRecommend interface { | ||
PreRecommend(ctx *RecommendationContext) error | ||
} | ||
|
||
// Phase: Recommend | ||
|
||
// Recommend interface | ||
type Recommend interface { | ||
Recommend(ctx *RecommendationContext) error | ||
} | ||
|
||
// PostRecommend interface | ||
type PostRecommend interface { | ||
Policy(ctx *RecommendationContext) error | ||
} | ||
|
||
// Phase: Observe | ||
|
||
// Observe interface | ||
type Observe interface { | ||
Observe(ctx *RecommendationContext) error | ||
} | ||
|
||
``` | ||
Recommender interface defines four stages and eight extension points that need to be implemented in recommender. These extension points are called sequentially during the recommendation process. Some of these extension points can change recommendation decisions, while others are only give information. | ||
|
||
## Architecture | ||
|
||
![](/images/recommendation-framework.png) | ||
|
||
## Phases | ||
|
||
The whole recommendation process is divided into four phases: Filter,Prepare,Recommend,Observe。Phase's input is the Kubernetes resource to analysis,output is the recommendation advise. Let's begin to introduce the inputs, outputs, and capabilities of each phase. | ||
|
||
`RecommendationContext` saved the context for a recommended process, including recommended target, RecommendationConfiguration etc., the user can add more content as needed. | ||
|
||
### Filter | ||
|
||
The Filter phase is used to preprocess the recommendation data. In general, it is necessary to decide whether the recommendation target matches Recommender during preprocessing. For example, the Resource Recommender only supports handling Workload (Deployment, StatefulSet). In addition, it can also determine whether the recommended target state is suitable for recommendation, such as whether it is being deleted or just created. The recommendation will be terminated when return error. BaseRecommender implements basic preprocessing functions and users can call it to inherit related functions. | ||
|
||
### Prepare | ||
|
||
The Prepare phase is used for data preparation, requesting an external monitoring system and saving the timing data in the context. PrePrepare extension point used to check the connection status of the monitoring system. Prepare extension point used to query time series data. The PostPrepare extension point is used to process time series data, such as abnormal cold start data, partial data loss, data aggregation, and clearing abnormal data. | ||
|
||
### Recommend | ||
|
||
The Recommend phase is used to optimize recommendations based on timing data and resource allocation. The type of optimization recommendation depends on the type of recommendation. For example, if it is a resource recommendation, then the output is the resource configuration for the kubernetes workload. The Recommend extension point is used to analyze and calculate the data using Crane's algorithm module, and the analysis result is finally processed in the PostRecommend stage. Users can customize it by implement their Recommend phase. | ||
|
||
### Observe | ||
|
||
The Observe phase is used to observe the recommendation result. For example, when recommending a resource, the information about the optimization proposal is saved to the monitoring system via Metric, and the revenue generated by the optimization proposal is observed through the Dashboard. |
Oops, something went wrong.