github.com/gocrane/crane@v0.11.0/docs/proposals/20220706-recommendation-definition.md (about)

     1  # Recommendation Definition
     2  - This proposal aims at definition for universal resource optimization. 
     3  
     4  ## Table of Contents
     5  
     6  <!-- TOC -->
     7  
     8  
     9  <!-- /TOC -->
    10  
    11  ## Motivation
    12  
    13  
    14  
    15  ## Proposal
    16  
    17  ### Api Definition
    18  
    19  RecommendationRule defines which resources are required to recommend and what is the runInterval.
    20  
    21  ```go
    22  // RecommendationRuleSpec defines resources and runInterval to recommend
    23  type RecommendationRuleSpec struct {
    24  	// ResourceSelector indicates how to select resources(e.g. a set of Deployments) for an Recommendation.
    25  	// +required
    26  	// +kubebuilder:validation:Required
    27  	ResourceSelectors []ResourceSelector `json:"resourceSelectors"`
    28  
    29  	// RunInterval between two recommendation
    30  	RunInterval time.Duration `json:"runInterval,omitempty"`
    31  }
    32  
    33  // ResourceSelector describes how the resources will be selected.
    34  type ResourceSelector struct {
    35  	// Kind of the resource, e.g. Deployment
    36  	Kind string `json:"kind"`
    37  
    38  	// API version of the resource, e.g. "apps/v1"
    39  	// +optional
    40  	APIVersion string `json:"apiVersion,omitempty"`
    41  
    42  	// Name of the resource.
    43  	// +optional
    44  	Name string `json:"name,omitempty"`
    45  
    46  	// +optional
    47  	LabelSelector metav1.LabelSelector `json:"labelSelector,omitempty"`
    48  }
    49  
    50  namespace ?
    51  ```
    52  
    53  Recommendation is a content holder for recommendation result. We hope that the recommendation data can be applied directly to kubernetes cluster(Recommendation as a code) and Different type recommendation have different recommendation yaml, so the content is stored in recommendation as `Data`.
    54  
    55  ```go
    56  type Recommendation struct {
    57  	metav1.TypeMeta   `json:",inline"`
    58  	metav1.ObjectMeta `json:"metadata,omitempty"`
    59  
    60  	// +kubebuilder:pruning:PreserveUnknownFields
    61  	Data runtime.RawExtension `json:"data"`
    62  }
    63  ```
    64  
    65  ### Recommendation Configuration
    66  
    67  Recommendation Configuration is centralized configuration that contains every rule for universal resource optimization. It not only includes RecommendationRules that use defines but also contains RecommendationPlugins.
    68  
    69  
    70  
    71