# Kubectl Grep
[![CircleCI](https://img.shields.io/circleci/build/github/guessi/kubectl-grep?token=39cb1435f15bbd1fd965997db3484aed48d458b0)](https://circleci.com/gh/guessi/kubectl-grep)
[![GoDoc](https://godoc.org/github.com/guessi/kubectl-grep?status.svg)](https://godoc.org/github.com/guessi/kubectl-grep)
[![Go Report Card](https://goreportcard.com/badge/github.com/guessi/kubectl-grep)](https://goreportcard.com/report/github.com/guessi/kubectl-grep)
[![GitHub release](https://img.shields.io/github/release/guessi/kubectl-grep.svg)](https://github.com/guessi/kubectl-grep/releases/latest)
[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/guessi/kubectl-grep)](https://github.com/guessi/kubectl-grep/blob/master/go.mod)
Filter Kubernetes resources by matching their names
# Requirements
- Kubernetes 1.17.0+
- Kubectl 1.17.0+
- Krew 0.4.0+
# Compatibility
please refer to [Kubernetes version policy](https://kubernetes.io/docs/setup/release/version-skew-policy/#kubectl) and [CHANGELOG](CHANGELOG.md) for supported version matrix.
Example: `kubectl-grep` build with Kubernetes-1.19.x should be compatable with Kubernetes cluster version 1.18, 1.19, 1.20.
# 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 are quite annoyed.
Before change, we usually filter pods by the following commands,
$ kubectl get pods | grep "keyword"
$ kubectl get pods -o wide | grep "keyword"
$ kubectl get pods -n "my-ns" | grep "keyword"
$ kubectl get pods -A | grep "keyword"
$ kubectl get pods -l "key=value" | grep "keyword"
$ kubectl get pods -l "key=value" -n "my-ns" | grep "keyword"
$ kubectl get pods -l "key=value" -A | grep "keyword"
With this plugin installed, you can filter pod with `kubectl grep` easily
$ kubectl grep pods "keyword"
$ kubectl grep pods "keyword" -o wide
$ kubectl grep pods "keyword" -n "my-ns"
$ kubectl grep pods "keyword" -A
$ kubectl grep pods "keyword" -l "key=value"
$ kubectl grep pods "keyword" -l "key=value" -n "my-ns"
$ kubectl grep pods "keyword" -l "key=value" -A
# Supported Resources
- [X] ConfigMaps
- [X] DaemonSets
- [X] Deployments
- [X] HPAs
- [X] Ingresses
- [X] Jobs
- [X] Nodes
- [X] Pods
- [X] Secrets
- [X] StatefulSets
# Installation
Installation via [krew](https://krew.sigs.k8s.io/docs/user-guide/setup/install/)
$ kubectl krew version # make sure you are running 0.4.0+
$ kubectl krew install grep
$ kubectl krew upgrade
Manual Installation
$ export KUBECTL_GREP_VERSION=$(curl -s https://api.github.com/repos/guessi/kubectl-grep/releases/latest | jq -r .tag_name)
$ curl -L -O https://github.com/guessi/kubectl-grep/releases/download/${KUBECTL_GREP_VERSION}/kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ tar zxvf kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ mv kubectl-grep /usr/local/bin
$ chmod +x /usr/local/bin/kubectl-grep
# Examples
List all pods in default namespace,
$ kubectl grep pods
List all pods in all namespaces,
$ kubectl grep pods -A
List all pods with specific keyword, under specific namespace,
$ kubectl grep pods -n star-lab flash
# 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
Any plan to support Kubernetes version before 1.10.0?
sorry, it only support Kubernetes 1.10.0+
I'm now running Kubernetes 1.10.0, do I need to upgrade my cluster?
nope, the only requirement is to upgrade your `kubectl` to 1.13.0+
Can I run Kubernetes 1.12.0 with kubectl 1.13.0?
sure, no problem
# Reference
- [Kubectl Plugins](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/)
# License
[Apache-2.0](LICENSE)
LunaKnight
- 粉丝: 37
- 资源: 4705
最新资源
- (175923204)JAVAWEB校园订餐系统项目源码.rar
- (170624028)ffmpeg+SDL2的简易流媒体播放器,仅供大家参考学习 缺少dll库,在我资源里面下载ffmpeg+SDL2较新发布那个有
- 基于java+ssm+mysql+微信小程序的付费自习室系统 源码+数据库(高分毕业设计).zip
- (14638450)最简单的基于FFMPEG+SDL的音频播放器(2014.5.6)
- 基于java+springboot+mysql+微信小程序的校园点餐系统 源码+数据库+论文(高分毕业设计).zip
- (174871244)自适应动态规划(近似动态规划)-ADP MATLAB-MATLAB编程
- (175426820)ChatGPT接入项目实例【 AI问答小程序源码-内置3.5接口】.rar
- (21614630)STM32F10xUSB开发工具包-cn 20181126
- 简单的登录系统-MySQL+Node.JS服务端+HTML+JS
- 全自动焊锡机sw18可编辑全套技术资料100%好用.zip
- 平台所需服务器、数据库、操作系统安全技术要点梳理
- 使用py异步编程实现接口并发测试
- 批量QSO生成ADIF工具是一款方便快捷的工具,用于生成ADIF格式的QSO日志文件 通过输入一串QSO信息,用户可以轻松生成符合规范的ADIF文件,以便快速上传lotw日志
- IMG_1134.JPG
- qt/C++ 学习笔记 MD5文件重复搜索工具
- html+css 圣诞树html网页代码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