kubernetes-sigs / krew

📦 Find and install kubectl plugins
https://krew.sigs.k8s.io
Apache License 2.0
6.4k stars 371 forks source link

Show if plugin is available on current platform in "krew search" output #546

Closed survivant closed 4 years ago

survivant commented 4 years ago

I'm on Windows and it could be great to have a flag to exclude plugin that are not supported in windows.

something that will return the same output as this

kubectl krew search | findstr -V windows


PS C:\windows\system32> kubectl krew search | findstr -V windows
NAME                            DESCRIPTION                                         INSTALLED
access-matrix                   Show an RBAC access matrix for server resources     no
auth-proxy                      Authentication proxy to a pod or service            no
change-ns                       View or change the current namespace via kubectl.   no
config-cleanup                  Automatically clean up your kubeconfig              no
debug                           Attach ephemeral debug container to running pod     no
deprecations                    Checks for deprecated objects in a cluster          no
df-pv                           Show disk usage (like unix df) for persistent v...  no
doctor                          Scans your cluster and reports anomalies.           no
duck                            List custom resources with ducktype support         no
eksporter                       Export resources and removes a pre-defined set ...  no
fields                          Grep resources hierarchy by field name              no
fleet                           Shows config and resources of a fleet of clusters   no
get-all                         Like `kubectl get all` but _really_ everything      no
gopass                          Imports secrets from gopass                         no
grep                            Filter Kubernetes resources by matching their n...  no
images                          Show container images used in the cluster.          no
konfig                          Merge, split or import kubeconfig files             no
krew                            Package manager for kubectl plugins.                yes
kubesec-scan                    Scan Kubernetes resources with kubesec.io.          no
match-name                      Match names of pods and other API objects           no
oidc-login                      Log in to the OpenID Connect provider               no
outdated                        Finds outdated container images running in a cl...  no
passman                         Store kubeconfig credentials in keychains or pa...  no
pod-dive                        Shows a pod's workload tree and info inside a node  no
popeye                          Scans your clusters for potential resource issues   no
preflight                       Executes application preflight tests in a cluster   no
rbac-view                       A tool to visualize your RBAC permissions.          no
resource-snapshot               Prints a snapshot of nodes, pods and HPAs resou...  no
sniff                           Start a remote packet capture on pods using tcp...  no
ssm-secret                      Import/export secrets from/to AWS SSM param store   no
status                          Show status details of a given resource.            no
support-bundle                  Creates support bundles for off-cluster analysis    no
topology                        Explore region topology for nodes or pods           no
tree                            Show a tree of object hierarchies through owner...  no
view-secret                     Decode Kubernetes secrets                           no
virt                            Control KubeVirt virtual machines using virtctl     no
who-can                         Shows who has RBAC permissions to access Kubern...  no
PS C:\windows\system32>
ahmetb commented 4 years ago

+1. We used to (or considered to) have AVAILABLE field on this table.

corneliusweig commented 4 years ago

This looks like a bug. We should be doing this already: https://github.com/kubernetes-sigs/krew/blob/e4b2528eec4df521d8823b4de92d221d6ac26e3d/cmd/krew/cmd/search.go#L84 /kind bug /priority P1 /help

k8s-ci-robot commented 4 years ago

@corneliusweig: This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-help command.

