kubectl node-resource
is a kubectl plugin that provides insights into Kubernetes node resource allocation (based on pod requests) and actual utilization (based on metrics-server data).
It helps administrators and developers understand how resources are being consumed across their cluster's nodes and node pools.
If you have Krew installed, you can install node-resource
with the following command:
kubectl krew install node-resource
--json
) for easy integration with other tools and scripts.allocation
command. Works well with large clusters.--show-free
) on each node.--show-cpu
, --show-memory
, --show-gpu
, --show-ephemeral-storage
, --show-pod-count
, and --show-host-ports
.This plugin offers two main subcommands:
utilization
: Show actual resource utilization on nodes.allocation
: Show pod resource allocations on nodes.Displays the resource allocation on nodes based on the sum of pod resource requests. It shows each node's allocatable CPU and memory, the sum of CPU and memory requests from pods running on them, and the percentage of allocatable resources requested.
Examples:
Usage Command Show allocation for all nodes, sorted by CPU percentage (default sort).kubectl node-resource allocationShow allocation for nodes with the label
role=worker
, and also display host ports used by containers on these nodes.
kubectl node-resource allocation "role=worker" \ --show-host-portsShow only the summary of allocation for nodes matching the label
pool=high-memory
, hiding the detailed table.
kubectl node-resource allocation "pool=high-memory" \ --summary=onlyShow allocation for a specific node named
node1
, sorted by memory percentage, and include free (allocatable - requested) resources.
kubectl node-resource allocation \ "kubernetes.io/hostname=node1" \ --sort-by=mem-percent \ --show-free
Both allocation
and utilization
commands support flags to control which resource details are displayed:
--show-cpu
: (Default: true
) Show CPU related information (allocatable, requested/used, percentage).--show-memory
: (Default: true
) Show Memory related information (allocatable, requested/used, percentage).The allocation
command additionally supports:
--show-pod-count
: (Default: false
) Show number of Pods on each node and Pod count limits.--show-host-ports
: (Default: false
) Show host ports used by containers on each node.--show-ephemeral-storage
: (Default: false
) Show ephemeral storage allocation details.--show-gpu
: (Default: false
) Show GPU allocation details.--gpu-resource-key
: (Default: "nvidia.com/gpu"
) Specify the resource key for GPU counting (e.g., amd.com/gpu
).These flags allow you to tailor the output to focus on the specific resources you are interested in. For example, to see only memory, ephemeral storage, and GPU (using the default key) for allocations:
kubectl node-resource allocation --show-cpu=false --show-memory --show-ephemeral-storage --show-gpu
For example, to show AMD GPUs, run:
kubectl node-resource allocation --show-gpu --gpu-resource-key=amd.com/gpu
Displays the actual resource utilization of nodes, similar to kubectl top node
. It shows each node's allocatable CPU and memory, the actual CPU and memory currently used, and the percentage of allocatable resources utilized. This command requires the Kubernetes metrics-server to be installed and running in the cluster.
Examples:
Usage Command Show utilization for all nodes, sorted by CPU percentage (default sort).kubectl node-resource utilizationShow utilization for nodes with the label
role=worker
.
kubectl node-resource utilization "role=worker"Show utilization and include a column for free (allocatable - used) resources.
kubectl node-resource utilization \ --show-freeShow utilization for all nodes, sorted by memory percentage, and output in JSON format.
kubectl node-resource utilization \ --sort-by=mem-percent \ --json
This project is licensed under the Apache 2.0 License. See the LICENSE.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4