top

Display Resource (CPU/Memory) usage.

The top command allows you to see the resource consumption for nodes or pods.

This command requires Metrics Server to be correctly configured and working on the server.

Usage

$ kubectl top


node

Show metrics for all nodes

  1. kubectl top node

Show metrics for a given node

  1. kubectl top node NODE_NAME

Display resource (CPU/memory) usage of nodes.

The top-node command allows you to see the resource consumption of nodes.

Usage

$ kubectl top node [NAME | -l label]

Flags

NameShorthandDefaultUsage
no-headersfalseIf present, print output without headers
selectorlSelector (label query) to filter on, supports ‘=’, ‘==’, and ‘!=’.(e.g. -l key1=value1,key2=value2)
sort-byIf non-empty, sort nodes list using specified field. The field can be either ‘cpu’ or ‘memory’.
use-protocol-bufferstrueEnables using protocol-buffers to access Metrics API.

pod

Show metrics for all pods in the default namespace

  1. kubectl top pod

Show metrics for all pods in the given namespace

  1. kubectl top pod --namespace=NAMESPACE

Show metrics for a given pod and its containers

  1. kubectl top pod POD_NAME --containers

Show metrics for the pods defined by label name=myLabel

  1. kubectl top pod -l name=myLabel

Display resource (CPU/memory) usage of pods.

The ‘top pod’ command allows you to see the resource consumption of pods.

Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.

Usage

$ kubectl top pod [NAME | -l label]

Flags

NameShorthandDefaultUsage
all-namespacesAfalseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with —namespace.
containersfalseIf present, print usage of containers within a pod.
field-selectorSelector (field query) to filter on, supports ‘=’, ‘==’, and ‘!=’.(e.g. —field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.
no-headersfalseIf present, print output without headers.
selectorlSelector (label query) to filter on, supports ‘=’, ‘==’, and ‘!=’.(e.g. -l key1=value1,key2=value2)
sort-byIf non-empty, sort pods list using specified field. The field can be either ‘cpu’ or ‘memory’.
use-protocol-bufferstrueEnables using protocol-buffers to access Metrics API.