Merge pull request #132567 from janetkuo/kubectl-top-help

Enhance help text for the 'top' command

Kubernetes-commit: c1e421a4136ff6491865a2d0e9146090e62d3841
This commit is contained in:
Kubernetes Publisher 2025-06-30 11:00:42 -07:00
commit 1d576b52f0
3 changed files with 31 additions and 9 deletions

6
go.mod
View File

@ -32,8 +32,8 @@ require (
k8s.io/api v0.0.0-20250626212533-a8e4c192362f
k8s.io/apimachinery v0.0.0-20250625172236-d6651abdfec8
k8s.io/cli-runtime v0.0.0-20250625180656-b24f6b404b39
k8s.io/client-go v0.0.0-20250625172911-958288110116
k8s.io/component-base v0.0.0-20250625174139-179392ef0450
k8s.io/client-go v0.0.0-20250630172937-5e8db78e0499
k8s.io/component-base v0.0.0-20250627214227-48c508093cdb
k8s.io/component-helpers v0.0.0-20250625174307-2c1c0a306592
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20250610211856-8b98d1ed966a
@ -95,4 +95,4 @@ require (
sigs.k8s.io/kustomize/api v0.19.0 // indirect
)
replace k8s.io/code-generator => k8s.io/code-generator v0.0.0-20250626013117-789f480fac50
replace k8s.io/code-generator => k8s.io/code-generator v0.0.0-20250627222435-b32cd008a125

8
go.sum
View File

@ -207,10 +207,10 @@ k8s.io/apimachinery v0.0.0-20250625172236-d6651abdfec8 h1:MsspBt/pf3hqgJCgzv8XGY
k8s.io/apimachinery v0.0.0-20250625172236-d6651abdfec8/go.mod h1:8gnN3W0XUgFL9P1KdRepAJFA98YuYViPoaUkwNZ1q70=
k8s.io/cli-runtime v0.0.0-20250625180656-b24f6b404b39 h1:xQ6t4JZwm8Jl63K9b39Rf2t3BBqvLNJAUZheO8juxMw=
k8s.io/cli-runtime v0.0.0-20250625180656-b24f6b404b39/go.mod h1:/ZAfCgtsO8qN2eQTMoDWibiv3BRm3LJO0tGLqBZntUQ=
k8s.io/client-go v0.0.0-20250625172911-958288110116 h1:XSKq9Bbohb9kmuZhikSdxLQx02HaHg2xVlavGE64mnM=
k8s.io/client-go v0.0.0-20250625172911-958288110116/go.mod h1:Jz4vyKgB0jnBepznNT5YHdWzDWToklF9cWFW/mFnIc8=
k8s.io/component-base v0.0.0-20250625174139-179392ef0450 h1:nUV4kvIczLp0P70TR+o0w99Zs1BpssHCnZBqT0DrnoQ=
k8s.io/component-base v0.0.0-20250625174139-179392ef0450/go.mod h1:1x8lr7IgSZFmqqCK82ptOofUzOT7UAqyxK/+xKXh9To=
k8s.io/client-go v0.0.0-20250630172937-5e8db78e0499 h1:H1ALazQeWf1yF0qhlkwsdEvMFgUorS4vAIaB5hxw/tA=
k8s.io/client-go v0.0.0-20250630172937-5e8db78e0499/go.mod h1:S35/NV7N0qaT+n8zdnMvSHhv01b7Gh36CDzj/Ei/1G0=
k8s.io/component-base v0.0.0-20250627214227-48c508093cdb h1:/SlQXukQyfHPZgdysGd7/sFbCbkAbUIYbdU/lix9YxA=
k8s.io/component-base v0.0.0-20250627214227-48c508093cdb/go.mod h1:/vzEgMwklKytYpKL5RZgmP1G8vrqZCCefCKBixxOEDU=
k8s.io/component-helpers v0.0.0-20250625174307-2c1c0a306592 h1:nigNyzQcXWSVYFY9Q+fInwyK6HAc2neeOjQHtRx6YK8=
k8s.io/component-helpers v0.0.0-20250625174307-2c1c0a306592/go.mod h1:7K0IQ3HDLL09je7I28gGXhbf6nk4cqUUfnoNDK3Rh/Y=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=

View File

@ -39,9 +39,31 @@ var (
topLong = templates.LongDesc(i18n.T(`
Display resource (CPU/memory) usage.
The top command allows you to see the resource consumption for nodes or pods.
This command provides a view of recent resource consumption for nodes and pods.
It fetches metrics from the Metrics Server, which aggregates this data from the
kubelet on each node. The Metrics Server must be installed and running in the
cluster for this command to work.
This command requires Metrics Server to be correctly configured and working on the server. `))
The metrics shown are specifically optimized for Kubernetes autoscaling
decisions, such as those made by the Horizontal Pod Autoscaler (HPA) and
Vertical Pod Autoscaler (VPA). Because of this, the values may not match those
from standard OS tools like 'top', as the metrics are designed to provide a
stable signal for autoscalers rather than for pinpoint accuracy.
When to use this command:
* For on-the-fly spot-checks of resource usage (e.g. identify which pods
are consuming the most resources at a glance, or get a quick sense of the load
on your nodes)
* Understand current resource consumption patterns
* Validate the behavior of your HPA or VPA configurations by seeing the metrics
they use for scaling decisions.
It is not intended to be a replacement for full-featured monitoring solutions.
Its primary design goal is to provide a low-overhead signal for autoscalers,
not to be a perfectly accurate monitoring tool. For high-accuracy reporting,
historical analysis, dashboarding, or alerting, you should use a dedicated
monitoring solution.`))
)
func NewCmdTop(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {