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
kubectl top node
Show metrics for a given node
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
Name | Shorthand | Default | Usage |
---|---|---|---|
no-headers | false | If present, print output without headers | |
selector | l | Selector (label query) to filter on, supports ‘=’, ‘==’, and ‘!=’.(e.g. -l key1=value1,key2=value2) | |
sort-by | If non-empty, sort nodes list using specified field. The field can be either ‘cpu’ or ‘memory’. | ||
use-protocol-buffers | true | Enables using protocol-buffers to access Metrics API. |
pod
Show metrics for all pods in the default namespace
kubectl top pod
Show metrics for all pods in the given namespace
kubectl top pod --namespace=NAMESPACE
Show metrics for a given pod and its containers
kubectl top pod POD_NAME --containers
Show metrics for the pods defined by label name=myLabel
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
Name | Shorthand | Default | Usage |
---|---|---|---|
all-namespaces | A | false | If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with —namespace. |
containers | false | If present, print usage of containers within a pod. | |
field-selector | Selector (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-headers | false | If present, print output without headers. | |
selector | l | Selector (label query) to filter on, supports ‘=’, ‘==’, and ‘!=’.(e.g. -l key1=value1,key2=value2) | |
sort-by | If non-empty, sort pods list using specified field. The field can be either ‘cpu’ or ‘memory’. | ||
use-protocol-buffers | true | Enables using protocol-buffers to access Metrics API. |