kubernetes / kubernetes/kubectl
Add a flag to `kubectl top` to include cpu/memory resource request/limits for pods and containers
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
**What would you like to be added**:
An additional command line flag that, when enabled, adds the resource request and limits defined in the container manifest.
```shell
$ kubectl top pods --enumerate # or some other flag like '-o wide'
NAME CPU(cores) MEMORY(bytes) CPU REQ(cores) MEMORY REQ(bytes) CPU LIMIT(cores) MEMORY LIMIT(bytes)
my-pod-1 15m 10Mi 10m 5Mi 30m 15Mi
my-pod-2 15m 10Mi 10m 5Mi 30m 15Mi
my-pod-3 3m 5Mi 10m 5Mi 30m 15Mi
```
This flag should also be compatible with `--containers` and specifying a pod name.
**Why is this needed**:
I mostly operate in an on-prem cluster with our own hardware, and we don't utilize horizontal scaling for a handful of our deployments just due to the nature of their design. I.e. we find ourselves restricted for resources more often than not. Adding this flag to show the configured resource requests and limits would save a ton of time bouncing back and forth between `kubectl top pods` and `kubectl get pod ...` to compare the two.
Contributor guide
Research direction
Start with the kubectl top pods command and its existing --containers and pod-name paths. Review how the command formats CPU and memory output, then define the flag behavior for adding container resource requests and limits. Done means the flag works for pods, containers, and a specified pod while showing the requested resource columns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100