Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Recommendation framework #445

Merged
merged 19 commits into from
Aug 18, 2022
Merged

feat: Recommendation framework #445

merged 19 commits into from
Aug 18, 2022

Conversation

xieydd
Copy link
Member

@xieydd xieydd commented Jul 28, 2022

What type of PR is this?

Feature

What this PR does / why we need it:

Define recommendation framework interfaces .
Implement replicas recommendation via framework.

Special notes for your reviewer:

@qmhu

@xieydd xieydd requested a review from qmhu July 28, 2022 09:25
@xieydd
Copy link
Member Author

xieydd commented Jul 28, 2022

/hold

@github-actions
Copy link
Contributor

github-actions bot commented Jul 28, 2022

♻️ PR Preview b7228dd has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

@xieydd xieydd changed the title (WIP) Recommendation framework Recommendation framework Aug 10, 2022
@xieydd
Copy link
Member Author

xieydd commented Aug 10, 2022

done. pls review this pr @qmhu

@github-actions
Copy link
Contributor

github-actions bot commented Aug 10, 2022

🎉 Successfully Build Images.
Now Support ARM Platforms.
Comment Post Time: 2022-08-19 01:53
Git Version: b7228dd

Docker Registry

Overview: https://hub.docker.com/u/gocrane

Image Pull Command
crane-agent:pr-445-b7228dd docker pull gocrane/crane-agent:pr-445-b7228dd
dashboard:pr-445-b7228dd docker pull gocrane/dashboard:pr-445-b7228dd
metric-adapter:pr-445-b7228dd docker pull gocrane/metric-adapter:pr-445-b7228dd
craned:pr-445-b7228dd docker pull gocrane/craned:pr-445-b7228dd

Quick Deploy - Helm

helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace \
                   --set craned.image.repository=gocrane/craned \
                   --set craned.image.tag=pr-445-b7228dd \
                   --set metricAdapter.image.repository=gocrane/metric-adapter \
                   --set metricAdapter.image.tag=pr-445-b7228dd \
                   --set craneAgent.image.repository=gocrane/crane-agent \
                   --set craneAgent.image.tag=pr-445-b7228dd \
                   --set cranedDashboard.image.repository=gocrane/dashboard \
                   --set cranedDashboard.image.tag=pr-445-b7228dd crane/crane

Coding Registry

Overview: https://finops.coding.net/public-artifacts/gocrane/crane/packages

Image Pull Command
crane-agent:pr-445-b7228dd docker pull finops-docker.pkg.coding.net/gocrane/crane/crane-agent:pr-445-b7228dd
dashboard:pr-445-b7228dd docker pull finops-docker.pkg.coding.net/gocrane/crane/dashboard:pr-445-b7228dd
metric-adapter:pr-445-b7228dd docker pull finops-docker.pkg.coding.net/gocrane/crane/metric-adapter:pr-445-b7228dd
craned:pr-445-b7228dd docker pull finops-docker.pkg.coding.net/gocrane/crane/craned:pr-445-b7228dd

Quick Deploy - Helm

helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace \
                   --set craned.image.repository=finops-docker.pkg.coding.net/gocrane/crane/craned \
                   --set craned.image.tag=pr-445-b7228dd \
                   --set metricAdapter.image.repository=finops-docker.pkg.coding.net/gocrane/crane/metric-adapter \
                   --set metricAdapter.image.tag=pr-445-b7228dd \
                   --set craneAgent.image.repository=finops-docker.pkg.coding.net/gocrane/crane/crane-agent \
                   --set craneAgent.image.tag=pr-445-b7228dd \
                   --set cranedDashboard.image.repository=finops-docker.pkg.coding.net/gocrane/crane/dashboard \
                   --set cranedDashboard.image.tag=pr-445-b7228dd crane/crane

Ghcr Registry

Overview: https://github.com/orgs/gocrane/packages?repo_name=crane

