Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gerald1248/kubectl-match-name
regex matching for resource names
https://github.com/gerald1248/kubectl-match-name
kubectl kubectl-plugins
Last synced: 2 months ago
JSON representation
regex matching for resource names
- Host: GitHub
- URL: https://github.com/gerald1248/kubectl-match-name
- Owner: gerald1248
- License: mit
- Created: 2019-02-07T09:28:07.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-31T09:35:25.000Z (about 3 years ago)
- Last Synced: 2024-08-02T06:14:09.160Z (6 months ago)
- Topics: kubectl, kubectl-plugins
- Language: Go
- Size: 18.6 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-kubectl-plugins - kubectl-match-name
README
kubectl-match-name
==================Access pods quickly without using the clipboard or listing all pods first. Here are some typical use cases:
```
$ kubectl logs `kubectl match-name proxy` -f
I0207 12:51:25.322909 1 server.go:444] Version: v1.10.0
...
$ kubectl match-name proxy
kube-proxy-cvtm5
$ kubectl match-name -k svc .
default-http-backend
$ kubectl match-name minikube
etcd-minikube kube-addon-manager-minikube kube-apiserver-minikube kube-controller-manager-minikube kube-scheduler-minikube
```Let's take a closer look at the first example. What have we gained? This line replaces two common approaches. In many cases we would use the clipboard or type in the hash component of the name:
```
$ kubectl get po | grep proxy
kube-proxy-cf2df 1/1 Running 0 5h
kube-proxy-8dj6v 1/1 Running 0 5h
kube-proxy-s6wvq 1/1 Running 0 5h
$ kubectl logs kube-proxy-cf2df -f
```What about a one-liner? It's straightforward but hardly concise:
```
$ kubectl logs `kubectl get po --no-headers | grep proxy | cut -d' ' -f1 | head -n1` -f
```Why not just a shell script? Mainly because it probably will not work as intended on Windows. It is hard to overestimate the number of Kubernetes users using `kubectl` via Git Bash or PowerShell.
Note that although the binary itself is called `kubectl-match_name`, it is invoked by the command `kubectl match-name`.
## Usage
```
$ kubectl match-name -h
Usage: kubectl-match_name [-kubeconfig=PATH] [-a] [-k KIND] [-n NAMESPACE] REGEX
-A match in all namespaces
-a return all matching objects
-c count matching objects (implies -a)
-k string
match objects of kind (default "pod")
-kubeconfig string
absolute path to the kubeconfig file
-n string
namespace
```The search expression is interpreted by the Golang `regexp` package (sadly not PCRE).
## Run
To try the plugin on your computer, download one of the release binaries above (Linux, Mac, Windows).## Build
```
$ make
$ sudo make install
```