MCPcopy Index your code
hub / github.com/davidB/kubectl-view-allocations

github.com/davidB/kubectl-view-allocations @3.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.0.1 ↗ · + Follow
118 symbols 230 edges 9 files 3 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

kubectl-view-allocations

license Crates.io Project Status: Active Actions Status Documentation Crates.io GitHub All Releases

kubectl plugin for visualizing resource allocations across your cluster. Key differentiators:

  • All resources — cpu, memory, gpu, and any custom resource; not limited to cpu/memory like most tools
  • Tree view — group and aggregate by resource, node, namespace, or pod in any combination via -g
  • Full picture — requested, limit, allocatable, free, and optionally live utilization (-u, requires metrics-server)
kubectl view-allocations -u

screenshot

Note: By default only nodes without taints are shown. If results look empty or incomplete, use --ignore-taints to include control-plane or tainted nodes — see Filter by Node Taints.

Column Description
Requested Resources requested by containers in pod manifests, summed by pod/namespace/node. Includes percentage of the group's allocatable total.
Limit Max resources (limit) set in pod manifests, summed by pod/namespace/node. Includes percentage of the group's allocatable total.
Allocatable Allocatable resources defined (or detected) on nodes.
Free Allocatable - max(Limit, Requested) by default — see --used-mode to change this.
Utilization Actual cpu/memory usage from the Metrics API. Disabled by default; requires metrics-server on the cluster.

Table of Contents

Install

Recommended: krew is the easiest way to install and keep the plugin up to date.

krew

kubectl krew install view-allocations

mise (GitHub releases backend)

mise use -g github:davidB/kubectl-view-allocations

binary — download from GitHub releases or via script:

curl https://raw.githubusercontent.com/davidB/kubectl-view-allocations/master/scripts/getLatest.sh | bash

cargo

cargo install kubectl-view-allocations

Usage

All examples use kubectl-view-allocations directly; if installed via krew, substitute kubectl view-allocations.

Overview only

> kubectl-view-allocations -g resource

 Resource              Requested          Limit  Allocatable     Free
  cpu                 (21%) 56.7    (65%) 176.1        272.0     95.9
  ephemeral-storage     (0%)  __       (0%)  __        38.4T    38.4T
  memory             (8%) 52.7Gi  (15%) 101.3Gi      675.6Gi  574.3Gi
  nvidia.com/gpu      (71%) 10.0     (71%) 10.0         14.0      4.0
  pods                (9%) 147.0     (9%) 147.0         1.6k     1.5k

Show GPU allocation


> kubectl-view-allocations -r gpu

 Resource                   Requested       Limit  Allocatable  Free
  nvidia.com/gpu           (71%) 10.0  (71%) 10.0         14.0   4.0
  ├─ node-gpu1               (0%)  __    (0%)  __          2.0   2.0
  ├─ node-gpu2               (0%)  __    (0%)  __          2.0   2.0
  ├─ node-gpu3             (100%) 2.0  (100%) 2.0          2.0    __
  │  └─ fah-gpu-cpu-d29sc         2.0         2.0           __    __
  ├─ node-gpu4             (100%) 2.0  (100%) 2.0          2.0    __
  │  └─ fah-gpu-cpu-hkg59         2.0         2.0           __    __
  ├─ node-gpu5             (100%) 2.0  (100%) 2.0          2.0    __
  │  └─ fah-gpu-cpu-nw9fc         2.0         2.0           __    __
  ├─ node-gpu6             (100%) 2.0  (100%) 2.0          2.0    __
  │  └─ fah-gpu-cpu-gtwsf         2.0         2.0           __    __
  └─ node-gpu7             (100%) 2.0  (100%) 2.0          2.0    __
     └─ fah-gpu-cpu-x7zfb         2.0         2.0           __    __

Show utilization

  • Utilization information are retrieved from metrics-server (should be setup on your cluster).
  • Only reports cpu and memory utilization.
