kubectl top
and Pod CPU,
Syntax
kubectl top <node|pod> [name] [flags]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
--containers |
Pod | kubectl top pod web-pod --containers |
Common |
--sort-by |
cpu memory | kubectl top pods --sort-by=memory |
Common |
-l --selector |
kubectl top pods -l app=web |
Common | |
-A --all-namespaces |
kubectl top pods -A --sort-by=cpu |
Common |
Examples
kubectl top nodes
Metrics Server
Pod
kubectl top pods --sort-by=memory
,
Level
kubectl top pod web-app --containers
Pod
CPU
kubectl top pods -A --sort-by=cpu
CPU Pod
Common Errors
Metrics API not availableMetrics Server, : kubectl apply -f metrics-server.yaml
metrics not available yetMetrics Server, and more 1-2
Tips
- kubectl top Metrics Server
- requests/limits
- Prometheus + Grafana