workloads

package
v0.0.0-...-7cd5264 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KindGateway      = "Gateway"
	KindGatewayClass = "GatewayClass"
	KindHTTPRoute    = "HTTPRoute"
)
View Source
const (
	KindIngress               = "Ingress"
	KindService               = "Service"
	KindPersistentVolumeClaim = "PersistentVolumeClaim"
)
View Source
const (
	KindNodePool     = "NodePool"
	KindNodeClaim    = "NodeClaim"
	KindEC2NodeClass = "EC2NodeClass"
)

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
	NamespaceCounts        []NamespaceCounts
	Controllers            []ControllerResult
	Ingresses              []Ingress
	Services               []Service
	PersistentVolumeClaims []PersistentVolumeClaim
	Images                 []discovery.ImageResult
	// Karpenter is optional inventory of Karpenter CRDs (2.15+). Nil/omitted when
	// karpenter.sh is not installed. When present, nested arrays are always emitted
	// (possibly empty). Azure/GCP NodeClasses are out of scope for this release.
	Karpenter *Karpenter `json:",omitempty"`
	// GatewayAPI is optional inventory of Gateway API CRDs (2.16+). Nil/omitted when
	// gateway.networking.k8s.io is not installed. When present, nested arrays are always
	// emitted (including empty). KGateway (2.17+) is nested here and omitted when
	// gateway.kgateway.dev CRDs are absent.
	GatewayAPI *GatewayAPI `json:",omitempty"`
}

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
	// VolumeClaims lists PersistentVolumeClaim refs from the pod template and running pods.
	VolumeClaims []VolumeClaimRef `json:",omitempty"`
	// NodeNames are unique nodes where Running pods for this controller are scheduled.
	NodeNames []string `json:",omitempty"`
}

ControllerResult provides a wrapper around a PodResult

type EC2NodeClass

type EC2NodeClass struct {
	Kind                       string
	Name                       string
	UID                        string
	APIVersion                 string
	Labels                     map[string]string
	Annotations                map[string]string
	Role                       string                  `json:",omitempty"`
	InstanceProfile            string                  `json:",omitempty"`
	AMIFamily                  string                  `json:",omitempty"`
	Tags                       map[string]string       `json:",omitempty"`
	SubnetSelectorTerms        []KarpenterSelectorTerm `json:",omitempty"`
	SecurityGroupSelectorTerms []KarpenterSelectorTerm `json:",omitempty"`
	AMISelectorTerms           []KarpenterSelectorTerm `json:",omitempty"`
	Conditions                 []KarpenterCondition    `json:",omitempty"`
}

EC2NodeClass is an AWS Karpenter EC2NodeClass inventory object (cluster-scoped).

type Gateway

type Gateway struct {
	Kind             string
	Name             string
	Namespace        string
	Annotations      map[string]string
	Labels           map[string]string
	UID              string
	APIVersion       string
	GatewayClassName string             `json:",omitempty"`
	Listeners        []GatewayListener  `json:",omitempty"`
	Addresses        []GatewayAddress   `json:",omitempty"`
	Conditions       []GatewayCondition `json:",omitempty"`
}

Gateway is a Gateway API Gateway inventory object (namespaced).

type GatewayAPI

type GatewayAPI struct {
	Gateways       []Gateway
	GatewayClasses []GatewayClass
	HTTPRoutes     []HTTPRoute
	KGateway       *KGateway `json:",omitempty"`
}

GatewayAPI is optional Gateway API inventory nested under ClusterWorkloadReport. Omitted (nil) when gateway.networking.k8s.io CRDs are not installed.

type GatewayAddress

type GatewayAddress struct {
	Type  string `json:",omitempty"`
	Value string `json:",omitempty"`
}

GatewayAddress is a status address entry.

type GatewayClass

type GatewayClass struct {
	Kind           string
	Name           string
	Annotations    map[string]string
	Labels         map[string]string
	UID            string
	APIVersion     string
	ControllerName string             `json:",omitempty"`
	ParametersRef  *GatewayObjectRef  `json:",omitempty"`
	Conditions     []GatewayCondition `json:",omitempty"`
}

GatewayClass is a cluster-scoped Gateway API class.

