kube

package
v0.0.0-...-3d28120 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 25 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(metricsclient *versioned.Clientset, nodes *v1.NodeList, capacity v1.ResourceList, resources []*ContainerResources, field string, reverse bool, nodesOnly bool) (rows [][]string)

func GetConfig

func GetConfig() *rest.Config

func GetField

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

func GetFields

func GetFields(r interface{}) []string

func GetNodesByUsage

func GetNodesByUsage(nodes *v1.NodeList, metricsclient *versioned.Clientset) map[string]NodeStatus

TODO check sort NOT WORKING FOR Memory

func GetNodesListAndMetrics

func GetNodesListAndMetrics(config *rest.Config) (*v1.NodeList, *versioned.Clientset)

func GetPodsByNode

func GetPodsByNode(d clientset.Clientset, name string, namespace string) (*v1.PodList, error)

func GetPodsTotalMemRequestsAndLimits

func GetPodsTotalMemRequestsAndLimits(podList []corev1.Pod) (int64, int64)

func GetWorkerNode

func GetWorkerNode(nodes map[string]NodeStatus) (string, error)

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 *corev1.Node) corev1.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 {
	NodeName           string
	Name               string
	Namespace          string
	CpuReq             *CpuResource
	CpuLimit           *CpuResource
	PercentCpuReq      int64
	PercentCpuLimit    int64
	MemReq             *MemoryResource
	MemLimit           *MemoryResource
	PercentMemoryReq   int64
	PercentMemoryLimit int64
	PodAge             time.Duration
}

func GetPodsByUsage

func GetPodsByUsage(nodeName string, resources []*ContainerResources) []*ContainerResources

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 {
	Clientset *kubernetes.Clientset
}

func GetClient

func GetClient(config *rest.Config) *KubeClient

func NewKubeClient

func NewKubeClient(clientset *kubernetes.Clientset) *KubeClient

func (*KubeClient) ActivePods

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

func (*KubeClient) ClusterCapacity

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

func (*KubeClient) ContainerResources

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

func (*KubeClient) NodeList

func (c *KubeClient) NodeList() (*corev1.NodeList, error)

func (*KubeClient) NodeResources

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

func (*KubeClient) ResourceUsage

func (k *KubeClient) ResourceUsage(metricsclient *versioned.Clientset, namespace, sort string, reverse bool, csv bool, nodesOnly 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 NodeStatus

type NodeStatus struct {
	MemAlloc int64
	// contains filtered or unexported fields
}

mem usage in Gi

func FilterNodesByUsage

func FilterNodesByUsage(nodes map[string]NodeStatus, memThreshold int64) []NodeStatus

Jump to

Keyboard shortcuts

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