kubeapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package kubeapi implements function and type to operate kubernetes common resource.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcAndRoundMetricsRatio

func CalcAndRoundMetricsRatio(usage, limit int64) float64

CalcAndRoundMetricsRatio calculate ratio by resource usage and limit.

func FetchContainerMetricsMean

func FetchContainerMetricsMean(
	ctx context.Context,
	wg *sync.WaitGroup,
	cl metricsClientset.Interface,
	resultCh chan MetricsField,
	receiveGatlingFinishedCh chan bool,
	podConfig cfg.TargetPodConfig,
)

FetchContainerMetricsMean returns container resources value mean.

Fetch metrics value every 5 seconds until informerCh get value or context done. Cpu and Memory value is rounded and cast from *inf.Dec to int64. If error occured this error only log error and continue to run. (not returns error object)

func InitClient

func InitClient(k8sCtxName string) (ctrlClient.Client, error)

InitClient returns client of kubeapi.

use for operate gatling object.

func InitMetricsClient

func InitMetricsClient(k8sCtxName string) (*metricsClientset.Clientset, error)

InitMetricsClient returns clientset of metrics.

Types

type MetricsField

type MetricsField struct {
	Cpu    int64 // milli vCPU
	Memory int64 // bytes
}

MetricsField hold container metrics value.

func FetchContainerResourcesLimit

func FetchContainerResourcesLimit(
	ctx context.Context,
	cl ctrlClient.Client,
	podConfig cfg.TargetPodConfig,
) (*MetricsField, error)

FetchContainerResourcesLimit fetch specified container and get resources limits or requests field value.

Jump to

Keyboard shortcuts

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