top

package
v1.10.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MeasuredResources is the list of resources that are measured by the top command.
	MeasuredResources = []corev1.ResourceName{
		corev1.ResourceCPU,
		corev1.ResourceMemory,
	}
	// PodColumns is the list of columns used in the top pod command.
	PodColumns = []string{"NAME", "CLUSTER", "CPU(cores)", "MEMORY(bytes)"}
	// NamespaceColumn is the column name for namespace.
	NamespaceColumn = "NAMESPACE"
	// PodColumn is the column name for pod.
	PodColumn = "POD"
)

Functions

func GenClusterList added in v1.8.0

func GenClusterList(clientSet karmadaclientset.Interface, clusters []string) ([]string, error)

GenClusterList generates the cluster list.

func GetMemberAndMetricsClientSet added in v1.8.0

func GetMemberAndMetricsClientSet(f util.Factory,
	cluster string, useProtocolBuffers bool) (*kubernetes.Clientset, *metricsclientset.Clientset, error)

GetMemberAndMetricsClientSet returns the clientset for member cluster and metrics server.

func NewCmdTop

func NewCmdTop(f util.Factory, parentCommand string, streams genericiooptions.IOStreams) *cobra.Command

NewCmdTop implements the top command.

func NewCmdTopPod

func NewCmdTopPod(f util.Factory, parentCommand string, o *PodOptions, streams genericiooptions.IOStreams) *cobra.Command

NewCmdTopPod implements the top pod command.

func SupportedMetricsAPIVersionAvailable

func SupportedMetricsAPIVersionAvailable(discoveredAPIGroups *metav1.APIGroupList) bool

SupportedMetricsAPIVersionAvailable checks if the metrics API version is supported.

Types

type CmdPrinter added in v1.9.0

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

CmdPrinter is an implementation of TopPrinter which prints the metrics to the given writer.

func NewTopCmdPrinter

func NewTopCmdPrinter(out io.Writer) *CmdPrinter

NewTopCmdPrinter creates a new TopCmdPrinter.

func (*CmdPrinter) PrintPodMetrics added in v1.9.0

func (printer *CmdPrinter) PrintPodMetrics(metrics []metricsapi.PodMetrics, printContainers, withNamespace, noHeaders bool, sortBy string, sum bool) error

PrintPodMetrics prints the given metrics to the given writer.

type PodMetricsSorter

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

PodMetricsSorter sorts a list of PodMetrics.

func NewPodMetricsSorter

func NewPodMetricsSorter(metrics []metricsapi.PodMetrics, withNamespace bool, sortBy string) *PodMetricsSorter

NewPodMetricsSorter returns a new PodMetricsSorter, which can be used to sort a list of PodMetrics.

func (*PodMetricsSorter) Len

func (p *PodMetricsSorter) Len() int

Len returns the length of the PodMetricsSorter.

func (*PodMetricsSorter) Less

func (p *PodMetricsSorter) Less(i, j int) bool

Less compares two PodMetrics and returns true if the first PodMetrics should sort before the second.

func (*PodMetricsSorter) Swap

func (p *PodMetricsSorter) Swap(i, j int)

Swap swaps the place of two PodMetrics.

type PodOptions added in v1.9.0

type PodOptions struct {
	ResourceName       string
	Namespace          string
	Clusters           []string
	LabelSelector      string
	FieldSelector      string
	SortBy             string
	AllNamespaces      bool
	PrintContainers    bool
	NoHeaders          bool
	UseProtocolBuffers bool
	Sum                bool

	Printer *CmdPrinter

	genericiooptions.IOStreams
	// contains filtered or unexported fields
}

PodOptions contains the options to the top command.

func (*PodOptions) Complete added in v1.9.0

func (o *PodOptions) Complete(f util.Factory, cmd *cobra.Command, args []string) error

Complete completes all the required options.

func (*PodOptions) RunTopPod added in v1.9.0

func (o *PodOptions) RunTopPod(f util.Factory) error

RunTopPod runs the top pod command.

func (*PodOptions) Validate added in v1.9.0

func (o *PodOptions) Validate() error

Validate checks the validity of the options.

type ResourceAdder

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

ResourceAdder adds pod metrics to a total

func NewResourceAdder

func NewResourceAdder(resources []corev1.ResourceName) *ResourceAdder

NewResourceAdder returns a new ResourceAdder

func (*ResourceAdder) AddPodMetrics

func (adder *ResourceAdder) AddPodMetrics(m *metricsapi.PodMetrics)

AddPodMetrics adds each pod metric to the total

type ResourceMetricsInfo

type ResourceMetricsInfo struct {
	Cluster   string
	Name      string
	Metrics   corev1.ResourceList
	Available corev1.ResourceList
}

ResourceMetricsInfo contains the information of a resource metric.

Jump to

Keyboard shortcuts

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