Documentation ¶
Overview ¶
Package chpa and this controller were mostly inspired by
k8s-1.10.8/pkg/controller/podautoscaler/horizontal.go
Index ¶
- func Add(mgr manager.Manager) error
- type ReconcileCHPA
- type ReplicaCalculator
- func (c *ReplicaCalculator) GetExternalMetricReplicas(currentReplicas int32, targetUtilization int64, metricName, namespace string, ...) (replicaCount int32, utilization int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetExternalPerPodMetricReplicas(currentReplicas int32, targetUtilizationPerPod int64, ...) (replicaCount int32, utilization int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, ...) (replicaCount int32, utilization int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetObjectMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, ...) (replicaCount int32, utilization int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetRawResourceReplicas(currentReplicas int32, targetUtilization int64, resource v1.ResourceName, ...) (replicaCount int32, utilization int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetResourceReplicas(currentReplicas int32, targetUtilization int32, resource v1.ResourceName, ...) (replicaCount int32, utilization int32, rawUtilization int64, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ReconcileCHPA ¶
ReconcileCHPA reconciles a CHPA object
func (*ReconcileCHPA) Reconcile ¶
Automatically generate RBAC rules to allow the Controller to read and write Deployments TODO: decide, what to use: patch or update in rbac +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;update;patch +kubebuilder:rbac:groups=,resources=pods,verbs=get;list +kubebuilder:rbac:groups=autoscalers.postmates.com,resources=chpas,verbs=get;list;watch;create;update;patch;delete
type ReplicaCalculator ¶
type ReplicaCalculator struct {
// contains filtered or unexported fields
}
ReplicaCalculator is responsible for calculation of the number of replicas It contains all the needed information
func NewReplicaCalculator ¶
func NewReplicaCalculator(metricsClient metricsclient.MetricsClient, podsGetter v1coreclient.PodsGetter, tolerance float64) *ReplicaCalculator
NewReplicaCalculator returns a ReplicaCalculator object reference
func (*ReplicaCalculator) GetExternalMetricReplicas ¶
func (c *ReplicaCalculator) GetExternalMetricReplicas(currentReplicas int32, targetUtilization int64, metricName, namespace string, selector *metav1.LabelSelector) (replicaCount int32, utilization int64, timestamp time.Time, err error)
GetExternalMetricReplicas calculates the desired replica count based on a target metric value (as a milli-value) for the external metric in the given namespace, and the current replica count.
func (*ReplicaCalculator) GetExternalPerPodMetricReplicas ¶
func (c *ReplicaCalculator) GetExternalPerPodMetricReplicas(currentReplicas int32, targetUtilizationPerPod int64, metricName, namespace string, selector *metav1.LabelSelector) (replicaCount int32, utilization int64, timestamp time.Time, err error)
GetExternalPerPodMetricReplicas calculates the desired replica count based on a target metric value per pod (as a milli-value) for the external metric in the given namespace, and the current replica count.
func (*ReplicaCalculator) GetMetricReplicas ¶
func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, namespace string, selector labels.Selector) (replicaCount int32, utilization int64, timestamp time.Time, err error)
GetMetricReplicas calculates the desired replica count based on a target metric utilization (as a milli-value) for pods matching the given selector in the given namespace, and the current replica count
func (*ReplicaCalculator) GetObjectMetricReplicas ¶
func (c *ReplicaCalculator) GetObjectMetricReplicas(currentReplicas int32, targetUtilization int64, metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference) (replicaCount int32, utilization int64, timestamp time.Time, err error)
GetObjectMetricReplicas calculates the desired replica count based on a target metric utilization (as a milli-value) for the given object in the given namespace, and the current replica count.
func (*ReplicaCalculator) GetRawResourceReplicas ¶
func (c *ReplicaCalculator) GetRawResourceReplicas(currentReplicas int32, targetUtilization int64, resource v1.ResourceName, namespace string, selector labels.Selector) (replicaCount int32, utilization int64, timestamp time.Time, err error)
GetRawResourceReplicas calculates the desired replica count based on a target resource utilization (as a raw milli-value) for pods matching the given selector in the given namespace, and the current replica count
func (*ReplicaCalculator) GetResourceReplicas ¶
func (c *ReplicaCalculator) GetResourceReplicas(currentReplicas int32, targetUtilization int32, resource v1.ResourceName, namespace string, selector labels.Selector) (replicaCount int32, utilization int32, rawUtilization int64, timestamp time.Time, err error)
GetResourceReplicas calculates the desired replica count based on a target resource utilization percentage of the given resource for pods matching the given selector in the given namespace, and the current replica count