Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

karmadactl supports top node #4224

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

zhzhuang-zju
Copy link
Contributor

@zhzhuang-zju zhzhuang-zju commented Nov 13, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:
karmadactl supports top node

$ karmadactl top node
NAME                    CLUSTER   CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
member1-control-plane   member1   90m          2%     876Mi           5% 
member2-control-plane   member1   90m          2%     876Mi           5% 
member3-control-plane   member1   90m          2%     876Mi           5% 

$ karmadactl top node --clusters=member1
NAME                    CLUSTER   CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
member1-control-plane   member1   90m          2%     876Mi           5% 

Which issue(s) this PR fixes:
Parts of #4217

Special notes for your reviewer:
none

Does this PR introduce a user-facing change?:

`karmadactl`: add new command `top node` to display resource (CPU/memory) usage of nodes in member clusters.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 13, 2023
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 13, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2023

⚠️ Please install the 'codecov app svg image' 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).

Files Patch % Lines
pkg/karmadactl/top/top_node.go 0.00% 143 Missing ⚠️
pkg/karmadactl/top/metrics_printer.go 0.00% 31 Missing ⚠️
pkg/karmadactl/top/metrics_sorter.go 0.00% 16 Missing ⚠️
pkg/karmadactl/top/top.go 0.00% 1 Missing ⚠️

❗ 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%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me.

@chaunceyjiang Can you help to take a look? As it's similar to top pods.

pkg/karmadactl/util/validate.go Outdated Show resolved Hide resolved
pkg/karmadactl/util/validate.go Outdated Show resolved Hide resolved
@chaunceyjiang
Copy link
Member

/assign

@zhzhuang-zju
Copy link
Contributor Author

kindly ping @chaunceyjiang @RainbowMango

Signed-off-by: zhzhuang-zju <m17799853869@163.com>
@zhzhuang-zju
Copy link
Contributor Author

@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.

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

It looks great!

# _output/bin/linux/amd64/karmadactl top nodes
NAME                    CLUSTER   CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
member1-control-plane   member1   292m         7%     779Mi           4%        
member2-control-plane   member2   98m          2%     772Mi           4%        
member3-control-plane   member3   104m         2%     869Mi           5%        

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 26, 2024
@karmada-bot
Copy link
Collaborator

[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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 26, 2024
@karmada-bot karmada-bot merged commit d12df24 into karmada-io:master Aug 26, 2024
12 checks passed
@RainbowMango RainbowMango added this to the v1.11 milestone Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants