Skip to content

Commit 2e1357f

Browse files
committed
docs: update and rework README & SKILL
1 parent ecef17a commit 2e1357f

4 files changed

Lines changed: 152 additions & 106 deletions

File tree

README.md

Lines changed: 107 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,93 @@
11
# kubectl-view-allocations
22

3-
[![Crates.io](https://img.shields.io/crates/l/kubectl-view-allocations.svg)](http://creativecommons.org/publicdomain/zero/1.0/)
3+
[![license](https://img.shields.io/crates/l/kubectl-view-allocations.svg)](http://creativecommons.org/publicdomain/zero/1.0/)
44
[![Crates.io](https://img.shields.io/crates/v/kubectl-view-allocations.svg)](https://crates.io/crates/kubectl-view-allocations)
5-
6-
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
5+
[![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
76
[![Actions Status](https://github.com/davidB/kubectl-view-allocations/workflows/ci-flow/badge.svg)](https://github.com/davidB/kubectl-view-allocations/actions)
87
[![Documentation](https://docs.rs/kubectl-view-allocations/badge.svg)](https://docs.rs/kubectl-view-allocations/)
9-
108
[![Crates.io](https://img.shields.io/crates/d/kubectl-view-allocations.svg)](https://crates.io/crates/kubectl-view-allocations)
119
![GitHub All Releases](https://img.shields.io/github/downloads/davidB/kubectl-view-allocations/total.svg)
1210

13-
`kubectl` plugin lists allocations for resources (cpu, memory, gpu,...) as defined into the manifest of nodes and running pods. It doesn't list usage like `kubectl top`. It can provide result grouped by namespaces, nodes, pods and filtered by resources'name.
11+
`kubectl` plugin for visualizing resource allocations across your cluster. Key differentiators:
1412

15-
Columns displayed :
13+
- **All resources** — cpu, memory, gpu, and any custom resource; not limited to cpu/memory like most tools
14+
- **Tree view** — group and aggregate by resource, node, namespace, or pod in any combination via `-g`
15+
- **Full picture** — requested, limit, allocatable, free, and optionally live utilization (`-u`, requires metrics-server)
1616

17-
- `Requested` : Quantity of resources requested by the container in the pod's manifest. It's the sum group by pod, namespace, node where container is running. With percentage of resources requested over what is allocatable in the group.
18-
- `Limit` : Quantity of resources max (limit) requestable by the container in the pod's manifest. It's the sum group by pod, namespace, node where container is running. With percentage of resources max / limit over what is allocatable in the group.
19-
- `Allocatable` : Allocatable resources defined (or detected) on nodes.
20-
- `Free` : `Allocatable - max (Limit, Requested)` (by default, see options `--used-mode`)
21-
- `Utilization` : Quantity of resources (cpu & memory only) used as reported by Metrics API. It's disable by default, [metrics-server](https://github.com/kubernetes-incubator/metrics-server) is optional and should be setup into the cluster.
17+
```sh
18+
kubectl view-allocations
19+
```
2220

23-
![screenshot](./Screenshot-20260606_1213.png)
21+
> **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](#filter-by-node-taints).
2422
25-
## Install
23+
## Table of Contents
2624

27-
### Via download binary
25+
- [Output Columns](#output-columns)
26+
- [Install](#install) — krew · mise · binary · cargo
27+
- [Usage](#usage)
28+
- [Overview only](#overview-only)
29+
- [Show GPU allocation](#show-gpu-allocation)
30+
- [Show utilization](#show-utilization)
31+
- [Group by namespaces](#group-by-namespaces)
32+
- [Show as CSV](#show-as-csv)
33+
- [Filter by node taints](#filter-by-node-taints)
34+
- [Full option reference](#full-option-reference)
35+
- [Alternatives](#alternatives)
2836

29-
Download from [github's release](https://github.com/davidB/kubectl-view-allocations/releases/latest) or use script
37+
## Output Columns
3038

31-
```sh
32-
curl https://raw.githubusercontent.com/davidB/kubectl-view-allocations/master/scripts/getLatest.sh | bash
33-
```
39+
| Column | Description |
40+
|---|---|
41+
| `Requested` | Resources requested by containers in pod manifests, summed by pod/namespace/node. Includes percentage of the group's allocatable total. |
42+
| `Limit` | Max resources (limit) set in pod manifests, summed by pod/namespace/node. Includes percentage of the group's allocatable total. |
43+
| `Allocatable` | Allocatable resources defined (or detected) on nodes. |
44+
| `Free` | `Allocatable - max(Limit, Requested)` by default — see `--used-mode` to change this. |
45+
| `Utilization` | Actual cpu/memory usage from the Metrics API. Disabled by default; requires [metrics-server](https://github.com/kubernetes-incubator/metrics-server) on the cluster. |
46+
47+
![screenshot](./Screenshot-20260606_1213.png)
3448

35-
### Via krew (kubectl plugin manager)
49+
## Install
3650

37-
[Krew – kubectl plugin manager](https://krew.sigs.k8s.io/)
51+
**Recommended:** [krew](https://krew.sigs.k8s.io/) is the easiest way to install and keep the plugin up to date.
3852

53+
**krew**
3954
```sh
4055
kubectl krew install view-allocations
4156
```
4257

43-
### Via cargo
44-
58+
**mise** (GitHub releases backend)
4559
```sh
46-
cargo install kubectl-view-allocations
60+
mise use -g github:davidB/kubectl-view-allocations
4761
```
4862

49-
### As an AI coding skill
50-
51-
If your AI coding tool supports [skills.sh](https://skills.sh), install the
52-
`kubectl-view-allocations` skill with:
53-
63+
**binary** — download from [GitHub releases](https://github.com/davidB/kubectl-view-allocations/releases/latest) or via script:
5464
```sh
55-
npx skills add davidB/kubectl-view-allocations
65+
curl https://raw.githubusercontent.com/davidB/kubectl-view-allocations/master/scripts/getLatest.sh | bash
5666
```
5767

58-
This installs the assistant workflow for using `kubectl view-allocations`; it
59-
does not install the `kubectl-view-allocations` binary itself.
60-
61-
### As lib in Cargo.toml
62-
63-
If you want to embed some function or struct of the plugin into an other rust code:
64-
65-
```toml
66-
[dependencies]
67-
kubectl-view-allocations = { version = "0.14", default-features = false }
68-
69-
[features]
70-
default = ["k8s-openapi/v1_20"]
68+
**cargo**
69+
```sh
70+
cargo install kubectl-view-allocations
7171
```
7272

7373
## Usage
7474

75-
### Show help
76-
77-
```sh
78-
> kubectl-view-allocations -h
79-
kubectl plugin to list allocations (cpu, memory, gpu,...) X (utilization, requested, limit, allocatable,...)
75+
All examples use `kubectl-view-allocations` directly; if installed via krew, substitute `kubectl view-allocations`.
8076

81-
Usage: kubectl-view-allocations [OPTIONS]
77+
### Overview only
8278

83-
Options:
84-
--kubeconfig <KUBECONFIG>
85-
Path to the kubeconfig file to use for requests to kubernetes cluster
86-
--context <CONTEXT>
87-
The name of the kubeconfig context to use
88-
-n, --namespace <NAMESPACE>...
89-
Filter pods by namespace(s), by default pods in all namespaces are listed (comma separated list or multiple calls)
90-
-l, --selector <SELECTOR>
91-
Show only nodes match this label selector
92-
--ignore-taints [<IGNORE_TAINTS>...]
93-
Ignore nodes with specific taints; when not specified, only nodes without taints are shown; when used without values, show all nodes (comma-separated list)
94-
-u, --utilization
95-
Force to retrieve utilization (for cpu and memory), requires having metrics-server https://github.com/kubernetes-sigs/metrics-server
96-
-z, --show-zero
97-
Show lines with zero requested AND zero limit AND zero allocatable, OR pods with unset requested AND limit for `cpu` and `memory`
98-
--used-mode <USED_MODE>
99-
The way to compute the `used` part for free (`allocatable - used`) [default: max-request-limit] [possible values: max-request-limit, only-request]
100-
--precheck
101-
Pre-check access and refresh token on kubeconfig by running `kubectl cluster-info`
102-
--accept-invalid-certs
103-
Accept invalid certificates (dangerous)
104-
-r, --resource-name <RESOURCE_NAME>...
105-
Filter resources shown by name(s), by default all resources are listed (comma separated list or multiple calls)
106-
-g, --group-by <GROUP_BY>...
107-
Group information in a hierarchical manner; defaults to `-g resource,node,pod` (comma-separated list or multiple calls) [possible values: resource, node, pod, namespace]
108-
-o, --output <OUTPUT>
109-
Output format [default: table] [possible values: table, csv]
110-
-s, --sort <SORT>
111-
Sort rows by column(s), SQL-like syntax: 'col [ASC|DESC]' (comma-separated). Valid columns: usage/utilization, requested, limits/limit, allocatable, free, name. Direction is optional (default ASC). name ASC is always the implicit final tiebreaker [default: "usage DESC, requested DESC, limits DESC, name ASC"]
112-
-h, --help
113-
Print help
114-
-V, --version
115-
Print version
79+
```sh
80+
> kubectl-view-allocations -g resource
11681

117-
https://github.com/davidB/kubectl-view-allocations
82+
Resource Requested Limit Allocatable Free
83+
cpu (21%) 56.7 (65%) 176.1 272.0 95.9
84+
ephemeral-storage (0%) __ (0%) __ 38.4T 38.4T
85+
memory (8%) 52.7Gi (15%) 101.3Gi 675.6Gi 574.3Gi
86+
nvidia.com/gpu (71%) 10.0 (71%) 10.0 14.0 4.0
87+
pods (9%) 147.0 (9%) 147.0 1.6k 1.5k
11888
```
11989

120-
### Show gpu allocation
90+
### Show GPU allocation
12191

12292
```sh
12393

@@ -139,23 +109,10 @@ https://github.com/davidB/kubectl-view-allocations
139109
└─ fah-gpu-cpu-x7zfb 2.0 2.0 __ __
140110
```
141111

142-
### Overview only
143-
144-
```sh
145-
> kubectl-view-allocations -g resource
146-
147-
Resource Requested Limit Allocatable Free
148-
cpu (21%) 56.7 (65%) 176.1 272.0 95.9
149-
ephemeral-storage (0%) __ (0%) __ 38.4T 38.4T
150-
memory (8%) 52.7Gi (15%) 101.3Gi 675.6Gi 574.3Gi
151-
nvidia.com/gpu (71%) 10.0 (71%) 10.0 14.0 4.0
152-
pods (9%) 147.0 (9%) 147.0 1.6k 1.5k
153-
```
154-
155112
### Show utilization
156113

157-
- Utilization information are retrieve from [metrics-server](https://github.com/kubernetes-incubator/metrics-server) (should be setup on your cluster).
158-
- Only report cpu and memory utilization
114+
- Utilization information are retrieved from [metrics-server](https://github.com/kubernetes-incubator/metrics-server) (should be setup on your cluster).
115+
- Only reports cpu and memory utilization.
159116

160117
```sh
161118
> kubectl-view-allocations -u
@@ -206,9 +163,9 @@ https://github.com/davidB/kubectl-view-allocations
206163
└─ kube-system 5.0 5.0 __ __
207164
```
208165

209-
### Show as csv
166+
### Show as CSV
210167

211-
In this case value as expanded as float (with 2 decimal)
168+
Values are expanded as floats (with 2 decimal places).
212169

213170
```sh
214171
kubectl-view-allocations -o csv
@@ -228,7 +185,7 @@ Date,Kind,resource,node,pod,Requested,%Requested,Limit,%Limit,Allocatable,Free
228185
...
229186
```
230187

231-
It can be combined with "group-by" options.
188+
Can be combined with `--group-by`:
232189

233190
```sh
234191
kubectl-view-allocations -g resource -o csv
@@ -272,6 +229,51 @@ kubectl-view-allocations -l environment=production --ignore-taints dedicated=dat
272229
- **Include control-plane**: Use `--ignore-taints node-role.kubernetes.io/control-plane` to see workload + control-plane nodes
273230
- **Include specialized nodes**: Use `--ignore-taints dedicated,workload` to include dedicated or workload-specific nodes alongside regular workload nodes
274231

232+
### Full option reference
233+
234+
```sh
235+
> kubectl-view-allocations -h
236+
kubectl plugin to list allocations (cpu, memory, gpu,...) X (utilization, requested, limit, allocatable,...)
237+
238+
Usage: kubectl-view-allocations [OPTIONS]
239+
240+
Options:
241+
--kubeconfig <KUBECONFIG>
242+
Path to the kubeconfig file to use for requests to kubernetes cluster
243+
--context <CONTEXT>
244+
The name of the kubeconfig context to use
245+
-n, --namespace <NAMESPACE>...
246+
Filter pods by namespace(s), by default pods in all namespaces are listed (comma separated list or multiple calls)
247+
-l, --selector <SELECTOR>
248+
Show only nodes match this label selector
249+
--ignore-taints [<IGNORE_TAINTS>...]
250+
Ignore nodes with specific taints; when not specified, only nodes without taints are shown; when used without values, show all nodes (comma-separated list)
251+
-u, --utilization
252+
Force to retrieve utilization (for cpu and memory), requires having metrics-server https://github.com/kubernetes-sigs/metrics-server
253+
-z, --show-zero
254+
Show lines with zero requested AND zero limit AND zero allocatable, OR pods with unset requested AND limit for `cpu` and `memory`
255+
--used-mode <USED_MODE>
256+
The way to compute the `used` part for free (`allocatable - used`) [default: max-request-limit] [possible values: max-request-limit, only-request]
257+
--precheck
258+
Pre-check access and refresh token on kubeconfig by running `kubectl cluster-info`
259+
--accept-invalid-certs
260+
Accept invalid certificates (dangerous)
261+
-r, --resource-name <RESOURCE_NAME>...
262+
Filter resources shown by name(s), by default all resources are listed (comma separated list or multiple calls)
263+
-g, --group-by <GROUP_BY>...
264+
Group information in a hierarchical manner; defaults to `-g resource,node,pod` (comma-separated list or multiple calls) [possible values: resource, node, pod, namespace]
265+
-o, --output <OUTPUT>
266+
Output format [default: table] [possible values: table, csv]
267+
-s, --sort <SORT>
268+
Sort rows by column(s), SQL-like syntax: 'col [ASC|DESC]' (comma-separated). Valid columns: usage/utilization, requested, limits/limit, allocatable, free, name. Direction is optional (default ASC). name ASC is always the implicit final tiebreaker [default: "usage DESC, requested DESC, limits DESC, name ASC"]
269+
-h, --help
270+
Print help
271+
-V, --version
272+
Print version
273+
274+
https://github.com/davidB/kubectl-view-allocations
275+
```
276+
275277
## Alternatives & Similars
276278

277279
- see the discussion [Need simple kubectl command to see cluster resource usage · Issue #17512 · kubernetes/kubernetes](https://github.com/kubernetes/kubernetes/issues/17512)
@@ -283,3 +285,7 @@ kubectl-view-allocations -l environment=production --ignore-taints dedicated=dat
283285
- For CPU & Memory utilization only
284286
- `kubectl top pods`
285287
- [LeastAuthority/kubetop: A top(1)-like tool for Kubernetes.](https://github.com/LeastAuthority/kubetop)
288+
- As a Rust library
289+
- [kdash-rs/kdash](https://crates.io/crates/kdash) embeds `kubectl-view-allocations` as a dependency. To use it in your own Rust project: `kubectl-view-allocations = { version = "1.1.0", default-features = false }` (add `k8s-openapi/vX_YY` to your features).
290+
- Via AI assistant (no binary needed)
291+
- If your AI coding tool supports [skills.sh](https://skills.sh), install the assistant workflow with `npx skills add davidB/kubectl-view-allocations`. This lets your AI agent run and interpret `kubectl view-allocations` for you — it does not install the binary.

skills/kubectl-view-allocations/SKILL.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
---
22
name: kubectl-view-allocations
3-
description: "Use when inspecting Kubernetes resource allocation with kubectl view-allocations. For allocation questions, use kubectl view-allocations first and do not replace it with native kubectl get/describe/top/jsonpath queries. Covers cluster/node/namespace/pod requests, limits, allocatable, free capacity, GPU or custom resources, taint-filtered node views, CSV exports, metrics-server utilization via kubectl view-allocations -u, kubeconfig/context access checks, and allocation-focused troubleshooting. Trigger for CPU, memory, GPU, pod capacity, overcommit, missing requests/limits, tainted nodes, or comparing requested/limit/utilization data in a Kubernetes cluster."
3+
description: "Use when inspecting Kubernetes resource allocation with kubectl view-allocations. For allocation questions, use kubectl view-allocations first and do not replace it with native kubectl get/describe/top/jsonpath queries. Covers cluster/node/namespace/pod requests, limits, allocatable, free capacity, ALL resources including GPU and custom resources (not just CPU/memory), taint-filtered node views, tree-view grouping via -g, multi-column sort via --sort, CSV exports, metrics-server utilization via kubectl view-allocations -u, kubeconfig/context access checks, and allocation-focused troubleshooting. Trigger for CPU, memory, GPU, pod capacity, overcommit, missing requests/limits, tainted nodes, or comparing requested/limit/utilization data in a Kubernetes cluster. WARNING: default output excludes tainted nodes — results may be empty or partial on clusters where all nodes have taints (e.g. control-plane-only, GPU, dedicated workload nodes)."
44
---
55

66
# Kubectl View Allocations
77

88
Use `kubectl view-allocations` as the required first tool for this repository's allocation workflow. Do not answer allocation questions by reconstructing the same data with native `kubectl get`, `kubectl describe`, `kubectl top`, JSONPath, or ad hoc scripts unless `kubectl view-allocations` cannot run and the user accepts a fallback.
99

10-
`kubectl view-allocations` reports Kubernetes allocations from manifests and node allocatable resources; it is not a replacement for `kubectl top`, except when `-u/--utilization` is explicitly requested and Metrics API is available.
10+
`kubectl view-allocations` reports Kubernetes allocations from manifests and node allocatable resources. Key differentiators over `kubectl top` and similar tools:
11+
12+
- **All resources**: cpu, memory, GPU, and any custom resource — not limited to cpu/memory
13+
- **Tree view**: group and aggregate by resource, node, namespace, or pod in any combination via `-g`
14+
- **Live utilization**: optional via `-u` (requires metrics-server), same as `kubectl top` but richer
15+
16+
> **Default taint filtering**: only nodes *without* taints are shown. On clusters where all nodes carry taints (control-plane-only, GPU nodes, dedicated workloads), the output may be empty or partial. Use `--ignore-taints` to include tainted nodes.
1117
1218
## Workflow
1319

@@ -54,6 +60,12 @@ kubectl view-allocations -r gpu
5460
kubectl view-allocations --ignore-taints -g resource,node
5561
kubectl view-allocations -u -r cpu,memory
5662
kubectl view-allocations -o csv -g resource,node,pod
63+
# Sort: show most-requested resources first (default)
64+
kubectl view-allocations -s "requested DESC"
65+
# Sort by free capacity ascending (find most constrained nodes first)
66+
kubectl view-allocations -g resource,node -s "free ASC"
67+
# Multi-column sort
68+
kubectl view-allocations -s "usage DESC, requested DESC"
5769
```
5870

5971
Add `--context CONTEXT` and `--kubeconfig PATH` when the user names a cluster or config file. Use `--precheck` when kube auth tokens may need refreshing because it runs `kubectl cluster-info` first.
@@ -69,7 +81,9 @@ Read `references/command-cookbook.md` for command recipes, interpretation notes,
6981
- `Utilization`: live CPU/memory usage from Metrics API, shown only with `-u`.
7082
- `__`: value is absent or not meaningful at that grouping level, not necessarily zero.
7183

72-
Default grouping is `resource,node,pod`; `resource` is always prepended when omitted. Default node filtering excludes tainted nodes. Use `--ignore-taints` with no value to include all nodes, or with taint keys/key-value pairs to include specific tainted nodes.
84+
Default grouping is `resource,node,pod`; `resource` is always prepended when omitted. Default node filtering excludes tainted nodes — **if output is empty or missing nodes, try `--ignore-taints`**. Use `--ignore-taints` with no value to include all nodes, or with taint keys/key-value pairs to include specific tainted nodes.
85+
86+
`--sort` / `-s` accepts SQL-like syntax: `col [ASC|DESC]`, comma-separated for multi-column. Valid columns: `usage`/`utilization`, `requested`, `limits`/`limit`, `allocatable`, `free`, `name`. Default: `"usage DESC, requested DESC, limits DESC, name ASC"`. Sort applies within sibling groups at each tree level.
7387

7488
## Safety
7589

0 commit comments

Comments
 (0)