Git Product home page Git Product logo

kubectl-grep's Introduction

Kubectl Grep

GitHub Actions GoDoc Go Report Card GitHub release GitHub go.mod Go version

Filter Kubernetes resources by matching their names

Compatibility

please refer to Kubernetes version policy and CHANGELOG for supported version matrix.

Why we need it?

playing with Kubernetes is my daily job, and I normally search pods by pipe, grep, --label, --field-selector, etc. while hunting abnormal pods, but typing such long commands is quite annoying.

Before change, we usually filter pods by the following commands,

$ kubectl get pods -n star-lab | grep "flash"

With this plugin installed, you can filter pod with kubectl grep easily

$ kubectl grep pods -n star-lab flash

Installation

Installation via krew

$ kubectl krew version # make sure you are running 0.4.4+
$ kubectl krew install grep
$ kubectl krew update
$ kubectl krew upgrade grep

Manual Installation

$ curl -fsSL -O https://github.com/guessi/kubectl-grep/releases/latest/download/kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ tar zxvf kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ mv kubectl-grep /usr/local/bin

How to get developer build?

$ go get -u github.com/guessi/kubectl-grep
$ cd ${GOPATH}/src/github.com/guessi/kubectl-grep
$ make all

FAQ

How do I check the tool's version?

  • kubectl grep version

Can I use version X kubectl with version Y kubectl-grep?

  • Sure, no problem

What kind of resource(s) kubectl-grep support?

Reference

License

Apache-2.0

kubectl-grep's People

Contributors

appleboy avatar elgalu avatar guessi avatar tsaarni avatar wshihadeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kubectl-grep's Issues

[Feature] Support CRDs

Is your feature request related to a problem? Please describe.
Kubectl commands like get work with CRDs, i.e. I can do things like kubectl get ingress. But using kubectl grep I can only get the basic/default resource types.

Describe the solution you'd like
Support the CRDs installed on the cluster like kubectl get does, e.g. kubectl grep ingress, kubectl grep mapping, etc.

Describe alternatives you've considered
Only way is to go back to kubectl get ... | grep ...

[Bug] not using current namespace on macosx

Describe the bug
Need to specify namespace to have results on macosx

To Reproduce
Steps to reproduce the behavior:

  1. kubectl grep pods nginx
  2. kubectl grep pods nginx -n demo

Expected behavior
I would have thought that it would use the current NS

Screenshots

Environment (please complete the following information):

  • Operation System: macOS
  • Kubernetes Version 1.12.9
    Kubectl Version v1.14.3

Additional context
NA

[Feature] Support arm64 based cpu for macOS

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
Cannot use in arm64 based cpu for macOS. Any plan on support it?
Thanks.

$ krew install grep
Updated the local copy of plugin index.
Installing plugin: grep
W0905 09:22:33.335262   47104 install.go:164] failed to install plugin "grep": plugin "grep" does not offer installation for this platform
failed to install some plugins: [grep]: plugin "grep" does not offer installation for this platform

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

grep Logs

It would be incredibly beneficial to grep logs.

I'm currently having to get logs based on pod labels. Would be really nice if I could see all of the logs based on a grep command.

kubectl grep logs -n namespace service-a

Question : How do I use contexts from kubeconfig using this project

svarkey@svarkey-Precision-7760:~$ kubectl grep pods -l name=test --context cs-prod1
Error: unknown flag: --context
Usage:
kubectl-grep pods [flags]

Aliases:
pods, po, pod

Flags:
-h, --help help for pods
-o, --output string Output format.

Global Flags:
-A, --all-namespaces If present, list the requested object(s) across all namespaces.
--field-selector string Selector (field query) to filter on. (e.g. --field-selector key1=value1,key2=value2)
-n, --namespace string Namespace for search. (default: "default")
-l, --selector string Selector (label query) to filter on. (e.g. -l key1=value1,key2=value2)

unknown flag: --context

[Feature] CI/CD Pipeline Should Support Pull-Requests

Is your feature request related to a problem? Please describe.
Currently the CI only support master build, but it should support pull-requests as well.

Describe the solution you'd like
N/A

Describe alternatives you've considered
N/A

Additional context
N/A

[Bug] Flag `-h` or `--help` is not working

Describe the bug
flag -h or --help is not working

instead, it returns,

% kubectl-grep -h
Usage of kubectl-grep:
  -kubeconfig string
    	(optional) absolute path to the kubeconfig file (default "~/.kube/config")

