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

cli: Support kubectl-style resource selectors #2734

Open
olix0r opened this issue Apr 22, 2019 · 10 comments
Open

cli: Support kubectl-style resource selectors #2734

olix0r opened this issue Apr 22, 2019 · 10 comments

Comments

@olix0r
Copy link
Member

olix0r commented Apr 22, 2019

The various Linkerd subcommands that operate on kubernetes resources all work somewhat differently, and none of them support Kubernetes label selection.

Anywhere where the linkerd CLI operates on a list of resources (tap, top, routes, stat, metrics, etc), linkerd should accept resource selections exactly like kubectl.

Furthermore the --linkerd-namespace flag should be changed so that its short flag is -L, so that the -l flag can be used for label selection (like other kubernetes-related tools).

For example, kubectl supports the following:

:; kubectl get -n linkerd svc/linkerd-web deploy/linkerd-web
NAME                  TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)             AGE
service/linkerd-web   ClusterIP   10.0.238.66   <none>        8084/TCP,9994/TCP   11d

NAME                                DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.extensions/linkerd-web   1         1         1            1           11d
:; kubectl -n linkerd get po -l linkerd.io/control-plane-component    
NAME                                   READY     STATUS    RESTARTS   AGE
linkerd-controller-58fb7787b-kxhw5     4/4       Running   0          11d
linkerd-grafana-659c48d67-h8lx6        2/2       Running   0          11d
linkerd-identity-84fd9b78b-g9h4c       2/2       Running   0          11d
linkerd-prometheus-644698f444-zg9fn    2/2       Running   0          11d
linkerd-sp-validator-c4965d44c-8qqmb   2/2       Running   0          4d
linkerd-web-7f46b9cfcb-6c6kv           2/2       Running   0          4d
:; kubectl -n linkerd get deploy linkerd-controller linkerd-identity
NAME                 DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
linkerd-controller   1         1         1            1           11d
NAME                 DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
linkerd-identity     1         1         1            1           11d

linkerd should accept resource lists similarly.


linkerd stat accepts multiple resources, like kubectl, but does not accept label selectors:

:; linkerd -n linkerd stat deploy linkerd-controller linkerd-identity
NAME                 MESHED   SUCCESS      RPS   LATENCY_P50   LATENCY_P95   LATENCY_P99   TCP_CONN
linkerd-controller      1/1    81.82%   1.1rps           1ms           2ms           3ms         17
linkerd-identity        1/1   100.00%   0.3rps           1ms           1ms           1ms         13

linkerd tap, linkerd top, and likerd routes do not accept a list of resources

:; linkerd -n linkerd tap deploy linkerd-controller linkerd-identity
Error: accepts between 1 and 2 arg(s), received 3
Usage:
  linkerd tap [flags] (RESOURCE)

But there is no technical reason for this, since they all accept all resources of a given type:

:; linkerd -n linkerd tap deploy
req id=0:1 proxy=out src=10.244.3.83:46802 dst=10.244.0.214:4191 tls=no_authority_in_http_request :method=GET :authority=10.244.0.214:4191 :path=/metrics
rsp id=0:1 proxy=out src=10.244.3.83:46802 dst=10.244.0.214:4191 tls=no_authority_in_http_request :status=200 latency=3853µs
end id=0:1 proxy=out src=10.244.3.83:46802 dst=10.244.0.214:4191 tls=no_authority_in_http_request duration=39µs response-length=5635B                                    

The linkerd metrics command does not accept any resource lists, though it supports expanding group types like deploy/foo.

@olix0r olix0r added this to To do in 2.5 - Release via automation Apr 22, 2019
@grampelberg grampelberg added the priority/P2 Nice-to-have for Release label Apr 29, 2019
@grampelberg grampelberg removed this from To do in 2.5 - Release Jul 15, 2019
@VineethReddy02
Copy link

I would like to work on this.

@grampelberg
Copy link
Contributor

@VineethReddy02 go for it! Any pointers we can give to help out?

@mayankshah1607
Copy link
Contributor

@VineethReddy02 @grampelberg Is this still being worked on? I'd like to take up this one if that's okay :)

@grampelberg
Copy link
Contributor

@mayankshah1607 let's give @VineethReddy02 a little bit, but I'm unaware of anyone actively working on this one.

@VineethReddy02
Copy link

Hi @mayankshah1607 you can take this up. I am occupied at this moment.

@shidenkai0
Copy link

shidenkai0 commented Jun 15, 2022

Hi @mayankshah1607, are you still working on this? If not I would like to have a go at this one.

EDIT: I saw that some PRs were already merged, is this issue still relevant? If so, what remains to be implemented?

@kleimkuhler
Copy link
Contributor

@shidenkai0 It looks like #4183 was a created to track the remaining work. That was closed because it staled out — not because the work was completed. You should be able to reference that issue for adding what is left if you are interested!

@adleong
Copy link
Member

adleong commented Jun 22, 2022

According to #4183, the remaining commands that need to be updated are:

  • Unify various methods that retrieve label selectors
  • Add support for tap,top,routes,stat to accept list of resources
  • Update metrics command to accept label selectors - --selector flag
  • Update metrics command to not require resource name while using the --selector flag

@itsCheithanya
Copy link

has this issue been solved ? if no can i work on this?
@adleong

@kleimkuhler
Copy link
Contributor

@itsCheithanya the issues listed in the bullet points above are still open so you're free to work on this if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants