-
Notifications
You must be signed in to change notification settings - Fork 40k
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
auto-scaler types #5492
auto-scaler types #5492
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1443,3 +1443,91 @@ func AddToNodeAddresses(addresses *[]NodeAddress, addAddresses ...NodeAddress) { | |
} | ||
} | ||
} | ||
|
||
// AutoScaler monitors other resources that are resizeable and adjusts them according to configuration. | ||
type AutoScaler struct { | ||
TypeMeta `json:",inline"` | ||
ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// Spec defines the auto-scaler targets and thresholds. | ||
Spec AutoScalerSpec `json:"spec,omitempty"` | ||
|
||
// Status defines the actions the auto-scaler has taken. | ||
Status AutoScalerStatus `json:"status,omitempty"` | ||
} | ||
|
||
// AutoScalerStatus provides the status of an auto-scaler. | ||
type AutoScalerStatus struct { | ||
// TODO: open for discussion on what meaningful information can be reported in the status | ||
// The status may return the replica count here but we may want more information | ||
// such as if the count reflects a threshold being passed. | ||
} | ||
|
||
// AutoScalerSpec defines the auto-scaler targets and thresholds. | ||
type AutoScalerSpec struct { | ||
// Thresholds holds a collection of AutoScaleThresholds that drive the auto-scaler. | ||
Thresholds []AutoScaleThreshold `json:"thresholds,omitempty"` | ||
|
||
// MaxAutoScaleCount defines the max replicas that the auto-scaler can use. This value must be | ||
// >= MinAutoScaleCount. | ||
MaxAutoScaleCount int64 `json:"maxAutoScaleCount,omitempty"` | ||
|
||
// MinAutoScaleCount defines the minimum number replicas that the auto-scaler can reduce to, | ||
// 0 means that the application is allowed to idle. | ||
MinAutoScaleCount int64 `json:"minAutoScaleCount,omitempty"` | ||
|
||
// TargetSelector provides the resizeable target(s). Right now this is a ReplicationController | ||
// in the future it could be a job or any resource that implements resize. If multiple targets | ||
// are resolved by the selector the auto-scaler will resize the largest one. | ||
TargetSelector map[string]string `json:"targetSelector,omitempty"` | ||
|
||
// MonitorSelector defines a set of resources that the auto-scaler is monitoring | ||
// (replication controllers). Monitored objects are used by thresholds to examine | ||
// statistics. Example: get statistic X for object Y (the monitored object) to see if threshold is passed. | ||
MonitorSelector map[string]string `json:"monitorSelector,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either the comment is unclear or I'm dumb, but I don't know how monitor selector is used. The example doesn't relate to things I use selectors on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The monitor selector provides the set of objects that they auto-scaler is responsible for monitoring. The thresholds may use these objects to retrieve statistics from the store. In the example object Y is an object returned by the monitor selector. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put that in the comment :)
|
||
} | ||
|
||
// AutoScaleThreshold is a behavior based on statistics used to drive the auto-scaler in scaling decisions. | ||
type AutoScaleThreshold struct { | ||
// Type is the type of threshold being used, intention or value. | ||
Type AutoScaleThresholdType `json:"type,omitempty"` | ||
|
||
// IntentionConfig holds the config for intention based thresholds. | ||
IntentionConfig AutoScaleIntentionThresholdConfig `json:"intentionConfig,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember discussing this in the other thread but these seem more like resources (thresholds). Also, just looking at the names I have no idea what these things do - I would look to focus on recognizable concepts in these names. Threshold is fine - the action is not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intention based thresholds started with item 5 in this comment #2863 (comment) and were confirmed in this one #2863 (comment) I can add the value based thresholds in the implementation, it just sounded as if intent based was the way folks were leaning. |
||
} | ||
|
||
// AutoScaleIntentionThresholdConfig holds configuration for intention based thresholds. | ||
// The scaler will adjust by 1 accordingly and maintain once the intention is reached. | ||
type AutoScaleIntentionThresholdConfig struct { | ||
// Intent is the lexicon of what intention is requested. | ||
Intent AutoScaleIntentionType `json:"intent,omitempty"` | ||
|
||
// Value is intention dependent in terms of above, below, equal and represents | ||
// the value to check against. | ||
Value float32 `json:"value,omitempty"` | ||
} | ||
|
||
// AutoScaleThresholdType is either intention based or value based. | ||
type AutoScaleThresholdType string | ||
|
||
// AutoScaleIntentionType is a lexicon for intentions such as "cpu-utilization", | ||
// "max-rps-per-endpoint". | ||
type AutoScaleIntentionType string | ||
|
||
// Constants for auto-scalers and any auto-scaling child types like intentions | ||
const ( | ||
// AutoScaleThresholdTypeIntention is used when defining an intention based threshold. | ||
AutoScaleThresholdTypeIntention AutoScaleThresholdType = "Intention" | ||
|
||
// TODO: AutoScaleIntentionType types | ||
// example: AutoScaleIntentionTypeMaxRPS AutoScaleIntentionType = "MaxRPS" | ||
) | ||
|
||
// AutoScalerList is a list of AutoScaler items | ||
type AutoScalerList struct { | ||
TypeMeta `json:",inline"` | ||
ListMeta `json:"metadata,omitempty"` | ||
|
||
// Items is a list of AutoScaler objects. | ||
Items []AutoScaler `json:"items"` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1181,3 +1181,90 @@ type SecretList struct { | |
|
||
Items []Secret `json:"items" description:"items is a list of secret objects"` | ||
} | ||
|
||
// AutoScaler monitors other resources that are resizeable and adjusts them according to configuration. | ||
type AutoScaler struct { | ||
TypeMeta `json:",inline"` | ||
Labels map[string]string `json:"labels,omitempty"` | ||
|
||
// Spec defines the auto-scaler targets and thresholds. | ||
Spec AutoScalerSpec `json:"spec,omitempty"` | ||
|
||
// Status defines the actions the auto-scaler has taken. | ||
Status AutoScalerStatus `json:"status,omitempty"` | ||
} | ||
|
||
// AutoScalerStatus provides the status of an auto-scaler. | ||
type AutoScalerStatus struct { | ||
// TODO: open for discussion on what meaningful information can be reported in the status | ||
// The status may return the replica count here but we may want more information | ||
// such as if the count reflects a threshold being passed. | ||
} | ||
|
||
// AutoScalerSpec defines the auto-scaler targets and thresholds. | ||
type AutoScalerSpec struct { | ||
// Thresholds holds a collection of AutoScaleThresholds that drive the auto-scaler. | ||
Thresholds []AutoScaleThreshold `json:"thresholds,omitempty"` | ||
|
||
// MaxAutoScaleCount defines the max replicas that the auto-scaler can use. This value must be | ||
// >= MinAutoScaleCount. | ||
MaxAutoScaleCount int64 `json:"maxAutoScaleCount,omitempty"` | ||
|
||
// MinAutoScaleCount defines the minimum number replicas that the auto-scaler can reduce to, | ||
// 0 means that the application is allowed to idle. | ||
MinAutoScaleCount int64 `json:"minAutoScaleCount,omitempty"` | ||
|
||
// TargetSelector provides the resizeable target(s). Right now this is a ReplicationController | ||
// in the future it could be a job or any resource that implements resize. If multiple targets | ||
// are resolved by the selector the auto-scaler will resize the largest one. | ||
TargetSelector map[string]string `json:"targetSelector,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Selector api has changed, update this to be consistent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear, are you asking me to change this into a labels.Set? It looks like everything is still using maps of strings in the type definitions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sync with Dario
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @smarterclayton
Breaking up the label types into two packages, one with Captain, permission to abort for this PR or shall I carry on? Just to rule out any PEBKAC, this is how I chose to refactor to try and minimize how many files were touched. I left everything that existed in the labels package mostly untouched. I then broke out the types in labels.go and selector.go into their own package and added some utility methods to labels.go to easily make a Labels struct without importing the types directly. That still left me with at least 75 files to touch. https://github.com/pweil-/kubernetes/tree/labels-as-apitype/pkg/labels There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (a compare on that link will show the unfinished refactoring that I was doing this afternoon) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check with Dario
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #341 and https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/labels/selector.go#L156. We're working towards supporting generalized label selectors in the API, but it doesn't exist yet. In any case, labels.Set isn't the right representation -- that a label set, not a selector. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @bgrant0607, understood. @smarterclayton - I'll check with @sdminonne on the timing for this (#341 (comment) item 1) and put a TODO here since it is not quite ready. If he has a quick(er) strategy in mind for implementation that I can help out with I'll submit a PR for it and rebase to use it. Based on that, this PR is read for the round 2 of reviews from the initial feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've fixed the error circular reference in #5771 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 🏆 |
||
|
||
// MonitorSelector defines a set of resources that the auto-scaler is monitoring | ||
// (replication controllers). Monitored objects are used by thresholds to examine | ||
// statistics. Example: get statistic X for object Y (the monitored object) to see if threshold is passed. | ||
MonitorSelector map[string]string `json:"monitorSelector,omitempty"` | ||
} | ||
|
||
// AutoScaleThreshold is a behavior based on statistics used to drive the auto-scaler in scaling decisions. | ||
type AutoScaleThreshold struct { | ||
// Type is the type of threshold being used, intention or value. | ||
Type AutoScaleThresholdType `json:"type,omitempty"` | ||
|
||
// IntentionConfig holds the config for intention based thresholds. | ||
IntentionConfig AutoScaleIntentionThresholdConfig `json:"intentionConfig,omitempty"` | ||
} | ||
|
||
// AutoScaleIntentionThresholdConfig holds configuration for intention based thresholds. | ||
// The scaler will adjust by 1 accordingly and maintain once the intention is reached. | ||
type AutoScaleIntentionThresholdConfig struct { | ||
// Intent is the lexicon of what intention is requested. | ||
Intent AutoScaleIntentionType `json:"intent,omitempty"` | ||
|
||
// Value is intention dependent in terms of above, below, equal and represents | ||
// the value to check against. | ||
Value float32 `json:"value,omitempty"` | ||
} | ||
|
||
// AutoScaleThresholdType is either intention based or value based. | ||
type AutoScaleThresholdType string | ||
|
||
// AutoScaleIntentionType is a lexicon for intentions such as "cpu-utilization", | ||
// "max-rps-per-endpoint". | ||
type AutoScaleIntentionType string | ||
|
||
// Constants for auto-scalers and any auto-scaling child types like intentions | ||
const ( | ||
// AutoScaleThresholdTypeIntention is used when defining an intention based threshold. | ||
AutoScaleThresholdTypeIntention AutoScaleThresholdType = "Intention" | ||
|
||
// TODO: AutoScaleIntentionType types | ||
// example: AutoScaleIntentionTypeMaxRPS AutoScaleIntentionType = "MaxRPS" | ||
) | ||
|
||
// AutoScalerList is a list of AutoScaler items | ||
type AutoScalerList struct { | ||
TypeMeta `json:",inline"` | ||
|
||
// Items is a list of AutoScaler objects. | ||
Items []AutoScaler `json:"items"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make these int64