> kubectl-view-allocations -u

 Resource                                                 Utilization     Requested         Limit  Allocatable    Free
  cpu                                                      (0%) 31.0m   (6%) 950.0m   (1%) 100.0m         16.0    15.1
  └─ demo-kube-control-plane                               (0%) 31.0m   (6%) 950.0m   (1%) 100.0m         16.0    15.1
     ├─ kube-apiserver-demo-kube-control-plane                  13.0m        250.0m            __           __      __
     ├─ etcd-demo-kube-control-plane                             6.0m        100.0m            __           __      __
     ├─ kube-controller-manager-demo-kube-control-plane          4.0m        200.0m            __           __      __
     ├─ metrics-server-7c47898747-664mk                          2.0m            __            __           __      __
     ├─ kube-proxy-mnv5g                                         1.0m            __            __           __      __
     ├─ local-path-provisioner-6bc4bddd6b-8q2bk                  1.0m            __            __           __      __
     ├─ coredns-5d78c9869d-955fw                                 1.0m        100.0m            __           __      __
     ├─ coredns-5d78c9869d-9jcrv                                 1.0m        100.0m            __           __      __
     ├─ kube-scheduler-demo-kube-control-plane                   1.0m        100.0m            __           __      __
     └─ kindnet-fz7fb                                            1.0m        100.0m        100.0m           __      __
  ephemeral-storage                                                __            __            __      468.4Gi      __
  └─ demo-kube-control-plane                                       __            __            __      468.4Gi      __
  memory                                                 (2%) 487.1Mi  (1%) 290.0Mi  (1%) 390.0Mi       31.3Gi  30.9Gi
  └─ demo-kube-control-plane                             (2%) 487.1Mi  (1%) 290.0Mi  (1%) 390.0Mi       31.3Gi  30.9Gi
     ├─ kube-apiserver-demo-kube-control-plane                296.8Mi            __            __           __      __
     ├─ kube-controller-manager-demo-kube-control-plane        51.1Mi            __            __           __      __
     ├─ etcd-demo-kube-control-plane                           32.4Mi       100.0Mi            __           __      __
     ├─ kube-scheduler-demo-kube-control-plane                 25.2Mi            __            __           __      __
     ├─ kube-proxy-mnv5g                                       17.2Mi            __            __           __      __
     ├─ metrics-server-7c47898747-664mk                        16.6Mi            __            __           __      __
     ├─ coredns-5d78c9869d-955fw                               14.9Mi        70.0Mi       170.0Mi           __      __
     ├─ coredns-5d78c9869d-9jcrv                               14.0Mi        70.0Mi       170.0Mi           __      __
     ├─ kindnet-fz7fb                                          10.2Mi        50.0Mi        50.0Mi           __      __
     └─ local-path-provisioner-6bc4bddd6b-8q2bk                 8.6Mi            __            __           __      __
  pods                                                             __     (9%) 10.0     (9%) 10.0        110.0   100.0
  └─ demo-kube-control-plane                                       __     (9%) 10.0     (9%) 10.0        110.0   100.0

Group by namespaces

> kubectl-view-allocations -g namespace

 Resource               Requested         Limit  Allocatable   Free
  cpu                (10%) 200.0m            __          2.0    1.8
  └─ kube-system           200.0m            __           __     __
  ephemeral-storage            __            __        99.8G     __
  memory             (2%) 140.0Mi  (3%) 170.0Mi        5.8Gi  5.6Gi
  └─ kube-system          140.0Mi       170.0Mi           __     __
  pods                   (5%) 5.0      (5%) 5.0        110.0  105.0
  └─ kube-system              5.0           5.0           __     __

Show as CSV

Values are expanded as floats (with 2 decimal places).

kubectl-view-allocations -o csv
Date,Kind,resource,node,pod,Requested,%Requested,Limit,%Limit,Allocatable,Free
2020-08-19T19:12:48.326605746+00:00,resource,cpu,,,59.94,22%,106.10,39%,272.00,165.90
2020-08-19T19:12:48.326605746+00:00,node,cpu,node-gpu1,,2.31,19%,4.47,37%,12.00,7.53
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu1,yyy-b8bd56fbd-5x8vq,1.00,,2.00,,,
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu1,kube-flannel-ds-amd64-7dz9z,0.10,,0.10,,,
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu1,node-exporter-gpu-b4w7s,0.11,,0.22,,,
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu1,xxx-backend-7d84544458-46qnh,1.00,,2.00,,,
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu1,weave-scope-agent-bbdnz,0.10,,0.15,,,
2020-08-19T19:12:48.326605746+00:00,node,cpu,node-gpu2,,0.31,1%,0.47,2%,24.00,23.53
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu2,kube-flannel-ds-amd64-b5b4v,0.10,,0.10,,,
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu2,node-exporter-gpu-796jz,0.11,,0.22,,,
2020-08-19T19:12:48.326605746+00:00,pod,cpu,node-gpu2,weave-scope-agent-8rhnd,0.10,,0.15,,,
2020-08-19T19:12:48.326605746+00:00,node,cpu,node-gpu3,,3.41,11%,6.67,21%,32.00,25.33
...

