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

Added "kubectl search" as plugin #140

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@guessi
Copy link

commented Apr 20, 2019

Basic Usage:

$ kubectl krew install --manifest=plugins/search.yaml
$ kubectl search pods keyword

Checklist for plugin developers:

  • Read the Plugin Naming Guide (for new plugins)
  • Verify the installation from URL or a local archive works (kubectl krew install --manifest=[...] --archive=[...])
Added "kubectl search" as plugin
    $ kubectl krew install --manifest=plugins/search.yaml

    $ kubectl search deployments keyword
    $ kubectl search pods keyword
    $ kubectl search hpas keyword

Signed-off-by: guessi <guessi@gmail.com>
@k8s-ci-robot

This comment has been minimized.

Copy link

commented Apr 20, 2019

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot

This comment has been minimized.

Copy link

commented Apr 20, 2019

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: guessi
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: juanvallejo

If they are not already assigned, you can assign the PR to them by writing /assign @juanvallejo in a comment when ready.

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

@corneliusweig

This comment has been minimized.

Copy link
Contributor

commented Apr 20, 2019

@guessi Your doc sounds as if kubectl grep would be a more appropriate name. Am I mistaken?

@guessi

This comment has been minimized.

Copy link
Author

commented Apr 20, 2019

@corneliusweig It basically do the same job that grep does.

but kubectl get ... | grep keyword will remove the header, unless we execute kubectl get ... | egrep '(^NAME|keyword)'. Whereas kubectl-search will keep the format as kubectl does. So I think it's not just grepping the keyword.

@ahmetb

This comment has been minimized.

Copy link
Contributor

commented May 15, 2019

Name grab issues

The search name is a bit namegrab-ish. What if we have other plugins with the same name in the future that are potentially better?

Doesn't sound like a plugin we should have

This functionality actually exists in kubectl:

kubectl get pods --filter=metadata.name=keyword

https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/

In this case, we shouldn't probably convert something that could be a very small bash function to a plugin. You can probably just rewrite this as (pseudocode):

foo() {
    kubectl get args[-2] --filter=args[-1] args[3:*]
}

Similarly I think it can be done by kubectl get pods | grep keyword which utilizes grep, and good from an Unix philosophy perspective.


I currently vote to put a /hold on this, until we have better decision-making around whether ultra-small utilities like this should get in.

@guessi

This comment has been minimized.

Copy link
Author

commented May 15, 2019

@ahmetb Well... it's true, it can easily replaced by a small script, or any other kind of shell aliases, I love writing shell script for my daily jobs, and I do know it could be integrated into existed plugins, such as @corneliusweig 's great work: ketall.


My initial though was to provide another easy way to do search via a simple binary execution setup, and execute simple kubectl search ... right after the binary download, especially for the newbies.

Finding resources inside Kubernetes without caring:

  • Where should I put the script?
  • Is it compatible with my operation system?
  • Is it compatible with existed aliases?
  • It's not work under my shell environment, but I don't know why?
  • Oops, there's no sample for the PowerShell, it's useless for me

Furthermore, everyone got his own dotfiles, but not all user familiar with these scripting jobs.

Take my colleague as example, pure Ops guy, or pure Dev guys, who run application on Kubernetes, but they don't write shell scripts for work. They just wanna search something.

Yeah... lazy developers, but it's true, lol

As for the name of the tool, just wanna made it easy to remember for all users, as I mention before, not all user familiar running their code on Unix-like system, e.g, FindStr for the PowerShell. So, I still insist search is much more better than grep for the tool's name.

That's why I create this tool, and named it as kubectl-search.


It's open discussion, please feel free to leave your opinion :-)

* By the way, if there's bug, please do let met know, I will try to fix it ASAP.

@ahmetb

This comment has been minimized.

Copy link
Contributor

commented May 16, 2019

OK I’ll re-evaluate this and actually use the tool hands-on. It's unlikely I'll get back to it before KubeCon EU ends, so this may delay to end of May.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.