# 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)
没有合适的资源?快使用搜索试试~ 我知道了~
kubectl-grep:通过匹配名称来过滤Kubernetes资源
共34个文件
go:23个
md:4个
yaml:1个
需积分: 37 4 下载量 51 浏览量
2021-05-03
14:14:09
上传
评论
收藏 50KB ZIP 举报
温馨提示
Kubectl Grep 通过匹配名称来过滤Kubernetes资源 要求 Kubernetes 1.17.0以上 Kubectl 1.17.0+ 克鲁0.4.0+ 兼容性 请参阅和以获取支持的版本矩阵。 示例:使用Kubernetes-1.19.x构建的kubectl-grep应该与Kubernetes集群版本1.18、1.19、1.20兼容。 我们为什么需要它? 与Kubernetes一起玩是我的日常工作,通常我在搜索异常Pod时通过pipe , grep ,-- --label ,-- --field-selector等搜索Pod,但是键入这么长的命令却很烦人。 更改之前,我们通常通过以下命令过滤Pod, $ kubectl get pods | grep "keyword" $ kubectl get pods -o
资源推荐
资源详情
资源评论
收起资源包目录
kubectl-grep-master.zip (34个子文件)
kubectl-grep-master
pkg
client
client.go 677B
constants
constants.go 2KB
resources
daemonsets.go 3KB
pods.go 2KB
nodes.go 2KB
configmaps.go 1KB
hpas.go 1KB
jobs.go 1KB
secrets.go 1002B
deployments.go 2KB
statefulsets.go 2KB
ingresses.go 2KB
options
options.go 336B
utils
apps.go 1KB
networking.go 609B
common.go 1KB
batch.go 533B
core.go 2KB
autoscaling.go 609B
cmd
resources.go 5KB
version.go 534B
root.go 2KB
.krew.yaml 1KB
.github
ISSUE_TEMPLATE
bug_report.md 783B
feature_request.md 635B
LICENSE 11KB
main.go 90B
.gitignore 289B
CHANGELOG.md 3KB
.circleci
config.yml 3KB
Makefile 2KB
go.sum 54KB
README.md 4KB
go.mod 201B
共 34 条
- 1
资源评论
LunaKnight
- 粉丝: 36
- 资源: 4705
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功