To Reproduce
Steps to reproduce the behavior:

  1. kubectl-grep -h or kubectl-grep --help

Expected behavior
It should return default help message, just like kubectl-grep does

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):
ALL

Additional context
Add any other context about the problem here.

[Bug] CVE-2019-9946

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Operation System: [e.g. Ubuntu, CentOS, macOS]
  • Kubernetes Version [e.g. v1.10.5, v1.11.7, v1.13.4]
  • Kubectl Version [e.g. v1.10.5, v1.11.7, v1.13.4]

Additional context
Add any other context about the problem here.

[Bug] kubectl grep unusable out of the box

Describe the bug
Unless there is a kubeconfig with configuration for a valid cluster set as the current context, all kubectl-grep commands fail.

Source of the problem
InitClient() code

To Reproduce

  1. Generate an unacceptable or null kubeconfig either by removing all context entries, deleting random lines, corrupting values or outright deleting kubeconfig
  2. Try any invocation of kubectl grep

Expected behavior
kubectl grep --help will show help info
kubectl grep --version will show the version
kubectl grep pods "debug" will fail

Screenshots

sh-4.2# kubectl grep --help
Fatal: Unable to get config
sh-4.2# kubectl grep --version
Fatal: Unable to get config
sh-4.2# kubectl grep pods "debug"
Fatal: Unable to get config
sh-4.2# kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []
sh-4.2# kubectl-grep --version
Fatal: Unable to get config
sh-4.2# kubectl-grep --help
Fatal: Unable to get config
sh-4.2#

Environment (please complete the following information):

  • Operation System: [e.g. Ubuntu, CentOS, macOS]
    MacOS 10.15.3, CentOS 7/8, Docker 2.2.0.4
  • Kubernetes Version [e.g. v1.10.5, v1.11.7, v1.13.4]
    v1.16.6
  • Kubectl Version [e.g. v1.10.5, v1.11.7, v1.13.4]
    v1.16.6

Additional context
Its very disruptive for automated utilities that login to a cluster must be done to verify the version installed.

[Feature] Helper Script for Upgrading Go Modules

Is your feature request related to a problem? Please describe.
Kubernetes are kind of rapid development application, things may changed from day to day.
To avoid unexpected APIs compatibility issue, it would be better to pin the following packages on released version, or a tagged version, such as kubernetes-1.13.4, or v10.0.0. We should avoid go.mod or go.sum being updated after a go get -u ... command executed, or it will be upgrade to master commit, which might be an unstable build.

  • k8s.io/api
  • k8s.io/apimachinery
  • k8s.io/client-go

Describe the solution you'd like
N/A

Describe alternatives you've considered
N/A

Additional context
N/A

[Bug] CircleCI Not Respect Cache Setup

Describe the bug
CircleCI build processes showing

No cache is found for key: v1-kubectl-search-cWF9gow_fbDB7st0znwgVDi3lvxE324Hq7w5e+Tkvrw=-source

which means the cache setup is not working

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Operation System: [e.g. Ubuntu, CentOS, macOS]
  • Kubernetes Version [e.g. v1.10.5, v1.11.7, v1.13.4]
  • Kubectl Version [e.g. v1.10.5, v1.11.7, v1.13.4]

Additional context
Add any other context about the problem here.

[krew] Distribute with license

👋 Hello, maintainer of the kubectl plugin manager krew here.

Thank you for your commitment to open source by making this plugin available via krew!

Krew wants to give credit where credit is due by installing the proper license file for the plugins it distributes. However, your plugin was found to not contain any license file. We wanted to remind you that if you're using a license such as Apache 2.0, you should be bundling your LICENSE file with your plugin’s distributions.

What do you have to do?

  • Please ensure your GitHub repository has a license file.
  • Make sure your archive file (.tar.gz or .zip) contains the license file.
  • Please submit a pull-request to krew-index and update the files: section to copy the file to the installation directory. Have a look at this PR for an example: https://github.com/kubernetes-sigs/krew-index/pull/314/files

If you need further assistance, don't hesitate to ask for help.

[Bug] CVE-2019-1002101

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Operation System: [e.g. Ubuntu, CentOS, macOS]
  • Kubernetes Version [e.g. v1.10.5, v1.11.7, v1.13.4]
  • Kubectl Version [e.g. v1.10.5, v1.11.7, v1.13.4]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.