cli: Support kubectl-style resource selectors
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 11.5k
- Forks
- 1.4k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 53
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Linkerd CLI entry points for stat, tap, top, routes, metrics, and the shared namespace flag handling. Compare their resource arguments with kubectl's resource-list and label-selector behavior. Done means the affected commands accept equivalent resource lists and selectors, with --linkerd-namespace using -L, and existing command behavior remains covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- cli, devops
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100