package util

import "k8s.io/kubernetes/pkg/kubelet/util"

Package util holds utility functions.

Index

Variables

var IsUnixDomainSocket = filesystem.IsUnixDomainSocket

Functions

func FromApiserverCache

func FromApiserverCache(opts *metav1.GetOptions)

FromApiserverCache modifies <opts> so that the GET request will be served from apiserver cache instead of from etcd.

func GetBootTime

func GetBootTime() (time.Time, error)

GetBootTime returns the time at which the machine was started, truncated to the nearest second. It uses /proc/stat first, which is more accurate, and falls back to the less accurate unix.Sysinfo if /proc/stat failed.

func GetContainerByIndex

func GetContainerByIndex(containers []v1.Container, statuses []v1.ContainerStatus, idx int) (v1.Container, bool)

GetContainerByIndex validates and extracts the container at index "idx" from "containers" with respect to "statuses". It returns true if the container is valid, else returns false.

func GetNodenameForKernel

func GetNodenameForKernel(hostname string, hostDomainName string, setHostnameAsFQDN *bool) (string, error)

GetNodenameForKernel gets hostname value to set in the hostname field (the nodename field of struct utsname) of the pod.

func IsCgroup2UnifiedMode

func IsCgroup2UnifiedMode() bool

IsCgroup2UnifiedMode returns true if the cgroup v2 unified mode is enabled

func LocalEndpoint

func LocalEndpoint(path, file string) (string, error)

LocalEndpoint returns the full path to a unix socket at the given endpoint

func NormalizePath

func NormalizePath(path string) string

NormalizePath is a no-op for Linux for now

func SetNodeOwnerFunc

func SetNodeOwnerFunc(c clientset.Interface, nodeName string) func(lease *coordinationv1.Lease) error

SetNodeOwnerFunc helps construct a newLeasePostProcessFunc which sets a node OwnerReference to the given lease object

Types

type NodeStartupLatencyTracker

type NodeStartupLatencyTracker interface {
	// This function may be called across Kubelet restart.
	RecordAttemptRegisterNode()
	// This function should not be called across Kubelet restart.
	RecordRegisteredNewNode()
	// This function may be called across Kubelet restart.
	RecordNodeReady()
}

func NewNodeStartupLatencyTracker

func NewNodeStartupLatencyTracker() NodeStartupLatencyTracker

type PodStartupLatencyTracker

type PodStartupLatencyTracker interface {
	ObservedPodOnWatch(pod *v1.Pod, when time.Time)
	RecordImageStartedPulling(podUID types.UID)
	RecordImageFinishedPulling(podUID types.UID)
	RecordStatusUpdated(pod *v1.Pod)
	DeletePodStartupState(podUID types.UID)
}

PodStartupLatencyTracker records key moments for startup latency calculation, e.g. image pulling or pod observed running on watch.

func NewPodStartupLatencyTracker

func NewPodStartupLatencyTracker() PodStartupLatencyTracker

NewPodStartupLatencyTracker creates an instance of PodStartupLatencyTracker

Source Files

boottime_util_linux.go doc.go node_startup_latency_tracker.go nodelease.go pod_startup_latency_tracker.go util.go util_linux.go util_unix.go

Directories

PathSynopsis
pkg/kubelet/util/cache
pkg/kubelet/util/format
pkg/kubelet/util/ioutils
pkg/kubelet/util/manager
pkg/kubelet/util/queue
pkg/kubelet/util/sliceutils
pkg/kubelet/util/storePackage store hosts a Store interface and its implementations.
pkg/kubelet/util/swap
Version
v1.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
20 packages
Last checked
3 hours ago

Tools for package owners.