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

Optimize karmadactl get to output more information #1270

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

lonelyCZ
Copy link
Member

@lonelyCZ lonelyCZ commented Jan 17, 2022

Signed-off-by: lonelyCZ [email protected]

What type of PR is this?
/kind feature

What this PR does / why we need it:
Optimize output content.

[root@master67 karmada]# ./karmadactl get pod -o wide
NAME                     CLUSTER   READY   STATUS      RESTARTS   AGE    IP             NODE       NOMINATED NODE   READINESS GATES   ADOPTION
nginx-6799fc88d8-4dkqm   member1   1/1     Running     0          3d5h   10.244.0.102   master68   <none>           <none>            N
pi--1-7rpgp              member1   0/1     Completed   0          10h    10.244.0.103   master68   <none>           <none>            N
pi--1-h7zdq              member1   0/1     Completed   0          10h    10.244.0.105   master68   <none>           <none>            N
pi--1-z65zd              member1   0/1     Completed   0          10h    10.244.0.104   master68   <none>           <none>            N
nginx-6799fc88d8-9fcpz   member2   1/1     Running     0          3d5h   10.244.0.77    master67   <none>           <none>            N
pi-jpnvx                 member2   0/1     Completed   0          10h    10.244.0.79    master67   <none>           <none>            N
pi-sk86w                 member2   0/1     Completed   0          10h    10.244.0.78    master67   <none>           <none>            N
pi-sll66                 member2   0/1     Completed   0          10h    10.244.0.80    master67   <none>           <none>            N
[root@master67 karmada]# ./karmadactl get pod,svc -o wide
NAME                         CLUSTER   READY   STATUS      RESTARTS   AGE     IP             NODE       NOMINATED NODE   READINESS GATES   ADOPTION
pod/nginx-6799fc88d8-4dkqm   member1   1/1     Running     0          3d19h   10.244.0.102   master68   <none>           <none>            N
pod/pi--1-7rpgp              member1   0/1     Completed   0          24h     10.244.0.103   master68   <none>           <none>            N
pod/pi--1-h7zdq              member1   0/1     Completed   0          24h     10.244.0.105   master68   <none>           <none>            N
pod/pi--1-z65zd              member1   0/1     Completed   0          24h     10.244.0.104   master68   <none>           <none>            N
pod/nginx-6799fc88d8-9fcpz   member2   1/1     Running     0          3d19h   10.244.0.77    master67   <none>           <none>            N
pod/pi-jpnvx                 member2   0/1     Completed   0          24h     10.244.0.79    master67   <none>           <none>            N
pod/pi-sk86w                 member2   0/1     Completed   0          24h     10.244.0.78    master67   <none>           <none>            N
pod/pi-sll66                 member2   0/1     Completed   0          24h     10.244.0.80    master67   <none>           <none>            N

NAME                 CLUSTER   TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE   SELECTOR   ADOPTION
service/kubernetes   member1   ClusterIP   10.96.0.1    <none>        443/TCP   61d   <none>     N
service/kubernetes   member2   ClusterIP   10.96.0.1    <none>        443/TCP   85d   <none>     N
[root@master67 karmada]# ./karmadactl get pod -A
NAMESPACE        NAME                                             CLUSTER   READY   STATUS      RESTARTS      AGE
default          nginx-6799fc88d8-9fcpz                           member2   1/1     Running     0             3d19h
default          pi-jpnvx                                         member2   0/1     Completed   0             24h
default          pi-sk86w                                         member2   0/1     Completed   0             24h
default          pi-sll66                                         member2   0/1     Completed   0             24h
karmada-system   etcd-0                                           member2   1/1     Running     0             3d20h
karmada-system   karmada-aggregated-apiserver-7b88b8df99-v8nml    member2   1/1     Running     0             3d20h
karmada-system   karmada-apiserver-77bf5b778f-fbsdv               member2   1/1     Running     0             3d20h
karmada-system   karmada-controller-manager-7d66968445-hrr6w      member2   1/1     Running     0             3d20h
karmada-system   karmada-kube-controller-manager-dc99ffd8-wq8c2   member2   1/1     Running     0             3d20h
karmada-system   karmada-scheduler-8677cdf96d-rjxjq               member2   1/1     Running     0             3d20h
karmada-system   karmada-webhook-5bfd9fb89d-bbl5v                 member2   1/1     Running     0             3d20h
kube-system      coredns-6d56c8448f-6sxdn                         member2   1/1     Running     1             56d
kube-system      coredns-6d56c8448f-pt9ns                         member2   1/1     Running     1             56d
kube-system      etcd-master67                                    member2   1/1     Running     2             85d
kube-system      kube-apiserver-master67                          member2   1/1     Running     2             56d
kube-system      kube-controller-manager-master67                 member2   1/1     Running     40            85d
kube-system      kube-flannel-ds-klpjg                            member2   1/1     Running     1             56d
kube-system      kube-proxy-9p86s                                 member2   1/1     Running     3             85d
kube-system      kube-scheduler-master67                          member2   1/1     Running     39            85d
default          nginx-6799fc88d8-4dkqm                           member1   1/1     Running     0             3d19h
default          pi--1-7rpgp                                      member1   0/1     Completed   0             24h
default          pi--1-h7zdq                                      member1   0/1     Completed   0             24h
default          pi--1-z65zd                                      member1   0/1     Completed   0             24h
kube-system      coredns-7f6cbbb7b8-77wjk                         member1   1/1     Running     0             50d
kube-system      coredns-7f6cbbb7b8-hhp8x                         member1   1/1     Running     0             50d
kube-system      etcd-master68                                    member1   1/1     Running     1 (50d ago)   61d
kube-system      kube-apiserver-master68                          member1   1/1     Running     1 (50d ago)   61d
kube-system      kube-controller-manager-master68                 member1   1/1     Running     1 (50d ago)   61d
kube-system      kube-flannel-ds-9w82j                            member1   1/1     Running     0             50d
kube-system      kube-proxy-hp966                                 member1   1/1     Running     1 (50d ago)   61d
kube-system      kube-scheduler-master68                          member1   1/1     Running     1 (50d ago)   59d