Image Pull Command
crane-agent:pr-445-b7228dd docker pull ghcr.io/gocrane/crane/crane-agent:pr-445-b7228dd
dashboard:pr-445-b7228dd docker pull ghcr.io/gocrane/crane/dashboard:pr-445-b7228dd
metric-adapter:pr-445-b7228dd docker pull ghcr.io/gocrane/crane/metric-adapter:pr-445-b7228dd
craned:pr-445-b7228dd docker pull ghcr.io/gocrane/crane/craned:pr-445-b7228dd

Quick Deploy - Helm

helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace \
                   --set craned.image.repository=ghcr.io/gocrane/crane/craned \
                   --set craned.image.tag=pr-445-b7228dd \
                   --set metricAdapter.image.repository=ghcr.io/gocrane/crane/metric-adapter \
                   --set metricAdapter.image.tag=pr-445-b7228dd \
                   --set craneAgent.image.repository=ghcr.io/gocrane/crane/crane-agent \
                   --set craneAgent.image.tag=pr-445-b7228dd \
                   --set cranedDashboard.image.repository=ghcr.io/gocrane/crane/dashboard \
                   --set cranedDashboard.image.tag=pr-445-b7228dd crane/crane

pkg/recommendation/replicas/fliter.go Outdated Show resolved Hide resolved
pkg/recommendation/replicas/prepare.go Outdated Show resolved Hide resolved
func (rr *ReplicasRecommender) PreRecommend(ctx *framework.RecommendationContext) error {
// we load algorithm config in this phase
// TODO(chrisydxie) support configuration
config := &config.Config{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we have multiple algo config

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe the specific user case? Do we need hyper-parameter search?

pkg/recommendation/replicas/recommend.go Outdated Show resolved Hide resolved
@@ -73,3 +79,33 @@ func NewRecommendationContext(context context.Context, identity analytics.Object
// return false
// }
//}

func ToK8SObject(object interface{}, target interface{}) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can move those func to a separate file, not context.go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest a file name?

return json.Unmarshal(bytes, target)
}

func GetDaemonSetPods(kubeClient client.Client, namespace string, name string) ([]corev1.Pod, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated with utils GetDaemonSetPods.

// }
//}

func ObjectConversion(object interface{}, target interface{}) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need change Object and ObjectIdenty to seperate file, not context.go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest a filename ?

}

// will be use in future.
// if no data provider config set, use default history data provider
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need grpc data source.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can implement it in future.

pkg/recommendation/recommender/hpa/observe.go Outdated Show resolved Hide resolved
return fmt.Errorf("%s checkFluctuation failed: %v", rr.Name(), err)
}

targetUtilization, requestTotal, err := rr.proposeTargetUtilization(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix lint error.

}

// checkFluctuation check if the time series fluctuation is reach to replicas.fluctuation-threshold
func (rr *HPARecommender) checkFluctuation(medianMin, medianMax float64) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look like same as replicas function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a hpa recommendation function. Already remove from replicas recommender.

return nil
}

func (rr *ResourceRecommender) CollectData(ctx *framework.RecommendationContext) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource no need collect data?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently on.

"github.com/gocrane/crane/pkg/utils"
)

const callerFormat = "RecommendationCaller-%s-%s"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as hpa recommender, need change to ResourceRecommederCaller-%s-%s.

const callerFormat = "RecommendationCaller-%s-%s"

func (rr *ResourceRecommender) PreRecommend(ctx *framework.RecommendationContext) error {
return nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need load algoritjm config?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every container has two algoritjm config: cpu and memory ,so cannot use context's algoritjm config. we may need to reconsider it.

Signed-off-by: qmhu <brillantroad@gmail.com>
@qmhu qmhu merged commit 940f57f into main Aug 18, 2022
@qmhu qmhu changed the title Recommendation framework feat: Recommendation framework Aug 18, 2022
@xieydd
Copy link
Member Author

xieydd commented Aug 19, 2022

link: #433

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants