kx top
Lists Pod or Node CPU and memory usage with kubectl top, assigns indexes, and shows CPU%/MEM% — computed against each Pod’s limits for Pods, native to kubectl for Nodes.
A --sort sorts the table kx draws by its own columns, before numbering it, so row 1 is the first sorted row: name the columns separated by commas, as the header reads them, with a leading - to sort one from largest down. CPU and MEMORY sort as quantities and CPU% and MEM% as percentages, ties keep kubectl’s order, and a Pod with no limit sorts last either way. Another cluster’s listing — --context, --kubeconfig — prints kubectl’s own table, which kx never adds its percentage columns to: name ‘cpu’ or ‘memory’ there for Pods, and kubectl’s own ‘cpu%’ or ‘memory%’ for Nodes. kubectl’s own --sort-by still takes ‘cpu’ or ‘memory’, and applies first.
A --limit keeps the first N rows, after --match narrows them and --sort orders them and before they are numbered, so --sort age --limit 5 is the five newest numbered 1 to 5, and an index past them names nothing. The caption counts the rows kept against the rows there were.
A flag kx doesn’t know is refused; put it after -- to pass it through to kubectl.
Usage
kx top [OPTIONS] [resource] [kubectl flags]Arguments
| Argument | Description |
|---|---|
[resource] | ‘pods’ (the default) or ’nodes’ |
Options
| Option | Description |
|---|---|
-A, --all-namespaces | List Pods across every namespace; each row is indexed and carries its own namespace. Not for Nodes, which are not in a namespace |
--html | Render the listing as HTML and serve it in a browser |
--json | Print the listing as JSON instead of a table |
--limit int | Keep the first N rows, after --match and --sort and before indexing |
-m, --match string | Match by name (substring, case-insensitive) |
-n, --namespace string | Namespace to list Pods from; defaults to the current namespace. Not for Nodes, which are not in a namespace |
--no-headers | Leave out the header row; kx can’t number a table without one |
--no-limits | Skip the CPU%/MEM% columns (one fewer kubectl call) |
--no-open | Serve the HTML report without opening a browser |
--out string | Write the HTML report to this file instead of serving it in a browser |
--port int | Port to serve the HTML report on; 0 picks a free one |
--sort string | Sort by the columns shown, before indexing: ‘-mem%,-cpu%’ sorts by MEM% from most to least, then by CPU% |
Passthrough options
| Option | Description |
|---|---|
--containers | If present, print usage of containers within a pod. |
--field-selector string | 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. |
-l, --selector string | Selector (label query) to filter on, supports ‘=’, ‘==’, ‘!=’, ‘in’, ’notin’.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. |
--show-capacity | Print node resources based on Capacity instead of Allocatable(default) of the nodes. |
--show-swap | Show swap memory for the Pods or Nodes listed. |
--sort-by string | Sort Pods or Nodes by ‘cpu’ or ‘memory’. |
--sum | Print the sum of the resource usage |
--use-protocol-buffers | Enables using protocol-buffers to access Metrics API. |
… | kubectl’s global flags too: --context, --kubeconfig, --as and the rest; kubectl options lists them |
Global options
| Option | Description |
|---|---|
--no-color | Disable styled output |
-h, --help | Show this message and exit |
Examples
kx top
kx top nodes
kx top -m web
kx top --no-limits
kx top --html
kx top --json
kx top --out top.html
kx top --sort -mem%,-cpu%
kx top --sort -mem% --limit 10
kx top nodes --sort -cpu%
kx top --sort-by=memory