Skip to content

Commit 637945a

Browse files
committed
docs: update and rework README & SKILL
1 parent ecef17a commit 637945a

4 files changed

Lines changed: 163 additions & 108 deletions

File tree

README.md

Lines changed: 118 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,94 @@
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:
12+
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)
1416

15-
Columns displayed :
17+
```sh
18+
kubectl view-allocations
19+
```
1620

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.
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).
22+
23+
## Table of Contents
24+
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)
36+
- [Sponsors](#sponsors)
37+
38+
## Output Columns
39+
40+
| Column | Description |
41+
|---|---|
42+
| `Requested` | Resources requested by containers in pod manifests, summed by pod/namespace/node. Includes percentage of the group's allocatable total. |
43+
| `Limit` | Max resources (limit) set in pod manifests, summed by pod/namespace/node. Includes percentage of the group's allocatable total. |
44+
| `Allocatable` | Allocatable resources defined (or detected) on nodes. |
45+
| `Free` | `Allocatable - max(Limit, Requested)` by default — see `--used-mode` to change this. |
46+
| `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. |
2247

2348
![screenshot](./Screenshot-20260606_1213.png)
2449

2550
## Install
2651

27-
### Via download binary
28-
29-
Download from [github's release](https://github.com/davidB/kubectl-view-allocations/releases/latest) or use script
30-
31-
```sh
32-
curl https://raw.githubusercontent.com/davidB/kubectl-view-allocations/master/scripts/getLatest.sh | bash
33-
```
34-
35-
### Via krew (kubectl plugin manager)
36-
37-
[Krew – kubectl plugin manager](https://krew.sigs.k8s.io/)
52+
**Recommended:** [krew](https://krew.sigs.k8s.io/) is the easiest way to install and keep the plugin up to date.
3853

54+
**krew**
3955
```sh
4056
kubectl krew install view-allocations
4157
```
4258

43-
### Via cargo
44-
59+
**mise** (GitHub releases backend)
4560
```sh
46-
cargo install kubectl-view-allocations
61+
mise use -g github:davidB/kubectl-view-allocations
4762
```
4863

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-
64+
**binary** — download from [GitHub releases](https://github.com/davidB/kubectl-view-allocations/releases/latest) or via script:
5465
```sh
55-
npx skills add davidB/kubectl-view-allocations
66+
curl https://raw.githubusercontent.com/davidB/kubectl-view-allocations/master/scripts/getLatest.sh | bash
5667
```
5768

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"]
69+
**cargo**
70+
```sh
71+
cargo install kubectl-view-allocations
7172
```
7273

7374
## Usage
7475

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,...)
76+
All examples use `kubectl-view-allocations` directly; if installed via krew, substitute `kubectl view-allocations`.
8077

81-
Usage: kubectl-view-allocations [OPTIONS]
78+
### Overview only
8279

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
80+
```sh
81+
> kubectl-view-allocations -g resource
11682

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

120-
### Show gpu allocation
91+
### Show GPU allocation
12192

12293
```sh
12394

@@ -139,23 +110,10 @@ https://github.com/davidB/kubectl-view-allocations
139110
└─ fah-gpu-cpu-x7zfb 2.0 2.0 __ __
140111
```
141112

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-
155113
### Show utilization
156114

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
115+
- Utilization information are retrieved from [metrics-server](https://github.com/kubernetes-incubator/metrics-server) (should be setup on your cluster).
116+
- Only reports cpu and memory utilization.
159117

160118
```sh
161119
> kubectl-view-allocations -u
@@ -206,9 +164,9 @@ https://github.com/davidB/kubectl-view-allocations
206164
└─ kube-system 5.0 5.0 __ __
207165
```
208166

209-
### Show as csv
167+
### Show as CSV
210168

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

213171
```sh
214172
kubectl-view-allocations -o csv
@@ -228,7 +186,7 @@ Date,Kind,resource,node,pod,Requested,%Requested,Limit,%Limit,Allocatable,Free
228186
...
229187
```
230188

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

233191
```sh
234192
kubectl-view-allocations -g resource -o csv
@@ -272,6 +230,51 @@ kubectl-view-allocations -l environment=production --ignore-taints dedicated=dat
272230
- **Include control-plane**: Use `--ignore-taints node-role.kubernetes.io/control-plane` to see workload + control-plane nodes
273231
- **Include specialized nodes**: Use `--ignore-taints dedicated,workload` to include dedicated or workload-specific nodes alongside regular workload nodes
274232

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

277280
- 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 +286,15 @@ kubectl-view-allocations -l environment=production --ignore-taints dedicated=dat
283286
- For CPU & Memory utilization only
284287
- `kubectl top pods`
285288
- [LeastAuthority/kubetop: A top(1)-like tool for Kubernetes.](https://github.com/LeastAuthority/kubetop)
289+
- As a Rust library
290+
- [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).
291+
- Via AI assistant (no binary needed)
292+
- 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.
293+
294+
## Sponsors
295+
296+
[Alchim312 | CDviz](https://cdviz.dev) — SDLC observability platform built on CDEvents.
297+
298+
Download history (weekly, powered by [CDviz download-history](https://download-history.cdviz.dev)):
299+
300+
![Download History - All Time (Weekly)](https://download-history.cdviz.dev/api/chart/github.com/davidB/kubectl-view-allocations/all.svg?granularity=weekly)

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)