type GatewayCondition

type GatewayCondition struct {
	Type               string `json:",omitempty"`
	Status             string `json:",omitempty"`
	Reason             string `json:",omitempty"`
	Message            string `json:",omitempty"`
	LastTransitionTime string `json:",omitempty"`
}

GatewayCondition is a status condition summary.

type GatewayListener

type GatewayListener struct {
	Name            string             `json:",omitempty"`
	Protocol        string             `json:",omitempty"`
	Port            int32              `json:",omitempty"`
	Hostname        string             `json:",omitempty"`
	TLSMode         string             `json:",omitempty"`
	CertificateRefs []GatewayObjectRef `json:",omitempty"`
}

GatewayListener is a Gateway listener summary.

type GatewayObjectRef

type GatewayObjectRef struct {
	Group       string `json:",omitempty"`
	Kind        string `json:",omitempty"`
	Name        string `json:",omitempty"`
	Namespace   string `json:",omitempty"`
	SectionName string `json:",omitempty"`
	Port        *int32 `json:",omitempty"`
	Weight      *int32 `json:",omitempty"`
}

GatewayObjectRef is a simplified ParentRef / BackendRef / CertificateRef.

type GatewayTargetSelector

type GatewayTargetSelector struct {
	Group       string            `json:",omitempty"`
	Kind        string            `json:",omitempty"`
	MatchLabels map[string]string `json:",omitempty"`
}

GatewayTargetSelector is a label selector used by kgateway policies (targetSelectors).

type HTTPRoute

type HTTPRoute struct {
	Kind        string
	Name        string
	Namespace   string
	Annotations map[string]string
	Labels      map[string]string
	UID         string
	APIVersion  string
	Hostnames   []string           `json:",omitempty"`
	ParentRefs  []GatewayObjectRef `json:",omitempty"`
	Rules       []HTTPRouteRule    `json:",omitempty"`
}

HTTPRoute is a Gateway API HTTPRoute inventory object (namespaced).

type HTTPRouteMatch

type HTTPRouteMatch struct {
	PathType string `json:",omitempty"`
	Path     string `json:",omitempty"`
}

HTTPRouteMatch is a path match summary.

type HTTPRouteRule

type HTTPRouteRule struct {
	Matches       []HTTPRouteMatch   `json:",omitempty"`
	BackendRefs   []GatewayObjectRef `json:",omitempty"`
	ExtensionRefs []GatewayObjectRef `json:",omitempty"`
}

HTTPRouteRule is a match + backendRefs rule.

type Ingress

type Ingress struct {
	Kind             string
	Name             string
	Namespace        string
	Annotations      map[string]string
	Labels           map[string]string
	UID              string
	APIVersion       string
	IngressClassName *string                    `json:",omitempty"`
	Rules            []IngressRuleSummary       `json:",omitempty"`
	TLS              []IngressTLSSummary        `json:",omitempty"`
	DefaultBackend   *IngressBackendSummary     `json:",omitempty"`
	LoadBalancer     []IngressLoadBalancerEntry `json:",omitempty"`
}

type IngressBackendSummary

type IngressBackendSummary struct {
	ServiceName string `json:",omitempty"`
	ServicePort string `json:",omitempty"`
	API         string `json:",omitempty"`
	Kind        string `json:",omitempty"`
	Name        string `json:",omitempty"`
}

IngressBackendSummary is a service or resource backend for an Ingress path/default.

type IngressLoadBalancerEntry

type IngressLoadBalancerEntry struct {
	IP       string `json:",omitempty"`
	Hostname string `json:",omitempty"`
}

IngressLoadBalancerEntry is a load-balancer ingress point.

type IngressPathSummary

type IngressPathSummary struct {
	Path     string
	PathType string `json:",omitempty"`
	Backend  IngressBackendSummary
}

IngressPathSummary is a single HTTP path rule.

type IngressRuleSummary

type IngressRuleSummary struct {
	Host  string
	Paths []IngressPathSummary `json:",omitempty"`
}

IngressRuleSummary is a host rule with HTTP paths.

type IngressTLSSummary

type IngressTLSSummary struct {
	Hosts      []string `json:",omitempty"`
	SecretName string   `json:",omitempty"`
}

