{"id":13451600,"url":"https://github.com/robscott/kube-capacity","last_synced_at":"2025-05-14T12:06:58.523Z","repository":{"id":37663685,"uuid":"168855888","full_name":"robscott/kube-capacity","owner":"robscott","description":"A simple CLI that provides an overview of the resource requests, limits, and utilization in a Kubernetes cluster","archived":false,"fork":false,"pushed_at":"2025-03-29T21:03:13.000Z","size":53539,"stargazers_count":2328,"open_issues_count":38,"forks_count":119,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-10T03:47:13.518Z","etag":null,"topics":["kubernetes","resource-management","utilization"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robscott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-02T17:10:59.000Z","updated_at":"2025-04-09T14:20:38.000Z","dependencies_parsed_at":"2023-02-14T06:01:17.091Z","dependency_job_id":"8f27aab0-61b6-40f6-9d94-17f9875cd2c7","html_url":"https://github.com/robscott/kube-capacity","commit_stats":{"total_commits":99,"total_committers":26,"mean_commits":"3.8076923076923075","dds":0.696969696969697,"last_synced_commit":"f5b77a6707f423809aaa7998ba3ee3e7c568cd2c"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robscott%2Fkube-capacity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robscott%2Fkube-capacity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robscott%2Fkube-capacity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robscott%2Fkube-capacity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robscott","download_url":"https://codeload.github.com/robscott/kube-capacity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140741,"owners_count":22021218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubernetes","resource-management","utilization"],"created_at":"2024-07-31T07:00:56.744Z","updated_at":"2025-05-14T12:06:58.123Z","avatar_url":"https://github.com/robscott.png","language":"Go","funding_links":[],"categories":["Go","Tools and Libraries","Diagnostics \u0026 Troubleshooting","kubernetes","kubectl Plugins","\u003ca name=\"k8s\"\u003e\u003c/a\u003ek8s","Repositories"],"sub_categories":["Monitoring, Alerts, and Visualization","Installing plugins via awesome-kubectl-plugins"],"readme":"# kube-capacity\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/robscott/kube-capacity?v=1)](https://goreportcard.com/report/github.com/robscott/kube-capacity) [![CircleCI](https://circleci.com/gh/robscott/kube-capacity.svg?style=svg)](https://circleci.com/gh/robscott/kube-capacity)\n\nThis is a simple CLI that provides an overview of the resource requests, limits, and utilization in a Kubernetes cluster. It attempts to combine the best parts of the output from `kubectl top` and `kubectl describe` into an easy to use CLI focused on cluster resources.\n\n## Installation\nGo binaries are automatically built with each release by [GoReleaser](https://github.com/goreleaser/goreleaser). These can be accessed on the GitHub [releases page](https://github.com/robscott/kube-capacity/releases) for this project.\n\n### Homebrew\nThis project can be installed with [Homebrew](https://brew.sh/):\n```\nbrew tap robscott/tap\nbrew install robscott/tap/kube-capacity\n```\n\n### Krew\nThis project can be installed with [Krew](https://github.com/GoogleContainerTools/krew):\n\n\u003e **_NOTE:_** If kube-capacity was installed using Krew, use `kubectl resource-capacity` instead of `kube-capacity`.\n\n```\nkubectl krew install resource-capacity\n```\n\n## Usage\nBy default, kube-capacity will output a list of nodes with the total CPU and Memory resource requests and limits for all the pods running on them. For clusters with more than one node, the first line will also include cluster wide totals. That output will look something like this:\n\n```\nkube-capacity\n\nNODE              CPU REQUESTS    CPU LIMITS    MEMORY REQUESTS    MEMORY LIMITS\n*                 560m (28%)      130m (7%)     572Mi (9%)         770Mi (13%)\nexample-node-1    220m (22%)      10m (1%)      192Mi (6%)         360Mi (12%)\nexample-node-2    340m (34%)      120m (12%)    380Mi (13%)        410Mi (14%)\n```\n\n### Including Pods\nFor more detailed output, kube-capacity can include pods in the output. When `-p` or `--pods` are passed to kube-capacity, it will include pod specific output that looks like this:\n\n```\nkube-capacity --pods\n\nNODE              NAMESPACE     POD                   CPU REQUESTS    CPU LIMITS    MEMORY REQUESTS    MEMORY LIMITS\n*                 *             *                     560m (28%)      780m (38%)    572Mi (9%)         770Mi (13%)\n\nexample-node-1    *             *                     220m (22%)      320m (32%)    192Mi (6%)         360Mi (12%)\nexample-node-1    kube-system   metrics-server-lwc6z  100m (10%)      200m (20%)    100Mi (3%)         200Mi (7%)\nexample-node-1    kube-system   coredns-7b5bcb98f8    120m (12%)      120m (12%)    92Mi (3%)          160Mi (5%)\n\nexample-node-2    *             *                     340m (34%)      460m (46%)    380Mi (13%)        410Mi (14%)\nexample-node-2    kube-system   kube-proxy-3ki7       200m (20%)      280m (28%)    210Mi (7%)         210Mi (7%)\nexample-node-2    tiller        tiller-deploy         140m (14%)      180m (18%)    170Mi (5%)         200Mi (7%)\n```\n\n### Including Utilization\nTo help understand how resource utilization compares to configured requests and limits, kube-capacity can include utilization metrics in the output. It's important to note that this output relies on [metrics-server](https://github.com/kubernetes-incubator/metrics-server) functioning correctly in your cluster. When `-u` or `--util` are passed to kube-capacity, it will include resource utilization information that looks like this:\n\n```\nkube-capacity --util\n\nNODE              CPU REQUESTS    CPU LIMITS    CPU UTIL    MEMORY REQUESTS    MEMORY LIMITS   MEMORY UTIL\n*                 560m (28%)      130m (7%)     40m (2%)    572Mi (9%)         770Mi (13%)     470Mi (8%)\nexample-node-1    220m (22%)      10m (1%)      10m (1%)    192Mi (6%)         360Mi (12%)     210Mi (7%)\nexample-node-2    340m (34%)      120m (12%)    30m (3%)    380Mi (13%)        410Mi (14%)     260Mi (9%)\n```\n\n### Displaying Available Resources\nTo more clearly see the total available resources on the node it is possible to pass the `--available` option\nto kube-capacity, which will give output in the following format\n\n```\nkube-capacity --available\n\nNODE              CPU REQUESTS    CPU LIMITS    MEMORY REQUESTS    MEMORY LIMITS\n*                 560/2000m       130/2000m     572/5923Mi         770/5923Mi \nexample-node-1    220/1000m       10/1000m      192/3200Mi         360/3200Mi \nexample-node-2    340/1000m       120/1000m     380/2923Mi         410/2923Mi\n```\n\n### Including Pods and Utilization\nFor more detailed output, kube-capacity can include both pods and resource utilization in the output. When `--util` and `--pods` are passed to kube-capacity, it will result in a wide output that looks like this:\n\n```\nkube-capacity --pods --util\n\nNODE              NAMESPACE     POD                   CPU REQUESTS    CPU LIMITS   CPU UTIL     MEMORY REQUESTS    MEMORY LIMITS   MEMORY UTIL\n*                 *             *                     560m (28%)      780m (38%)   340m (17%)   572Mi (9%)         770Mi (13%)     470Mi (8%)\n\nexample-node-1    *             *                     220m (22%)      320m (32%)   160m (16%)   192Mi (6%)         360Mi (12%)     210Mi (7%)\nexample-node-1    kube-system   metrics-server-lwc6z  100m (10%)      200m (20%)   70m (7%)     100Mi (3%)         200Mi (7%)      120Mi (4%)\nexample-node-1    kube-system   coredns-7b5bcb98f8    120m (12%)      120m (12%)   90m (9%)     92Mi (3%)          160Mi (5%)      90Mi (3%)\n\nexample-node-2    *             *                     340m (34%)      460m (46%)   180m (18%)   380Mi (13%)        410Mi (14%)     260Mi (9%)\nexample-node-2    kube-system   kube-proxy-3ki7       200m (20%)      280m (28%)   110m (11%)   210Mi (7%)         210Mi (7%)      120Mi (4%)\nexample-node-2    tiller        tiller-deploy         140m (14%)      180m (18%)   70m (7%)     170Mi (6%)         200Mi (7%)      140Mi (5%)\n```\n\nIt's worth noting that utilization numbers from pods will likely not add up to the total node utilization numbers. Unlike request and limit numbers where node and cluster level numbers represent a sum of pod values, node metrics come directly from metrics-server and will likely include other forms of resource utilization.\n\n### Sorting\nTo highlight the nodes, pods, and containers with the highest metrics, you can sort by a variety of columns:\n\n```\nkube-capacity --util --sort cpu.util\n\nNODE              CPU REQUESTS    CPU LIMITS    CPU UTIL    MEMORY REQUESTS    MEMORY LIMITS   MEMORY UTIL\n*                 560m (28%)      130m (7%)     40m (2%)    572Mi (9%)         770Mi (13%)     470Mi (8%)\nexample-node-2    340m (34%)      120m (12%)    30m (3%)    380Mi (13%)        410Mi (14%)     260Mi (9%)\nexample-node-1    220m (22%)      10m (1%)      10m (1%)    192Mi (6%)         360Mi (12%)     210Mi (7%)\n```\n\n\u003e **Note** Starting in v0.7.4 you can append `.percentage` to sort by percentage. For\nexample, `kube-capacity --util --sort cpu.util.percentage`.\n\n### Displaying Pod Count\nTo display the pod count of each node and the whole cluster, you can pass **--pod-count** argument:\n```shell\n$ kube-capacity --pod-count\n\nNODE           CPU REQUESTS   CPU LIMITS   MEMORY REQUESTS   MEMORY LIMITS   POD COUNT\n*              950m (2%)      200m (0%)    284Mi (0%)        284Mi (0%)      10/220\nminikube       850m (5%)      100m (0%)    231Mi (1%)        231Mi (1%)      8/110\nminikube-m02   100m (0%)      100m (0%)    53Mi (0%)         53Mi (0%)       2/110\n```\n\n### Filtering By Labels\nFor more advanced usage, kube-capacity also supports filtering by pod, namespace, and/or node labels. The following examples show how to use these filters:\n\n```\nkube-capacity --pod-labels app=nginx\nkube-capacity --namespace default\nkube-capacity --namespace-labels team=api\nkube-capacity --node-labels kubernetes.io/role=node\n```\n\n### Filtering By Node Taints\nKube-capacity supports advanced filtering by taints. Users can filter in and filter out taints within the same expression. The following examples show how to use node taint filters:\n\n```\nkube-capacity --node-taints special=true:NoSchedule \nkube-capacity --node-taints special:NoSchedule \n```\nThese will return only special nodes.\n```\nkube-capacity --node-taints special=true:NoSchedule-\nkube-capacity --node-taints special:NoSchedule-\n```\nThese will filter out special nodes and return only unspecial nodes.\n```\nkube-capacity --node-taints special=true:NoSchedule,old-hardware:NoSchedule-\n```\nThis will return special nodes that are not tainted with `old-hardware:NoSchedule`. In other words, display the special nodes but don't display the ones that are running on old hardware.\n```\nkube-capacity --no-taint\n```\nThis will filter out all nodes with taints. \n\n### JSON and YAML Output\nBy default, kube-capacity will provide output in a table format. To view this data in JSON or YAML format, the output flag can be used. Here are some sample commands:\n```\nkube-capacity --pods --output json\nkube-capacity --pods --containers --util --output yaml\n```\n\n### CSV and TSV Output\nIf you would like the data in a comma or tab separated file to make importing the data into a spreadsheet easier the output flag has options for those as well. Here are some sample commands:\n```\nkube-capacity --pods --output csv\nkube-capacity --pods --containers --util --output tsv\n```\n\u003eNote: the `--available` flag is ignored with these two choices as the values can be derived within a spreadsheet\n\n## Flags Supported\n```\n      --as string                 user to impersonate command with\n      --as-group string           group to impersonate command with\n  -c, --containers                includes containers in output\n      --context string            context to use for Kubernetes config\n  -h, --help                      help for kube-capacity\n      --kubeconfig string         kubeconfig file to use for Kubernetes config\n  -n, --namespace string          only include pods from this namespace\n      --namespace-labels string   labels to filter namespaces with\n      --hide-limits               hide limits from output\n      --hide-requests             hide requests from output\n      --no-taint                  exclude nodes with taints\n      --node-labels string        labels to filter nodes with\n  -o, --output string             output format for information\n                                    (supports: [table json yaml csv tsv])\n                                    (default \"table\")\n  -a, --available                 includes quantity available instead of percentage used (ignored with csv or tsv output types)\n  -t, --node-taints               taints to filter nodes with\n  -l, --pod-labels string         labels to filter pods with\n  -p, --pods                      includes pods in output\n      --sort string               attribute to sort results by (supports:\n                                    [cpu.util cpu.request cpu.limit mem.util mem.request mem.limit cpu.util.percentage\n                                    cpu.request.percentage cpu.limit.percentage mem.util.percentage mem.request.percentage\n                                    mem.limit.percentage name])\n                                    (default \"name\")\n  -u, --util                      includes resource utilization in output\n      --pod-count                 includes pod counts for each of the nodes and the whole cluster\n```\n\n## Prerequisites\nAny commands requesting cluster utilization are dependent on [metrics-server](https://github.com/kubernetes-incubator/metrics-server) running on your cluster. If it's not already installed, you can install it with the official [helm chart](https://github.com/helm/charts/tree/master/stable/metrics-server).\n\n## Similar Projects\nThere are already some great projects out there that have similar goals.\n\n- [kube-resource-report](https://github.com/hjacobs/kube-resource-report): generates HTML/CSS report for resource requests and limits across multiple clusters.\n- [kubetop](https://github.com/LeastAuthority/kubetop): a CLI similar to top for Kubernetes, focused on resource utilization (not requests and limits).\n\n## Development\n\nrun `make` to run all tests\n\nsee `Makefile` for more commands\n\n## Contributors\n\nAlthough this project was originally developed by [robscott](https://github.com/robscott), there have been some great contributions from others:\n\n- [endzyme](https://github.com/endzyme)\n- [justinbarrick](https://github.com/justinbarrick)\n- [Padarn](https://github.com/Padarn)\n- [nickatsegment](https://github.com/nickatsegment)\n- [fnickels](https://github.com/fnickels)\n- [isaacnboyd](https://github.com/isaacnboyd)\n\n## License\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobscott%2Fkube-capacity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobscott%2Fkube-capacity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobscott%2Fkube-capacity/lists"}