Can be combined with --group-by:

kubectl-view-allocations -g resource -o csv
Date,Kind,resource,Requested,%Requested,Limit,%Limit,Allocatable,Free
2020-08-19T19:11:49.630864028+00:00,resource,cpu,59.94,22%,106.10,39%,272.00,165.90
2020-08-19T19:11:49.630864028+00:00,resource,ephemeral-storage,0.00,0%,0.00,0%,34462898618662.00,34462898618662.00
2020-08-19T19:11:49.630864028+00:00,resource,hugepages-1Gi,0.00,,0.00,,,
2020-08-19T19:11:49.630864028+00:00,resource,hugepages-2Mi,0.00,,0.00,,,
2020-08-19T19:11:49.630864028+00:00,resource,memory,69063409664.00,10%,224684670976.00,31%,722318667776.00,497633996800.00
2020-08-19T19:11:49.630864028+00:00,resource,nvidia.com/gpu,3.00,27%,3.00,27%,11.00,8.00
2020-08-19T19:11:49.630864028+00:00,resource,pods,0.00,0%,0.00,0%,1540.00,1540.00

Filter by Node Taints

By default, kubectl-view-allocations only shows nodes without taints (workload nodes). The --ignore-taints option allows you to control which nodes are included based on their taints.

# Default: Only show nodes without taints (workload nodes)
kubectl-view-allocations

# Ignore all taints and show all nodes (including control-plane)
kubectl-view-allocations --ignore-taints

# Show untainted nodes + nodes with specific taints (ignore these taints)
kubectl-view-allocations --ignore-taints node-role.kubernetes.io/control-plane

# Show untainted nodes + nodes with specific taint key-value pairs
kubectl-view-allocations --ignore-taints dedicated=database

# Ignore multiple taint patterns
kubectl-view-allocations --ignore-taints node-role.kubernetes.io/control-plane,dedicated=database

# Combine with label selector
kubectl-view-allocations -l environment=production --ignore-taints dedicated=database

Use cases: - Default behavior: Show only workload nodes (nodes without taints) for typical application resource allocation - Complete overview: Use --ignore-taints without values to see all nodes in the cluster, including control-plane and specialized nodes - Include control-plane: Use --ignore-taints node-role.kubernetes.io/control-plane to see workload + control-plane nodes - Include specialized nodes: Use --ignore-taints dedicated,workload to include dedicated or workload-specific nodes alongside regular workload nodes

Full option reference

```sh

kubectl-view-allocations -h kubectl plugin to list allocations (cpu, memory, gpu,...) X (utilization, requested, limit, allocatable,...)

Usage: kubectl-view-allocations [OPTIONS]

Options: --kubeconfig Path to the kubeconfig file to use for requests to kubernetes cluster --context The name of the kubeconfig context to use -n, --namespace ... Filter pods by namespace(s), by default pods in all namespaces are listed (comma separated list or multiple calls) -l, --selector

Core symbols most depended-on inside this repo

create_test_node
called by 24
src/lib.rs
parse_sort_spec
called by 13
src/sort.rs
sort_children_recursive
called by 7
src/sort.rs
process_resources
called by 6
src/collect.rs
is_empty
called by 5
src/display.rs
add
called by 5
src/lib.rs
compare_qty
called by 5
src/sort.rs
cmp
called by 4
src/qty.rs

Shape

Function 73
Method 25
Class 12
Enum 8

Languages

Rust100%

Modules by API surface

src/lib.rs52 symbols
src/qty.rs25 symbols
src/collect.rs11 symbols
src/sort.rs9 symbols
src/display.rs7 symbols
src/tree.rs6 symbols
src/metrics.rs5 symbols
src/main.rs2 symbols
examples/pod_api.rs1 symbols

For agents

$ claude mcp add kubectl-view-allocations \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page