linkerd / linkerd2

Ultralight, security-first service mesh for Kubernetes. Main repo for Linkerd 2.x.
https://linkerd.io
Apache License 2.0
10.6k stars 1.27k forks source link

cli: Support kubectl-style resource selectors #2734

Open olix0r opened 5 years ago

olix0r commented 5 years ago

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.

VineethReddy02 commented 4 years ago

I would like to work on this.

grampelberg commented 4 years ago

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

mayankshah1607 commented 4 years ago

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

grampelberg commented 4 years ago

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

VineethReddy02 commented 4 years ago

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

shidenkai0 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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

itsCheithanya commented 1 year ago

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

kleimkuhler commented 1 year ago

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