In response to [this](https://github.com/kubernetes-sigs/krew/issues/546): >This looks like a bug. We should be doing this already: https://github.com/kubernetes-sigs/krew/blob/e4b2528eec4df521d8823b4de92d221d6ac26e3d/cmd/krew/cmd/search.go#L84 >/kind bug >/priority P1 >/help > > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
onesolpark commented 4 years ago

If it might help, I've check in my windows server.

Seems like it's working as espected.

PS C:\Windows\System32> kubectl krew search
NAME                            DESCRIPTION                                         INSTALLED
access-matrix                   Show an RBAC access matrix for server resources     no
advise-psp                      Suggests PodSecurityPolicies for cluster.           unavailable on windows
auth-proxy                      Authentication proxy to a pod or service            no
bulk-action                     Do bulk actions on Kubernetes resources.            unavailable on windows
ca-cert                         Print the PEM CA certificate of the current clu...  unavailable on windows
capture                         Triggers a Sysdig capture to troubleshoot the r...  unavailable on windows
change-ns                       View or change the current namespace via kubectl.   no
cluster-group                   Exec commands across a group of contexts.           unavailable on windows
config-cleanup                  Automatically clean up your kubeconfig              no
cssh                            SSH into Kubernetes nodes                           unavailable on windows
ctx                             Switch between contexts in your kubeconfig          unavailable on windows
custom-cols                     A "kubectl get" replacement with customizable c...  unavailable on windows
debug                           Attach ephemeral debug container to running pod     no
debug-shell                     Create pod with interactive kube-shell.             unavailable on windows
deprecations                    Checks for deprecated objects in a cluster          no
df-pv                           Show disk usage (like unix df) for persistent v...  no
doctor                          Scans your cluster and reports anomalies.           no
duck                            List custom resources with ducktype support         no

Well you can change how it detects the OS by changing/adding KREW_OS environment variable. https://github.com/kubernetes-sigs/krew/blob/927e4d7a97f2f90fd8439bb8294530d5a1ea5c71/internal/installation/platform.go#L68-L75

Try kubectl krew search -v=2 and check if its printing out the OS/ARCH as you want it to. And check KREW_OS variable to be sure.

I0316 16:59:46.206573    2664 platform.go:43] Matching platform for labels(arch=amd64,os=windows)
I0316 16:59:46.206573    2664 platform.go:43] Matching platform for labels(arch=amd64,os=windows)
I0316 16:59:46.206573    2664 platform.go:51] Found matching platform with index (2)
I0316 16:59:46.206573    2664 platform.go:43] Matching platform for labels(arch=amd64,os=windows)
I0316 16:59:46.206573    2664 platform.go:43] Matching platform for labels(arch=amd64,os=windows)
I0316 16:59:46.206573    2664 platform.go:43] Matching platform for labels(arch=amd64,os=windows)
I0316 16:59:46.206573    2664 platform.go:43] Matching platform for labels(arch=amd64,os=windows)
ahmetb commented 4 years ago

OH I get it now! Thanks @onesolpark.

You want a feature to "hide" the ones not available. That's why you did | findstr -V windows (=grep -v) in the original post.

I think the decision we have right now is sorta ok.

We might consider some improvement to this, such as perhaps moving the unavailable ones to the end of the list, however right now we have an alphabetical sorting guarantee on the list, it would break that.

onesolpark commented 4 years ago

@ahmetb Do you think adding an option to show all plugins (i.e kubectl krew search --show-all) and hiding the unsupported plugins as default sound like a viable solution?

ahmetb commented 4 years ago

I don't think so. For many users this will severely limit their perception of what's available to them (in possibly another machine they own).

onesolpark commented 4 years ago

got it i guess the best option for now is like you said to move the unavailable ones to the bottom of the list :)

mind if i work on this one?

corneliusweig commented 4 years ago

I think moving the plugins to the end is not the cleanest solution here. I think it makes sense to show everything by default, but we could add an --hide-unavailable flag enables the filter for the current OS. WDYT?

corneliusweig commented 4 years ago

@onesolpark There is an ongoing effort to add custom indexes which will also touch the krew list machinery. Just watch out for a PR in that area, to avoid heavy merge conflicts.

onesolpark commented 4 years ago

@corneliusweig got it i'll watch out for the multi-indexing PR to avoid merge conflicts

fejta-bot commented 4 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot commented 4 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot commented 4 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

k8s-ci-robot commented 4 years ago

@fejta-bot: Closing this issue.

In response to [this](https://github.com/kubernetes-sigs/krew/issues/546#issuecomment-674547460): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >Send feedback to sig-testing, kubernetes/test-infra and/or [fejta](https://github.com/fejta). >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.