workloads

package
v0.0.0-...-720f831 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const KindIngress = "Ingress"

Variables

This section is empty.

Functions

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 AppliedResources

type AppliedResources struct {
	Requests         ResourcesInfo
	Limits           ResourcesInfo
	ExtendedRequests map[string]string `json:"ExtendedRequests,omitempty"`
	ExtendedLimits   map[string]string `json:"ExtendedLimits,omitempty"`
}

AppliedResources are request/limit strings derived from status.containerStatuses[].resources (runtime-applied), not pod spec. CPU and Memory stay on Requests/Limits (ResourcesInfo). GPU-class applied quantities use ExtendedRequests/ExtendedLimits.

type ClusterWorkloadReport

type ClusterWorkloadReport struct {
	ServerVersion string
	CreationTime  time.Time
	SourceName    string
	SourceType    string
	Nodes         []NodeSummary
	Namespaces    []corev1.Namespace
	Controllers   []ControllerResult
	Ingresses     []Ingress
}

ClusterWorkloadReport contains k8s workload resources report structure

func CreateResourceProviderFromAPI

func CreateResourceProviderFromAPI(ctx context.Context, dynamicClient dynamic.Interface, restMapper meta.RESTMapper, kube kubernetes.Interface, clusterName string) (*ClusterWorkloadReport, error)

CreateResourceProviderFromAPI creates a new ResourceProvider from an existing k8s interface

type ContainerResult

type ContainerResult struct {
	Name         string
	Image        string
	ImageID      string
	CreationTime time.Time
	Resource     ResourceResult
}

ContainerResult provides a list of validation messages for each container.

type ControllerResult

type ControllerResult struct {
	Kind           string
	Name           string
	Namespace      string
	Annotations    map[string]string
	Labels         map[string]string
	PodLabels      map[string]string
	PodAnnotations map[string]string
	UID            string
	ParentUID      string
	PodCount       float64
	Containers     []ContainerResult
}

ControllerResult provides a wrapper around a PodResult

type Ingress

type Ingress struct {
	Kind        string
	Name        string
	Namespace   string
	Annotations map[string]string
	Labels      map[string]string
	UID         string
	APIVersion  string
}

type NodeAllocatedResources

type NodeAllocatedResources struct {
	// Requests is the total requested resources of all pods in the node
	Requests v1.ResourceList
	// Requests is the total resource limits of all pods in the node
	Limits v1.ResourceList
}

NodeAllocatedResources describes node allocated resources.

type NodeSummary

type NodeSummary struct {
	Name               string
	Labels             map[string]string
	Annotations        map[string]string
	CreationTimestamp  time.Time
	Capacity           corev1.ResourceList
	Allocatable        corev1.ResourceList
	AllocatedLimits    corev1.ResourceList
	AllocatedRequests  corev1.ResourceList
	Utilization        NodeUtilization
	KubeletVersion     string
	KubeProxyVersion   string
	IsControlPlaneNode bool
}

NodeSummary gives highlevel overview of node informations

type NodeUtilization

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

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

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

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

	// GPURequestsFraction is a fraction of GPU, that is allocated.
	GPURequestsFraction float64 `json:"gpuRequestsFraction"`

	// GPULimitsFraction is a fraction of defined GPU limit, can be over 100%, i.e.
	// overcommitted.
	GPULimitsFraction float64 `json:"gpuLimitsFraction"`
}

type ResourceResult

type ResourceResult struct {
	Requests ResourcesInfo
	Limits   ResourcesInfo
	// GPURequests / GPULimits: optional template (pod spec) GPU-class maps; resource names vary by vendor (see Extended* on Applied for applied status when skewing).
	GPURequests map[string]string `json:"GPURequests,omitempty"`
	GPULimits   map[string]string `json:"GPULimits,omitempty"`
	// SpecAppliedConvergedCount is how many Running+Ready pods have status.containerStatuses[].resources
	// populated and semantically matching this workload's pod template (CPU/memory and tracked GPU-class resources) for this container.
	SpecAppliedConvergedCount int `json:"SpecAppliedConvergedCount"`
	// SpecAppliedSkewPods lists pods whose applied status resources differ from the top controller pod template (e.g. in-place resize ahead of template rollout).
	SpecAppliedSkewPods []SpecAppliedSkewPod `json:",omitempty"`
}

ResourceResult provides resources information.

type ResourcesInfo

type ResourcesInfo struct {
	Memory string
	CPU    string
}

ResourcesInfo provides request/limit item information (CPU and memory only).

type SpecAppliedSkewPod

type SpecAppliedSkewPod struct {
	Namespace string
	Name      string
	UID       string
	Applied   AppliedResources
}

type SpecAppliedStats

type SpecAppliedStats struct {
	ConvergedCount int
	SkewPods       []SpecAppliedSkewPod `json:",omitempty"`
}

Jump to

Keyboard shortcuts

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