Documentation ¶
Index ¶
- Variables
- func GenClusterList(clientSet karmadaclientset.Interface, clusters []string) ([]string, error)
- func GetMemberAndMetricsClientSet(f util.Factory, cluster string, useProtocolBuffers bool) (*kubernetes.Clientset, *metricsclientset.Clientset, error)
- func NewCmdTop(f util.Factory, parentCommand string, streams genericiooptions.IOStreams) *cobra.Command
- func NewCmdTopNode(f util.Factory, parentCommand string, o *NodeOptions, ...) *cobra.Command
- func NewCmdTopPod(f util.Factory, parentCommand string, o *PodOptions, ...) *cobra.Command
- func SupportedMetricsAPIVersionAvailable(discoveredAPIGroups *metav1.APIGroupList) bool
- type CmdPrinter
- type NodeMetricsSorter
- type NodeOptions
- type PodMetricsSorter
- type PodOptions
- type ResourceAdder
- type ResourceMetricsInfo
Constants ¶
This section is empty.
Variables ¶
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" // NodeColumns is the list of columns used in the top node command. NodeColumns = []string{"NAME", "CLUSTER", "CPU(cores)", "CPU%", "MEMORY(bytes)", "MEMORY%"} )
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 NewCmdTopNode ¶ added in v1.11.0
func NewCmdTopNode(f util.Factory, parentCommand string, o *NodeOptions, streams genericclioptions.IOStreams) *cobra.Command
NewCmdTopNode implements the top node 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) PrintNodeMetrics ¶ added in v1.11.0
func (printer *CmdPrinter) PrintNodeMetrics(metrics []metricsapi.NodeMetrics, availableResources map[string]map[string]corev1.ResourceList, noHeaders bool, sortBy string) error
PrintNodeMetrics prints the given metrics to the given writer.
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 NodeMetricsSorter ¶ added in v1.11.0
type NodeMetricsSorter struct {
// contains filtered or unexported fields
}
NodeMetricsSorter sorts a list of NodeMetrics.
func NewNodeMetricsSorter ¶ added in v1.11.0
func NewNodeMetricsSorter(metrics []metricsapi.NodeMetrics, sortBy string) *NodeMetricsSorter
NewNodeMetricsSorter returns a new NodeMetricsSorter, which can be used to sort a list of NodeMetrics.
func (*NodeMetricsSorter) Len ¶ added in v1.11.0
func (n *NodeMetricsSorter) Len() int
Len returns the length of the NodeMetricsSorter.
func (*NodeMetricsSorter) Less ¶ added in v1.11.0
func (n *NodeMetricsSorter) Less(i, j int) bool
Less compares two NodeMetrics and returns true if the first NodeMetrics should sort before the second.
func (*NodeMetricsSorter) Swap ¶ added in v1.11.0
func (n *NodeMetricsSorter) Swap(i, j int)
Swap swaps the place of two NodeMetrics.
type NodeOptions ¶ added in v1.11.0
type NodeOptions struct { Clusters []string ResourceName string Selector string SortBy string NoHeaders bool UseProtocolBuffers bool ShowCapacity bool Printer *CmdPrinter genericiooptions.IOStreams // contains filtered or unexported fields }
NodeOptions contains all the options for running the top-node cli command.
func (*NodeOptions) RunTopNode ¶ added in v1.11.0
func (o *NodeOptions) RunTopNode(f util.Factory) error
RunTopNode runs the top node command.
func (*NodeOptions) Validate ¶ added in v1.11.0
func (o *NodeOptions) Validate() error
Validate checks the validity of the options.
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) 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.