IngressTLSSummary is TLS config for an Ingress.

type KGateway

type KGateway struct {
	Backends              []KGatewayResource
	BackendConfigPolicies []KGatewayResource
	DirectResponses       []KGatewayResource
	GatewayExtensions     []KGatewayResource
	GatewayParameters     []KGatewayResource
	HTTPListenerPolicies  []KGatewayResource
	ListenerPolicies      []KGatewayResource
	TrafficPolicies       []KGatewayResource
}

KGateway is optional kgateway inventory nested under GatewayAPI.

type KGatewayResource

type KGatewayResource struct {
	Kind            string
	Name            string
	Namespace       string
	Annotations     map[string]string
	Labels          map[string]string
	UID             string
	APIVersion      string
	TargetRefs      []GatewayObjectRef      `json:",omitempty"`
	TargetSelectors []GatewayTargetSelector `json:",omitempty"`
	SpecFields      []string                `json:",omitempty"`
	Type            string                  `json:",omitempty"`
	StatusCode      int32                   `json:",omitempty"`
	Conditions      []GatewayCondition      `json:",omitempty"`
}

KGatewayResource is a safe inventory summary shared by kgateway CRDs.

type Karpenter

type Karpenter struct {
	NodePools      []NodePool
	NodeClaims     []NodeClaim
	EC2NodeClasses []EC2NodeClass // AWS only; empty when EC2NodeClass CRDs/RBAC absent
}

Karpenter is optional Karpenter inventory nested under ClusterWorkloadReport. Omitted (nil) when karpenter.sh CRDs are not installed.

type KarpenterCondition

type KarpenterCondition struct {
	Type               string `json:",omitempty"`
	Status             string `json:",omitempty"`
	Reason             string `json:",omitempty"`
	Message            string `json:",omitempty"`
	LastTransitionTime string `json:",omitempty"`
}

KarpenterCondition is a status condition summary.

type KarpenterDisruption

type KarpenterDisruption struct {
	ConsolidationPolicy string                      `json:",omitempty"`
	ConsolidateAfter    string                      `json:",omitempty"`
	Budgets             []KarpenterDisruptionBudget `json:",omitempty"`
}

KarpenterDisruption is NodePool disruption configuration.

type KarpenterDisruptionBudget

type KarpenterDisruptionBudget struct {
	Nodes    string `json:",omitempty"`
	Schedule string `json:",omitempty"`
	Duration string `json:",omitempty"`
}

KarpenterDisruptionBudget is a NodePool disruption budget summary.

type KarpenterNodeClassRef

type KarpenterNodeClassRef struct {
	Group string `json:",omitempty"`
	Kind  string `json:",omitempty"`
	Name  string `json:",omitempty"`
}

KarpenterNodeClassRef is a reference from a NodePool/NodeClaim to a NodeClass.

type KarpenterRequirement

type KarpenterRequirement struct {
	Key      string   `json:",omitempty"`
	Operator string   `json:",omitempty"`
	Values   []string `json:",omitempty"`
}

KarpenterRequirement mirrors a Karpenter node requirement.

type KarpenterSelectorTerm

type KarpenterSelectorTerm struct {
	ID    string            `json:",omitempty"`
	Name  string            `json:",omitempty"`
	Alias string            `json:",omitempty"`
	Owner string            `json:",omitempty"`
	Tags  map[string]string `json:",omitempty"`
}

KarpenterSelectorTerm is a simplified AMI/subnet/security-group selector term.

type NamespaceCounts

type NamespaceCounts struct {
	Name               string
	ResourceQuotaCount int
	LimitRangeCount    int
	NetworkPolicyCount int
	PodCount           int
	ServiceCount       int
	IngressCount       int
}

NamespaceCounts holds per-namespace inventory object counts.

type NodeAddressSummary

type NodeAddressSummary struct {
	Type    string
	Address string
}

NodeAddressSummary is a simplified node address.

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 NodeClaim