Which issue(s) this PR fixes:
Fixes #1219

Special notes for your reviewer:
Step1: Optimize output.
Step2: replace secret with proxy to access member clusters(include pull mode cluster).

Does this PR introduce a user-facing change?:

karmadactl get pod -o wide

karmadactl get pod,svc

karmadactl get pod -A

@karmada-bot karmada-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Jan 17, 2022
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 17, 2022
@RainbowMango
Copy link
Member

Looks pretty good! Please cc me once ready for view.
Just a remember, if you want to talk about this, today's community meeting would be a good place.

@lonelyCZ lonelyCZ changed the title [WIP]Optimize karmadactl get to output more information Optimize karmadactl get to output more information Jan 18, 2022
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 18, 2022
@lonelyCZ
Copy link
Member Author

Looks pretty good! Please cc me once ready for view. Just a remember, if you want to talk about this, today's community meeting would be a good place.

Thanks, as I thought. I want to talk about using proxy to access member clusters in karmadactl, and implement it in next pr, because it relate to all subcommand in karmadactl to access member clusters.

@lonelyCZ
Copy link
Member Author

/cc @RainbowMango

@@ -188,6 +200,7 @@ type OtherPrint struct {
}

// Run performs the get operation.
//nolint:gocyclo
Copy link
Member

Choose a reason for hiding this comment

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

Is there a plan to remove this nolint:gocyclo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I will do it in this pr.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removing this nolint:gocyclo need to split code that make code unreadable and complicated, so not removed for now and continue to find a good way.

Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with it. Could you please file an issue for this? You know, the technical debt is pretty easy to forget.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, add a issue that list all nolint:gocyclo in codes as items and plan to remove them?

Copy link
Member

Choose a reason for hiding this comment

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

Not list all, just focus on the new one would be ok.

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.

Does the example also needs to be updated?

./karmadactl get --help 
Display one or many resources

Usage:
  karmadactl get [NAME | -l label | -n namespace]  [flags]

Examples:

# List all pods in ps output format
karmadactl get pods

# List a single replicasets controller with specified NAME in ps output format 
karmadactl get replicasets nginx

# List deployments in JSON output format, in the "v1" version of the "apps" API group 
karmadactl get deployments.v1.apps 

# List all replication controllers and services together in ps output format 
karmadactl get rs,services

# List one or more resources by their type and names 
karmadactl get rs/nginx-cb87b6d88 service/kubernetes

I'm ok if you are going to do it by following PR. Just a question or reminder.

@lonelyCZ
Copy link
Member Author

Does the example also needs to be updated?

./karmadactl get --help 
Display one or many resources

Usage:
  karmadactl get [NAME | -l label | -n namespace]  [flags]

Examples:

# List all pods in ps output format
karmadactl get pods

# List a single replicasets controller with specified NAME in ps output format 
karmadactl get replicasets nginx

# List deployments in JSON output format, in the "v1" version of the "apps" API group 
karmadactl get deployments.v1.apps 

# List all replication controllers and services together in ps output format 
karmadactl get rs,services

# List one or more resources by their type and names 
karmadactl get rs/nginx-cb87b6d88 service/kubernetes

I'm ok if you are going to do it by following PR. Just a question or reminder.

Right, I add it right away.

@lonelyCZ lonelyCZ force-pushed the optimize-get branch 2 times, most recently from 88d98fe to 779a8eb Compare January 19, 2022 11:27
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.

Hi @lonelyCZ
This branch has conflicts that must be resolved.

@lonelyCZ
Copy link
Member Author

Hi @lonelyCZ This branch has conflicts that must be resolved.

Ok, I will fix it.

@lonelyCZ lonelyCZ force-pushed the optimize-get branch 2 times, most recently from ea46568 to 13e545c Compare January 20, 2022 12:09
@lonelyCZ
Copy link
Member Author

/cc @RainbowMango

The conflict has been fixed and the nolint:gocyclo also has been removed. To be on the safe side, could you please test it?

@RainbowMango
Copy link
Member

# ./karmadactl get pods -o wide
The karmadactl get command now only supports Push mode, [ member3 ] are not push mode

NAME                     CLUSTER   READY   STATUS    RESTARTS   AGE   IP          NODE                    NOMINATED NODE   READINESS GATES   ADOPTION
nginx-6799fc88d8-9mztc   member1   1/1     Running   0          28s   10.10.0.5   member1-control-plane   <none>           <none>            N
nginx-6799fc88d8-9pxj4   member2   1/1     Running   0          28s   10.12.0.5   member2-control-plane   <none>           <none>            N

Works as expected.

@RainbowMango
Copy link
Member

I updated the PR description to fixes the #1219. The following work(should be tracked by another issue) is not in the scope of the issue.

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

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2022
@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 Jan 21, 2022
@karmada-bot karmada-bot merged commit 9800c3c into karmada-io:master Jan 21, 2022
@RainbowMango
Copy link
Member

I updated the PR description to fixes the #1219. The following work(should be tracked by another issue) is not in the scope of the issue.

Tracked by #1091

@lonelyCZ
Copy link
Member Author

Ok, thanks! :)

@lonelyCZ lonelyCZ deleted the optimize-get branch July 11, 2022 07:09
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

karmadactl output format with more information such as -owide
3 participants