k8s

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONTAINER_CPU_METRICS = "container_cpu_user_seconds_total"
	CONTAINER_MEM_METRICS = "container_memory_usage_bytes"
)
View Source
const (
	METRIC_POD_LABEL        = "pod"
	METRIC_CONTAINER_LABEL  = "container"
	METRIC_NAME_LABEL       = "name"
	METRICS_NAMESPACE_LABEL = "namespace"
	METRICS_ID_LABEL        = "id"
	METRICS_IMAGE_LABEL     = "image"
	SORT_BY_CPU             = 0
	SORT_BY_MEM             = 1
	SORT_BY_POD             = 2
	SORT_BY_NAMESPACE       = 3
)
View Source
const (
	CADVISOR_PATH_TEMPLATE = "/api/v1/nodes/%s/proxy/metrics/cadvisor"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	Id        string
	Name      string
	Image     string
	PodName   string
	Namespace string
	// contains filtered or unexported fields
}

func (*Container) GetStats

func (c *Container) GetStats() *Stats

func (*Container) UpdateCpu

func (c *Container) UpdateCpu(cpu *Cpu, fetchTime time.Time)

func (*Container) UpdateMemory

func (c *Container) UpdateMemory(memory *Memory, fetchTime time.Time)

func (*Container) UpdateResources

func (c *Container) UpdateResources(resources *ContainerResources)

type ContainerResources

type ContainerResources struct {
	PodName   string
	Name      string
	Namespace string
	Image     string
	Request   Resources
	Limit     Resources
}

type Cpu

type Cpu struct {
	Name                 string
	Image                string
	PodName              string
	Namespace            string
	CpuUsageSecondsTotal float64
}

type Fetcher

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

func NewFetcher

func NewFetcher(clientset *kubernetes.Clientset) *Fetcher

func (*Fetcher) GetContainers

func (f *Fetcher) GetContainers() ([]*ContainerResources, error)

func (*Fetcher) GetMetrics

func (f *Fetcher) GetMetrics() ([]*NodeMetrics, error)

type Memory

type Memory struct {
	Name             string
	Image            string
	PodName          string
	Namespace        string
	MemoryUsageBytes float64
}

type NodeMetrics

type NodeMetrics struct {
	NodeName  string
	Cpu       []*Cpu
	Memory    []*Memory
	Timestamp time.Time
}

type Parser

type Parser struct {
}

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(b []byte) ([]*Cpu, []*Memory, error)

type Resources

type Resources struct {
	Cpu    float64
	Memory float64
}

type Stats

type Stats struct {
	Namespace          string
	PodName            string
	ContainerName      string
	CpuUsageMilli      float64
	MemoryBytes        float64
	LastUpdateTs       time.Time
	MemoryLimitBytes   float64
	CpuLimit           float64
	MemoryUsagePercent float64
	CpuUsagePercent    float64
}

Jump to

Keyboard shortcuts

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