LinuxCommandLibrary

kube-capacity

Show cluster resource requests, limits, and utilization

TLDR

List nodes including the total CPU and Memory resource requests and limits

$ kube-capacity
copy

Include pods
$ kube-capacity [[-p|--pods]]
copy

Include utilization
$ kube-capacity [[-u|--util]]
copy

SYNOPSIS

kube-capacity [OPTIONS]

PARAMETERS

-C, --columns strings
    Comma-separated list of columns: cpu,memory,pods,requests,limits,ephemeral-storage. Default: all.

--context string
    Kubeconfig context to use.

-h, --help
    Show help.

--insecure-skip-tls-verify
    Skip TLS certificate verification (insecure).

--kubeconfig string
    Path to kubeconfig file.

--limit-bytes int
    Memory column limit in bytes (default 100).

-n, --namespace string
    Filter pods by namespace (default: all).

--node strings
    Specific node names (default: all nodes).

--sort-by string
    Sort by column: cpu,memory,pods,requests,limits (default: cpu).

--totals
    Add totals row at bottom.

--version
    Print version.

DESCRIPTION

kube-capacity is a powerful command-line tool designed for Kubernetes administrators to analyze and report on the resource capacity and current usage across cluster nodes. It generates a detailed table displaying allocatable resources such as CPU, memory, pods, requests, limits, and optionally ephemeral-storage for each node.

This tool helps in capacity planning by showing remaining headroom, identifying overcommitted nodes, and simulating 'what-if' scenarios for scaling. It aggregates pod resource requests and limits to compute utilization percentages, making it easier to spot bottlenecks or underutilized resources.

By connecting to the Kubernetes API via kubeconfig, kube-capacity fetches real-time data without needing additional plugins. It's lightweight, fast, and supports customization like sorting, filtering by namespace or specific nodes, and configurable output columns. Ideal for daily monitoring, dashboards, or scripts in CI/CD pipelines.

Unlike kubectl top, which shows metrics from heapster/metrics-server, kube-capacity focuses on static capacity and requested resources, providing a complementary view for proactive management.

CAVEATS

Requires valid kubeconfig and cluster read access to nodes/pods. Does not use metrics-server; shows requests/limits only, not actual usage.

INSTALLATION

Download binaries from GitHub releases or go install github.com/robscott/kube-capacity@latest.

EXAMPLE

kube-capacity --columns cpu,memory --sort-by memory --totals
Shows CPU/memory sorted by memory with totals.

HISTORY

Developed by Rob Scott starting in 2018 as an open-source tool on GitHub (robscott/kube-capacity). Actively maintained with releases supporting recent Kubernetes versions.

SEE ALSO

kubectl(1), kubectl top node(1), kubectl describe node(1)

Copied to clipboard