type NodeClaim struct {
	Kind         string
	Name         string
	UID          string
	APIVersion   string
	Labels       map[string]string
	Annotations  map[string]string
	NodePool     string `json:",omitempty"`
	NodeClassRef *KarpenterNodeClassRef
	Requirements []KarpenterRequirement
	ProviderID   string               `json:",omitempty"`
	NodeName     string               `json:",omitempty"`
	Conditions   []KarpenterCondition `json:",omitempty"`
}

NodeClaim is a Karpenter NodeClaim inventory object (cluster-scoped).

type NodeConditionSummary

type NodeConditionSummary struct {
	Type               string
	Status             string
	Reason             string    `json:",omitempty"`
	Message            string    `json:",omitempty"`
	LastTransitionTime time.Time `json:",omitempty"`
}

NodeConditionSummary is a simplified node condition.

type NodeInfoSummary

type NodeInfoSummary struct {
	Architecture            string `json:",omitempty"`
	OperatingSystem         string `json:",omitempty"`
	OSImage                 string `json:",omitempty"`
	ContainerRuntimeVersion string `json:",omitempty"`
	KernelVersion           string `json:",omitempty"`
	KubeletVersion          string `json:",omitempty"`
}

NodeInfoSummary is a simplified node system info.

type NodePool

type NodePool struct {
	Kind         string
	Name         string
	UID          string
	APIVersion   string
	Labels       map[string]string
	Annotations  map[string]string
	Weight       *int32
	Limits       map[string]string
	NodeClassRef *KarpenterNodeClassRef
	Requirements []KarpenterRequirement
	Disruption   *KarpenterDisruption
	Conditions   []KarpenterCondition `json:",omitempty"`
}

NodePool is a Karpenter NodePool inventory object (cluster-scoped).

type NodeSummary

type NodeSummary struct {
	Name               string
	UID                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
	Conditions         []NodeConditionSummary `json:",omitempty"`
	Taints             []NodeTaintSummary     `json:",omitempty"`
	Unschedulable      bool
	Addresses          []NodeAddressSummary `json:",omitempty"`
	ProviderID         string               `json:",omitempty"`
	NodeInfo           NodeInfoSummary
}

NodeSummary gives highlevel overview of node informations

type NodeTaintSummary

type NodeTaintSummary struct {
	Key    string
	Value  string `json:",omitempty"`
	Effect string
}

NodeTaintSummary is a simplified node taint.

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 PersistentVolumeClaim

type PersistentVolumeClaim struct {
	Kind             string
	Name             string
	Namespace        string
	Annotations      map[string]string
	Labels           map[string]string
	UID              string
	APIVersion       string
	StorageClassName *string  `json:",omitempty"`
	AccessModes      []string `json:",omitempty"`
	VolumeMode       string   `json:",omitempty"`
	VolumeName       string   `json:",omitempty"`
	RequestStorage   string   `json:",omitempty"`
	CapacityStorage  string   `json:",omitempty"`
	Phase            string   `json:",omitempty"`
}

PersistentVolumeClaim is a PVC inventory object.

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 Service

type Service struct {
	Kind         string
	Name         string
	Namespace    string
	Annotations  map[string]string
	Labels       map[string]string
	UID          string
	APIVersion   string
	Type         string                     `json:",omitempty"`
	ClusterIP    string                     `json:",omitempty"`
	ClusterIPs   []string                   `json:",omitempty"`
	ExternalName string                     `json:",omitempty"`
	ExternalIPs  []string                   `json:",omitempty"`
	Selector     map[string]string          `json:",omitempty"`
	Ports        []ServicePortSummary       `json:",omitempty"`
	LoadBalancer []IngressLoadBalancerEntry `json:",omitempty"`
}

Service is a cluster Service inventory object.

type ServicePortSummary

type ServicePortSummary struct {
	Name       string `json:",omitempty"`
	Protocol   string `json:",omitempty"`
	Port       int32
	TargetPort string `json:",omitempty"`
	NodePort   int32  `json:",omitempty"`
}

ServicePortSummary is a single Service port.

type SpecAppliedSkewPod

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

type SpecAppliedStats

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

type VolumeClaimRef

type VolumeClaimRef struct {
	Name      string `json:",omitempty"` // volume name in the pod spec
	ClaimName string // PersistentVolumeClaim.claimName
}

VolumeClaimRef is a pod volume that references a PersistentVolumeClaim.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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