kube

package
v0.0.0-...-ce9e087 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportCSV

func ExportCSV(prefix string, rows [][]string) string

func FormatContainerMetrics

func FormatContainerMetrics(containerMetrics []*ContainerMetrics, metric_type v1.ResourceName, duration time.Duration, field string, reverse bool) (rows [][]string, total int64)

func FormatResourceUsage

func FormatResourceUsage(capacity v1.ResourceList, resources []*ContainerResources, field string, reverse bool) (rows [][]string)

func GetField

func GetField(r interface{}, field string) interface{}

func GetFields

func GetFields(r interface{}) []string

func MinMax_float64

func MinMax_float64(array []float64) (float64, float64)

func MinMax_int64

func MinMax_int64(array []int64) (int64, int64)

func NodeCapacity

func NodeCapacity(node *api_v1.Node) api_v1.ResourceList

func PrintContainerMetrics

func PrintContainerMetrics(rows [][]string, duration time.Duration, total int64)

func PrintResourceUsage

func PrintResourceUsage(rows [][]string)

Types

type ContainerMetrics

type ContainerMetrics struct {
	ContainerName string
	PodName       string
	NodeName      string

	MetricType v1.ResourceName
	MemoryMin  *MemoryResource
	MemoryMax  *MemoryResource
	MemoryMode *MemoryResource
	MemoryLast *MemoryResource

	CpuMin  *CpuResource
	CpuMax  *CpuResource
	CpuAvg  *CpuResource
	CpuLast *CpuResource

	DataPoints int64
}

func (ContainerMetrics) Validate

func (m ContainerMetrics) Validate(field string) bool

type ContainerResources

type ContainerResources struct {
	Name               string
	Namespace          string
	CpuReq             *CpuResource
	CpuLimit           *CpuResource
	PercentCpuReq      int64
	PercentCpuLimit    int64
	MemReq             *MemoryResource
	MemLimit           *MemoryResource
	PercentMemoryReq   int64
	PercentMemoryLimit int64
}

func (ContainerResources) Validate

func (r ContainerResources) Validate(field string) bool

type CpuResource

type CpuResource struct {
	*resource.Quantity
}

func NewCpuResource

func NewCpuResource(value int64) *CpuResource

func (*CpuResource) String

func (r *CpuResource) String() string

func (*CpuResource) ToQuantity

func (r *CpuResource) ToQuantity() *resource.Quantity

type KubeClient

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

func NewKubeClient

func NewKubeClient(
	clientset *kubernetes.Clientset,
) *KubeClient

func (*KubeClient) ActivePods

func (k *KubeClient) ActivePods(namespace, nodeName string) ([]api_v1.Pod, error)

func (*KubeClient) ClusterCapacity

func (k *KubeClient) ClusterCapacity() (capacity api_v1.ResourceList, err error)

func (*KubeClient) ContainerResources

func (k *KubeClient) ContainerResources(namespace string) (resources []*ContainerResources, err error)

func (*KubeClient) Historical

func (k *KubeClient) Historical(project, namespace string, workers int, resourceName v1.ResourceName, duration time.Duration, sort string, reverse bool, csv bool)

func (*KubeClient) NodeResources

func (k *KubeClient) NodeResources(namespace, nodeName string) (resources []*ContainerResources, err error)

func (*KubeClient) ResourceUsage

func (k *KubeClient) ResourceUsage(namespace, sort string, reverse bool, csv bool)

type MemoryResource

type MemoryResource struct {
	*resource.Quantity
}

func NewMemoryResource

func NewMemoryResource(value int64) *MemoryResource

func (*MemoryResource) String

func (r *MemoryResource) String() string

func (*MemoryResource) ToQuantity

func (r *MemoryResource) ToQuantity() *resource.Quantity

type MetricJob

type MetricJob struct {
	ContainerName string
	PodName       string
	PodUID        string
	Duration      time.Duration
	MetricType    v1.ResourceName
	// contains filtered or unexported fields
}

type StackDriverClient

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

func NewStackDriverClient

func NewStackDriverClient(project string) *StackDriverClient

func (*StackDriverClient) ContainerMetrics

func (s *StackDriverClient) ContainerMetrics(container_name string, pod_uid string, duration time.Duration, metric_type v1.ResourceName) *ContainerMetrics

func (*StackDriverClient) ListTimeSeries

func (s *StackDriverClient) ListTimeSeries(filter_map map[string]string, duration time.Duration) *monitoring.TimeSeriesIterator

func (*StackDriverClient) Run

func (s *StackDriverClient) Run(jobs chan<- *MetricJob, collector <-chan *ContainerMetrics, pods []v1.Pod, duration time.Duration, metric_type v1.ResourceName) (metrics []*ContainerMetrics)

func (*StackDriverClient) Worker

func (s *StackDriverClient) Worker(jobs <-chan *MetricJob, collector chan<- *ContainerMetrics)

Jump to

Keyboard shortcuts

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