Documentation ¶
Index ¶
- Constants
- type Autoscaler
- type Decider
- type DeciderSpec
- type DeciderStatus
- type MultiScaler
- func (m *MultiScaler) Create(ctx context.Context, decider *Decider) (*Decider, error)
- func (m *MultiScaler) Delete(ctx context.Context, namespace, name string) error
- func (m *MultiScaler) Get(ctx context.Context, namespace, name string) (*Decider, error)
- func (m *MultiScaler) Inform(event types.NamespacedName) bool
- func (m *MultiScaler) Poke(key types.NamespacedName, stat metrics.Stat)
- func (m *MultiScaler) Update(ctx context.Context, decider *Decider) (*Decider, error)
- func (m *MultiScaler) Watch(fn func(types.NamespacedName))
- type ScaleResult
- type UniScaler
- type UniScalerFactory
Constants ¶
const MinActivators = 2
MinActivators is the minimum number of activators a revision will get.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Autoscaler ¶
type Autoscaler struct {
// contains filtered or unexported fields
}
Autoscaler stores current state of an instance of an autoscaler.
func New ¶
func New( namespace string, revision string, metricClient metrics.MetricClient, lister corev1listers.EndpointsLister, deciderSpec *DeciderSpec, reporterCtx context.Context) (*Autoscaler, error)
New creates a new instance of autoscaler
func (*Autoscaler) Scale ¶
func (a *Autoscaler) Scale(ctx context.Context, now time.Time) ScaleResult
Scale calculates the desired scale based on current statistics given the current time. desiredPodCount is the calculated pod count the autoscaler would like to set. validScale signifies whether the desiredPodCount should be applied or not. Scale is not thread safe in regards to panic state, but it's thread safe in regards to acquiring the decider spec.
func (*Autoscaler) Update ¶
func (a *Autoscaler) Update(deciderSpec *DeciderSpec) error
Update reconfigures the UniScaler according to the DeciderSpec.
type Decider ¶
type Decider struct { metav1.ObjectMeta Spec DeciderSpec Status DeciderStatus }
Decider is a resource which observes the request load of a Revision and recommends a number of replicas to run. +k8s:deepcopy-gen=true
func (*Decider) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Decider.
func (*Decider) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type DeciderSpec ¶
type DeciderSpec struct { // TickInterval denotes how often we evaluate the scale suggestion. TickInterval time.Duration MaxScaleUpRate float64 MaxScaleDownRate float64 // The metric used for scaling, i.e. concurrency, rps. ScalingMetric string // The value of scaling metric per pod that we target to maintain. // TargetValue <= TotalValue. TargetValue float64 // The total value of scaling metric that a pod can maintain. TotalValue float64 // The burst capacity that user wants to maintain without queuing at the POD level. // Note, that queueing still might happen due to the non-ideal load balancing. TargetBurstCapacity float64 // ActivatorCapacity is the single activator capacity, for subsetting. ActivatorCapacity float64 // PanicThreshold is the threshold at which panic mode is entered. It represents // a factor of the currently observed load over the panic window over the ready // pods. I.e. if this is 2, panic mode will be entered if the observed metric // is twice as high as the current population can handle. PanicThreshold float64 // StableWindow is needed to determine when to exit panic mode. StableWindow time.Duration // The name of the k8s service for pod information. ServiceName string }
DeciderSpec is the parameters in which the Revision should scaled.
type DeciderStatus ¶
type DeciderStatus struct { // DesiredScale is the target number of instances that autoscaler // this revision needs. DesiredScale int32 // ExcessBurstCapacity is the difference between spare capacity // (how much more load the pods in the revision deployment can take before being // overloaded) and the configured target burst capacity. // If this number is negative: Activator will be threaded in // the request path by the PodAutoscaler controller. ExcessBurstCapacity int32 // NumActivators is the computed number of activators // necessary to back the revision. NumActivators int32 }
DeciderStatus is the current scale recommendation.
type MultiScaler ¶
type MultiScaler struct {
// contains filtered or unexported fields
}
MultiScaler maintains a collection of Uniscalers.
func NewMultiScaler ¶
func NewMultiScaler( stopCh <-chan struct{}, uniScalerFactory UniScalerFactory, logger *zap.SugaredLogger) *MultiScaler
NewMultiScaler constructs a MultiScaler.
func (*MultiScaler) Delete ¶
func (m *MultiScaler) Delete(ctx context.Context, namespace, name string) error
Delete stops and removes a Decider.
func (*MultiScaler) Inform ¶
func (m *MultiScaler) Inform(event types.NamespacedName) bool
Inform sends an update to the registered watcher function, if it is set.
func (*MultiScaler) Poke ¶
func (m *MultiScaler) Poke(key types.NamespacedName, stat metrics.Stat)
Poke checks if the autoscaler needs to be run immediately.
func (*MultiScaler) Watch ¶
func (m *MultiScaler) Watch(fn func(types.NamespacedName))
Watch registers a singleton function to call when DeciderStatus is updated.
type ScaleResult ¶ added in v0.15.0
type ScaleResult struct { // DesiredPodCount is the number of pods Autoscaler suggests for the revision. DesiredPodCount int32 // ExcessBurstCapacity is computed headroom of the revision taking into // the account target burst capacity. ExcessBurstCapacity int32 // NumActivators is the number of activators required to back this revision. NumActivators int32 // ScaleValid specifies whether this scale result is valid, i.e. whether // Autoscaler had all the necessary information to compute a suggestion. ScaleValid bool }
ScaleResult holds the scale result of the UniScaler evaluation cycle.
type UniScaler ¶
type UniScaler interface { // Scale computes a scaling suggestion for a revision. Scale(context.Context, time.Time) ScaleResult // Update reconfigures the UniScaler according to the DeciderSpec. Update(*DeciderSpec) error }
UniScaler records statistics for a particular Decider and proposes the scale for the Decider's target based on those statistics.
type UniScalerFactory ¶
UniScalerFactory creates a UniScaler for a given PA using the given dynamic configuration.