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

Add Recommendation API #4

Merged
merged 6 commits into from
Nov 26, 2021
Merged

Add Recommendation API #4

merged 6 commits into from
Nov 26, 2021

Conversation

yufeiyu
Copy link
Contributor

@yufeiyu yufeiyu commented Nov 24, 2021

No description provided.


// RecommendationSpec describes the recommendation type and what the recommendation is for.
type RecommendationSpec struct {
TargetRef autoscalingv2.CrossVersionObjectReference `json:"targetRef"`
Copy link
Contributor

Choose a reason for hiding this comment

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

missing omitempty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a mandatory field

// RecommendationSpec describes the recommendation type and what the recommendation is for.
type RecommendationSpec struct {
TargetRef autoscalingv2.CrossVersionObjectReference `json:"targetRef"`
Namespace string `json:"namespace"`
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to have cross namespace support for this?

Copy link
Contributor Author

@yufeiyu yufeiyu Nov 24, 2021

Choose a reason for hiding this comment

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

No.
RecommendationSpec should refer to a specific workload, which is uniquely identified by 'namespace/apiversion/kind/name'


type AdvancedHorizontalPodAutoscalerRecommendation struct {
// optional
MinReplicas *int32
Copy link
Contributor

Choose a reason for hiding this comment

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

what about other properties in AHPA?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently this is a place holder, and @qmhu can provide more in future:)

Copy link
Member

Choose a reason for hiding this comment

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

yeah, i will finish the recommendation for AHPA sooner

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Analytics represents the configuration of an analytics.
type Analytics struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be singlary format?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

analytics is uncountable noun

Copy link
Contributor

Choose a reason for hiding this comment

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

but kubernetes api need singular and plural format, then it is Analytics and Analytics, I am not sure if crdgen can handle such case, it might become Analytics and Analyticss

Copy link
Member

Choose a reason for hiding this comment

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

I have the same question here.


// +genclient
// +genclient:nonNamespaced
// +kubebuilder:resource:scope=Cluster
Copy link
Contributor

Choose a reason for hiding this comment

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

if we define this object scope as Cluster, it means generally only admin can scan the app, but should we also consider app owner?
maybe:
set this object as namespaced, and if use create the object in crane-root, then it applies everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

the same comment to analytics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is SRE or admin's job to perform any resource optimization action,s and app owner should only care the APM rather than the underlying resource consumption.

}

// AnalyticsSpec describes the analytics type and what the analysis is for.
type AnalyticsSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the relation of analytics and recommendation?
users define analytics and analytics controller creates recommendation?

Copy link
Contributor

Choose a reason for hiding this comment

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

I addition, is recommendation and analytic is very generic words, should we consider if the reflected the real intension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Analytics "generates" and "updates" Recommendations, which is similar to the relationship between CronJob and Job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about ResourceRecommendation & ResourceAnalytics?


go run ${KUBE_OPENAPI_PKG}/cmd/openapi-gen/openapi-gen.go --logtostderr \
Copy link
Member

Choose a reason for hiding this comment

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

openapi-gen and zz_generated.openapi is used now in metric-adapter, please keep it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

package v1alpha1

import (
"github.com/gocrane/api/recommendation"
Copy link
Member

Choose a reason for hiding this comment

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

please reformat this imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


// Recommendation represents the configuration of a single recommendation.
type Recommendation struct {
metav1.TypeMeta `json:",inline"`
Copy link
Member

Choose a reason for hiding this comment

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

It is nicer to add blank lines here for spec and status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


type AdvancedHorizontalPodAutoscalerRecommendation struct {
// optional
MinReplicas *int32
Copy link
Member

Choose a reason for hiding this comment

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

yeah, i will finish the recommendation for AHPA sooner

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Analytics represents the configuration of an analytics.
type Analytics struct {
Copy link
Member

Choose a reason for hiding this comment

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

I have the same question here.

// Recommendations is a list of pointers to recommendations that are updated by this analytics.
// +optional
// +listType=atomic
Recommendations []corev1.ObjectReference `json:"active,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Analystics n <-> n Recommendation
Seems no need to add owner reference between them

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 just select them from label selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


type AnalyticsType string

const (
Copy link
Member

Choose a reason for hiding this comment

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

how about combine AnalyticsType and RecommendationType

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

yuyufei added 3 commits November 25, 2021 18:08
…e.io"

2. Make Recommendation and Analytics namespace scoped.
3. Generate crd schemas for analysis.

const (
AnalyticsTypeAdvancedHPA AnalyticsType = "HPA"
AnalyticsTypeResource AnalyticsType = "Resource"
Copy link
Member

Choose a reason for hiding this comment

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

s/Type/AnalysisType/g

@qmhu
Copy link
Member

qmhu commented Nov 26, 2021

/LGTM

@yufeiyu yufeiyu merged commit 2c00506 into gocrane:main Nov 26, 2021
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.

None yet

3 participants