chpa

package
v0.0.0-...-dc50737 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Overview

Package chpa and this controller were mostly inspired by

k8s-1.10.8/pkg/controller/podautoscaler/horizontal.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager) error

Add creates a new CHPA Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller and Start it when the Manager is Started.

Types

type ReconcileCHPA

type ReconcileCHPA struct {
	client.Client
	// contains filtered or unexported fields
}

ReconcileCHPA reconciles a CHPA object

func (*ReconcileCHPA) Reconcile

func (r *ReconcileCHPA) Reconcile(request reconcile.Request) (reconcile.Result, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL