karmada
                                
                                
                                
                                    karmada copied to clipboard
                            
                            
                            
                        karmadactl supports top node
What type of PR is this? /kind feature
What this PR does / why we need it: karmadactl supports top node
Which issue(s) this PR fixes: Parts of #4217
Special notes for your reviewer: none
Does this PR introduce a user-facing change?:
Add command karmadactl top node to query the resource status of the cluster node. Like
➜  karmada git:(top) ✗ karmadactl top node -Cmember1
NAME                    CLUSTER   CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
member1-control-plane   member1   90m          2%     876Mi           5% 
                                    
                                    
                                    
                                
:warning: Please install the  to ensure uploads and comments are reliably processed by Codecov.
Codecov Report
Attention: Patch coverage is 0% with 191 lines in your changes missing coverage. Please review.
Project coverage is 29.52%. Comparing base (
6318541) to head (3af667c).
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4224      +/-   ##
==========================================
- Coverage   29.67%   29.52%   -0.15%     
==========================================
  Files         632      633       +1     
  Lines       43936    44127     +191     
==========================================
- Hits        13037    13029       -8     
- Misses      29954    30152     +198     
- Partials      945      946       +1     
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 29.52% <0.00%> (-0.15%) | 
:arrow_down: | 
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
/assign
kindly ping @chaunceyjiang @RainbowMango
@hulizhe @RainbowMango The previous proposal envisioned that the top pod and top node commands would provide the ability to view the usage of resources in the control plane and member clusters. However, due to the existence of the component metrics-adapter, when the operation scope of the top command is set to karmada, it returns the resources of all member clusters instead, just like:
$ kubectl --kubeconfig $HOME/.kube/karmada.config --context karmada-apiserver top pod   
NAME    CPU(cores)   MEMORY(bytes)   
nginx   0m           3Mi             
nginx   0m           2Mi             
nginx   0m           3Mi             
$ kubectl --kubeconfig $HOME/.kube/karmada.config --context karmada-apiserver top node
NAME                    CPU(cores)   CPU%    MEMORY(bytes)   MEMORY%   
member1-control-plane   85m          725Mi   
member2-control-plane   87m          715Mi   
member3-control-plane   94m          786Mi 
So, it would be better to limit the operation-scope of the top command to members.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: RainbowMango
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~pkg/karmadactl/top/OWNERS~~ [RainbowMango]
 
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment