datadoghq

package
v0.9.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Overview

Package datadoghq containers all the WatermarkPodAutoscaler controller logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogAttrsFromWpa

func GetLogAttrsFromWpa(wpa *datadoghqv1alpha1.WatermarkPodAutoscaler) ([]interface{}, error)

GetLogAttrsFromWpa returns a slice of all key/value pairs specified in the WPA log attributes annotation json.

Types

type Options

type Options struct {
	SkipNotScalingEvents bool
}

type RecommenderClient

type RecommenderClient interface {
	GetReplicaRecommendation(request *ReplicaRecommendationRequest) (*ReplicaRecommendationResponse, error)
}

func NewRecommenderClient

func NewRecommenderClient(client *http.Client) RecommenderClient

NewRecommenderClient returns a new RecommenderClient with the given http.Client.

type RecommenderClientImpl

type RecommenderClientImpl struct {
	// contains filtered or unexported fields
}

func (*RecommenderClientImpl) GetReplicaRecommendation

GetReplicaRecommendation returns a recommendation for the number of replicas to scale to based on the given ReplicaRecommendationRequest.

Currently, it supports http based recommendation service, but we need to implement grpc services too.

type ReplicaCalculation

type ReplicaCalculation struct {
	// contains filtered or unexported fields
}

ReplicaCalculation is used to compute the scaling recommendation.

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, recommenderClient RecommenderClient, podLister corelisters.PodLister, k8sClusterName string) *ReplicaCalculator

NewReplicaCalculator returns a ReplicaCalculator object reference

func (*ReplicaCalculator) GetExternalMetricReplicas

func (c *ReplicaCalculator) GetExternalMetricReplicas(logger logr.Logger, target *autoscalingv1.Scale, metric v1alpha1.MetricSpec, wpa *v1alpha1.WatermarkPodAutoscaler) (ReplicaCalculation, 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) GetRecommenderReplicas

func (c *ReplicaCalculator) GetRecommenderReplicas(logger logr.Logger, target *autoscalingv1.Scale, wpa *v1alpha1.WatermarkPodAutoscaler) (ReplicaCalculation, error)

GetRecommenderReplicas contacts an external replica recommender to get the desired replica count

func (*ReplicaCalculator) GetResourceReplicas

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

type ReplicaCalculatorItf

type ReplicaCalculatorItf interface {
	GetExternalMetricReplicas(logger logr.Logger, target *autoscalingv1.Scale, metric v1alpha1.MetricSpec, wpa *v1alpha1.WatermarkPodAutoscaler) (replicaCalculation ReplicaCalculation, err error)
	GetResourceReplicas(logger logr.Logger, target *autoscalingv1.Scale, metric v1alpha1.MetricSpec, wpa *v1alpha1.WatermarkPodAutoscaler) (replicaCalculation ReplicaCalculation, err error)
	GetRecommenderReplicas(logger logr.Logger, target *autoscalingv1.Scale, wpa *v1alpha1.WatermarkPodAutoscaler) (replicaCalculation ReplicaCalculation, err error)
}

ReplicaCalculatorItf interface for ReplicaCalculator

type ReplicaRecommendationRequest

type ReplicaRecommendationRequest struct {
	Namespace            string
	TargetRef            *v1alpha1.CrossVersionObjectReference
	TargetCluster        string
	Recommender          *v1alpha1.RecommenderSpec
	DesiredReplicas      int32
	CurrentReplicas      int32
	CurrentReadyReplicas int32
	MinReplicas          int32
	MaxReplicas          int32
}

type ReplicaRecommendationResponse

type ReplicaRecommendationResponse struct {
	Replicas           int
	ReplicasLowerBound int
	ReplicasUpperBound int
	Timestamp          time.Time
	Details            string
}

type WatermarkPodAutoscalerReconciler

type WatermarkPodAutoscalerReconciler struct {
	// This client, initialized using mgr.Client() above, is a split client
	// that reads objects from the cache and writes to the apiserver
	Client client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme

	Options Options
	// contains filtered or unexported fields
}

WatermarkPodAutoscalerReconciler reconciles a WatermarkPodAutoscaler object

func (*WatermarkPodAutoscalerReconciler) Reconcile

Reconcile reads that state of the cluster for a WatermarkPodAutoscaler object and makes changes based on the state read and what is in the WatermarkPodAutoscaler.Spec The Controller will requeue the Request to be processed again if the returned error is non-nil or Result.Requeue is true, otherwise upon completion it will remove the work from the queue.

func (*WatermarkPodAutoscalerReconciler) SetupWithManager

func (r *WatermarkPodAutoscalerReconciler) SetupWithManager(mgr ctrl.Manager, workers int) error

SetupWithManager creates a new Watermarkpodautoscaler controller

Directories

Path Synopsis
test
utils
Package utils provides a set of test utils functions.
Package utils provides a set of test utils functions.

Jump to

Keyboard shortcuts

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