kubernetes: k8s.io/kubernetes/pkg/kubelet/server/stats Index | Files | Directories

package stats

import "k8s.io/kubernetes/pkg/kubelet/server/stats"

Package stats handles exporting Kubelet and container stats. NOTE: We intend to move this functionality into a standalone pod, so this package should be very loosely coupled to the rest of the Kubelet.

Index

Package Files

doc.go fs_resource_analyzer.go handler.go prometheus_resource_metrics.go resource_analyzer.go summary.go summary_sys_containers.go volume_stat_calculator.go

func CreateHandlers Uses

func CreateHandlers(rootPath string, provider Provider, summaryProvider SummaryProvider, enableCAdvisorJSONEndpoints bool) *restful.WebService

CreateHandlers creates the REST handlers for the stats.

func NewPrometheusResourceMetricCollector Uses

func NewPrometheusResourceMetricCollector(provider SummaryProvider, config ResourceMetricsConfig) metrics.StableCollector

NewPrometheusResourceMetricCollector returns a metrics.StableCollector which exports resource metrics

type ContainerResourceMetric Uses

type ContainerResourceMetric struct {
    Desc    *metrics.Desc
    ValueFn func(stats.ContainerStats) (*float64, time.Time)
}

ContainerResourceMetric describes a metric for containers

type NodeResourceMetric Uses

type NodeResourceMetric struct {
    Desc    *metrics.Desc
    ValueFn func(stats.NodeStats) (*float64, time.Time)
}

NodeResourceMetric describes a metric for the node

type PodVolumeStats Uses

type PodVolumeStats struct {
    EphemeralVolumes  []stats.VolumeStats
    PersistentVolumes []stats.VolumeStats
}

PodVolumeStats encapsulates the VolumeStats for a pod. It consists of two lists, for local ephemeral volumes, and for persistent volumes respectively.

type Provider Uses

type Provider interface {
    // The following stats are provided by either CRI or cAdvisor.
    //
    // ListPodStats returns the stats of all the containers managed by pods.
    ListPodStats() ([]statsapi.PodStats, error)
    // ListPodStatsAndUpdateCPUNanoCoreUsage updates the cpu nano core usage for
    // the containers and returns the stats for all the pod-managed containers.
    ListPodCPUAndMemoryStats() ([]statsapi.PodStats, error)
    // ListPodStatsAndUpdateCPUNanoCoreUsage returns the stats of all the
    // containers managed by pods and force update the cpu usageNanoCores.
    // This is a workaround for CRI runtimes that do not integrate with
    // cadvisor. See https://github.com/kubernetes/kubernetes/issues/72788
    // for more details.
    ListPodStatsAndUpdateCPUNanoCoreUsage() ([]statsapi.PodStats, error)
    // ImageFsStats returns the stats of the image filesystem.
    ImageFsStats() (*statsapi.FsStats, error)

    // The following stats are provided by cAdvisor.
    //
    // GetCgroupStats returns the stats and the networking usage of the cgroup
    // with the specified cgroupName.
    GetCgroupStats(cgroupName string, updateStats bool) (*statsapi.ContainerStats, *statsapi.NetworkStats, error)
    // GetCgroupCPUAndMemoryStats returns the CPU and memory stats of the cgroup with the specified cgroupName.
    GetCgroupCPUAndMemoryStats(cgroupName string, updateStats bool) (*statsapi.ContainerStats, error)

    // RootFsStats returns the stats of the node root filesystem.
    RootFsStats() (*statsapi.FsStats, error)

    // The following stats are provided by cAdvisor for legacy usage.
    //
    // GetContainerInfo returns the information of the container with the
    // containerName managed by the pod with the uid.
    GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
    // GetRawContainerInfo returns the information of the container with the
    // containerName. If subcontainers is true, this function will return the
    // information of all the sub-containers as well.
    GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error)

    // The following information is provided by Kubelet.
    //
    // GetPodByName returns the spec of the pod with the name in the specified
    // namespace.
    GetPodByName(namespace, name string) (*v1.Pod, bool)
    // GetNode returns the spec of the local node.
    GetNode() (*v1.Node, error)
    // GetNodeConfig returns the configuration of the local node.
    GetNodeConfig() cm.NodeConfig
    // ListVolumesForPod returns the stats of the volume used by the pod with
    // the podUID.
    ListVolumesForPod(podUID types.UID) (map[string]volume.Volume, bool)
    // GetPods returns the specs of all the pods running on this node.
    GetPods() []*v1.Pod

    // RlimitStats returns the rlimit stats of system.
    RlimitStats() (*statsapi.RlimitStats, error)

    // GetPodCgroupRoot returns the literal cgroupfs value for the cgroup containing all pods
    GetPodCgroupRoot() string

    // GetPodByCgroupfs provides the pod that maps to the specified cgroup literal, as well
    // as whether the pod was found.
    GetPodByCgroupfs(cgroupfs string) (*v1.Pod, bool)
}

Provider hosts methods required by stats handlers.

type ResourceAnalyzer Uses

type ResourceAnalyzer interface {
    Start()

    SummaryProvider
    // contains filtered or unexported methods
}

ResourceAnalyzer provides statistics on node resource consumption

func NewResourceAnalyzer Uses

func NewResourceAnalyzer(statsProvider Provider, calVolumeFrequency time.Duration) ResourceAnalyzer

NewResourceAnalyzer returns a new ResourceAnalyzer

type ResourceMetricsConfig Uses

type ResourceMetricsConfig struct {
    NodeMetrics      []NodeResourceMetric
    ContainerMetrics []ContainerResourceMetric
}

ResourceMetricsConfig specifies which metrics to collect and export

type SummaryProvider Uses

type SummaryProvider interface {
    // Get provides a new Summary with the stats from Kubelet,
    // and will update some stats if updateStats is true
    Get(updateStats bool) (*statsapi.Summary, error)
    // GetCPUAndMemoryStats provides a new Summary with the CPU and memory stats from Kubelet,
    GetCPUAndMemoryStats() (*statsapi.Summary, error)
}

SummaryProvider provides summaries of the stats from Kubelet.

func NewSummaryProvider Uses

func NewSummaryProvider(statsProvider Provider) SummaryProvider

NewSummaryProvider returns a SummaryProvider using the stats provided by the specified statsProvider.

Directories

PathSynopsis
testing

Package stats imports 22 packages (graph) and is imported by 232 packages. Updated 2019-11-11. Refresh now. Tools for package owners.