kube

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExceedsCompare

func ExceedsCompare(a string) string

Compare

func FieldString

func FieldString(str string) float64

FieldString

func NodeCapacity

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

NodeCapacity

func PodRequestsAndLimits

func PodRequestsAndLimits(pod *v1.Pod) (reqs, limits v1.ResourceList, err error)

PodRequestsAndLimits returns a dictionary of all defined resources summed up for all containers of the pod. If pod overhead is non-nil, the pod overhead is added to the total container resource requests and to the total container limits which have a non-zero quantity.

Types

type CPUResources

type CPUResources struct {
	// CPUUsages is number of allocated milicores.
	CPUUsages *CpuResource

	// CPURequests is number of allocated milicores.
	CPURequests *CpuResource

	// CPURequestsFraction is a fraction of CPU, that is allocated.
	CPURequestsFraction float64 `json:"cpuRequestsFraction"`

	// CPULimits is defined CPU limit.
	CPULimits *CpuResource

	// CPULimitsFraction is a fraction of defined CPU limit, can be over 100%, i.e.
	// overcommitted.
	CPULimitsFraction float64 `json:"cpuLimitsFraction"`

	// CPUCapacity is specified node CPU capacity in milicores.
	CPUCapacity *CpuResource
}

CPUResources describes node allocated resources.

type CpuResource

type CpuResource struct {
	*resource.Quantity
}

func NewCpuResource

func NewCpuResource(value int64) *CpuResource

NewCpuResource

func (*CpuResource) String

func (r *CpuResource) String() string

String

func (*CpuResource) ToQuantity

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

ToQuantity

type KubeClient

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

KubeClient provides methods to get all required metrics from Kubernetes

func NewClient

func NewClient(config *rest.Config) (*KubeClient, error)

NewClient creates a new client to get data from kubernetes masters

func (*KubeClient) GetActivePodByNodename

func (k *KubeClient) GetActivePodByNodename(node corev1.Node) (*corev1.PodList, error)

GetActivePodByNodename

func (*KubeClient) GetNodeMetricsFromMetricsAPI

func (k *KubeClient) GetNodeMetricsFromMetricsAPI(resourceName string, selector labels.Selector) (*metricsapi.NodeMetricsList, error)

GetNodeMetricsFromMetricsAPI

func (*KubeClient) GetNodeResources

func (k *KubeClient) GetNodeResources(resourceName string, resourceType string, sortBy string, selector labels.Selector) ([][]string, error)

NodeResources

func (*KubeClient) GetNodes

func (k *KubeClient) GetNodes(resourceName string, selector labels.Selector) (map[string]corev1.Node, error)

GetNodes

func (*KubeClient) GetPodByPodname

func (k *KubeClient) GetPodByPodname(podName string, namespace string) (*corev1.Pod, error)

GetActivePodByPodname

func (*KubeClient) GetPodMetricsFromMetricsAPI

func (k *KubeClient) GetPodMetricsFromMetricsAPI(namespace, resourceName string, allNamespaces bool, labelSelector labels.Selector, fieldSelector fields.Selector) (*metricsapi.PodMetricsList, error)

GetPodMetricsFromMetricsAPI

func (*KubeClient) GetPodResources

func (k *KubeClient) GetPodResources(podmetrics []metricsapi.PodMetrics, namespace string, resourceName string, allNamespaces bool, resourceType string, sortBy string, labelSelector labels.Selector, fieldSelector fields.Selector) ([][]string, error)

func (*KubeClient) PodMetricses

func (k *KubeClient) PodMetricses() (*metricsV1beta1api.PodMetricsList, error)

PodMetricses returns all pods' usage metrics

type MemoryResource

type MemoryResource struct {
	*resource.Quantity
}

func NewMemoryResource

func NewMemoryResource(value int64) *MemoryResource

NewMemoryResource

func (*MemoryResource) String

func (r *MemoryResource) String() string

func (*MemoryResource) ToQuantity

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

ToQuantity

type MemoryResources

type MemoryResources struct {
	// MemoryUsages is a fraction of memory, that is allocated.
	MemoryUsages *MemoryResource

	// MemoryRequests is a fraction of memory, that is allocated.
	MemoryRequests *MemoryResource

	// MemoryRequestsFraction is a fraction of memory, that is allocated.
	MemoryRequestsFraction float64 `json:"memoryRequestsFraction"`

	// MemoryLimits is defined memory limit.
	MemoryLimits *MemoryResource

	// MemoryLimitsFraction is a fraction of defined memory limit, can be over 100%, i.e.
	// overcommitted.
	MemoryLimitsFraction float64 `json:"memoryLimitsFraction"`

	// MemoryCapacity is specified node memory capacity in bytes.
	MemoryCapacity *MemoryResource
}

MemoryResources describes node allocated resources.

type NodeAllocatedResources

type NodeAllocatedResources struct {
	CPUResources
	MemoryResources
	PodResources
}

NodeAllocatedResources describes node allocated resources.

type PodAllocatedResources

type PodAllocatedResources struct {
	// CPUUsages is number of allocated milicores.
	CPUUsages *CpuResource

	// CPURequestsFraction is a fraction of CPU, that is allocated.
	CPUUsagesFraction float64 `json:"cpuUsagesFraction"`

	// CPURequests is number of allocated milicores.
	CPURequests *CpuResource

	// CPULimits is defined CPU limit.
	CPULimits *CpuResource

	// MemoryUsages is a fraction of memory, that is allocated.
	MemoryUsages *MemoryResource

	// MemoryRequestsFraction is a fraction of memory, that is allocated.
	MemoryUsagesFraction float64 `json:"memoryUsagesFraction"`

	// MemoryRequests is a fraction of memory, that is allocated.
	MemoryRequests *MemoryResource

	// MemoryLimits is defined memory limit.
	MemoryLimits *MemoryResource
}

PodAllocatedResources describes node allocated resources.

type PodResources

type PodResources struct {
	// AllocatedPods in number of currently allocated pods on the node.
	AllocatedPods int `json:"allocatedPods"`

	// PodCapacity is maximum number of pods, that can be allocated on the node.
	PodCapacity int64 `json:"podCapacity"`

	// PodFraction is a fraction of pods, that can be allocated on given node.
	PodFraction float64 `json:"podFraction"`
}

MemoryResources describes node allocated resources.

Jump to

Keyboard shortcuts

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