A pretty command-line tool to monitor Kubernetes pod resource usage vs requests/limits
Compare actual CPU and memory usage against requested resources or limits with color-coded output for easy identification of over/under-utilized pods.
- π¨ Color-coded output - Instantly identify resource utilization patterns
- π Dual comparison modes - Compare against requests OR limits
- π Multi-namespace support - Check single namespace or all at once
- π― Flexible filtering - Show only CPU, memory, or both
- β‘ Performance focused - Fast scanning with progress indicators
- π§ Customizable thresholds - Adjust color coding to your needs
- π Usage percentage - Clear percentage differences for easy analysis
- ποΈ Requests vs Limits modes - Choose what to compare usage against
Color coding varies by mode:
- Red - Over-utilized (> 0% above requests)
- Yellow - Warning zone (-20% to 0%)
- Green - Well-utilized (-90% to -20%)
- Cyan - Very under-utilized (< -90%)
- Magenta - No resource requests set
- Red - Near limits (> -10% of limits)
- Yellow - Warning zone (-40% to -10%)
- Green - Well-utilized (-80% to -40%)
- Cyan - Very under-utilized (< -80%)
- Magenta - No resource limits set
# Download the latest release for your platform
curl -L https://github.com/Senk02/kdiff/releases/latest/download/kdiff.tgz -o kdiff.tgz
tar -xzvf kdiff.tgz
chmod +x kdiff
sudo mv kdiff /usr/local/bin/# Clone the repository
git clone https://github.com/Senk02/kdiff.git
cd kdiff
# Build the binary
make build
sudo chmod +x kdiff
# Optional: Install to PATH
sudo mv kdiff /usr/local/bin/- Kubernetes cluster with
metrics-serverinstalled and running - Valid
kubeconfigfile (usually at~/.kube/config) - Go 1.19+ (if building from source)
# Check current namespace (requests mode by default)
kdiff
# Check specific namespace
kdiff -n kube-system
# Check all namespaces
kdiff -a
# Use limits mode instead of requests
kdiff --mode limits# Show only CPU usage across all namespaces in limits mode
kdiff -a -o cpu -m limits
# Show only memory usage in specific namespace
kdiff -n production -o memory
# Show only pods exceeding their requests/limits
kdiff -d
# Ignore pods without resource requests/limits set
kdiff -i
# Combine filters: only over-utilized pods with requests set
kdiff -d -i
# Use specific kubeconfig context
kdiff --context my-cluster-context
# Check limits mode for all namespaces, CPU only
kdiff -A -o cpu --mode limits# Customize when colors appear for limits mode (values are percentages)
kdiff --mode limits --color-red -5 --color-yellow -30 --color-cyan -70
# This means for limits mode:
# Red: > -5% (very close to limits)
# Yellow: -30% to -5% of limits
# Green: -70% to -30% under limits
# Cyan: < -70% under limits- Compares actual usage against resource requests (what pods ask for)
- Positive percentages mean usage exceeds requests
- Helps identify pods that need higher requests
- Compares actual usage against resource limits (maximum allowed)
- Usually shows negative percentages since limits are typically higher than usage
- Helps identify pods approaching their resource limits
| Flag | Description |
|---|---|
-n <namespace> |
Specify namespace to check (defaults to current context) |
-a, -A |
Check all namespaces |
-o <filter> |
Filter output to 'cpu' or 'memory' |
-m, --mode <mode> |
Mode: 'requests' (default) or 'limits' |
-d |
Only show pods with usage over requests/limits |
-i, --ignore-unset |
Ignore pods without resource requests/limits set |
--kubeconfig <kubeconfig> |
Use a specific kubeconfig file |
--context <context> |
Use specific kubeconfig context |
-h |
Show help message |
--color-red <float> |
Threshold for red color |
--color-yellow <float> |
Threshold for yellow color |
--color-cyan <float> |
Threshold for cyan color |
Requests Mode:
- Red: > 0.0% (over requests)
- Yellow: -20.0% to 0.0% (warning zone)
- Cyan: < -90.0% (very under-utilized)
Limits Mode:
- Red: > -10.0% (near limits)
- Yellow: -40.0% to -10.0% (warning zone)
- Cyan: < -80.0% (very under-utilized)
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the GNU GPL V3 License - see the LICENSE file for details.
If you find this tool helpful, consider supporting the development:
"Error connecting to metrics API"
- Ensure
metrics-serveris installed:kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml - Check if metrics-server pods are running:
kubectl get pods -n kube-system | grep metrics-server
"No running pods found"
- Verify you're connected to the right cluster:
kubectl cluster-info - Check if pods exist in the namespace:
kubectl get pods -n <namespace>
"Error creating kubeconfig"
- Ensure your kubeconfig file exists and is valid:
kubectl config view - Try specifying a different context:
kdiff --context <context-name>
Made with β€οΈ for the Kubernetes community
