Integrated Grep Plugin for the Kubectl Web Shell¶
In our recent release, we added support for plugins in the web based kubectl shell that users have access to after they authenticate to their Rafay Org. In this blog, we will describe how we have enhanced the developer experience for users of this feature by providing them with a "grep plugin".
Rafay's zero trust kubectl web shell is one of the most heavily used features by users of the Rafay platform because it provides secure kubectl access to authenticated users from any device from anywhere. They just need a web browser to login and perform kubectl operations on their cluster.
Plugins for Kubectl Web Shell¶
We intend to progressively add more plugins for kubectl as we continue to receive feedback from our customers. Authenticated users can list all available plugins by using the following command.
kubectl plugin list
In the example output below, you can see that there are two plugins configured and available on the Controller via the zero trust kubectl web shell.
The following compatible plugins are available:
/usr/local/bin/kubectl-argo-rollouts
/usr/local/bin/kubectl-grep
Grep Plugin for Kubectl¶
The standard kubectl CLI can be extended and customized by installing plugins.
The grep plugin for kubectl was developed to help developers search for pods without being forced to repeatedly type long and complex kubectl commands.
Integrated Help¶
Integrated help is available for the grep plugin. Users can type the following command to be presented with the various options and examples.
kubectl grep --help
Filter Kubernetes resources by matching their names
More info: https://github.com/guessi/kubectl-grep
Usage:
kubectl-grep [command]
Examples:
List all pods in default namespace
$ kubectl grep pods
List all pods in all namespaces
$ kubectl grep pods -A
List all pods in namespace "start-lab" which contains keyword "flash"
$ kubectl grep pods -n star-lab flash
A Real Life Example¶
Let us look at a real life example of how users can leverage this enhancement to dramatically improve their experience and reduce cognitive overload. Let's assume the developer/operator is trying to find all pods that have the word apple-pie in their name. Now, let us look at the difference in experience with the grep plugin for kubectl.
Without Grep¶
A typical user would try to list all the pods in the cluster and manually comb through them. This is extremely manual and cumbersome
kubectl get po -A
NAMESPACE NAME READY STATUS RESTARTS AGE
app-team-2 xwing-56f5b549cb-6hl8m 1/1 Running 0 33d
apple-juice apple-juice-84d967bf59-c7rql 1/1 Running 0 109d
apple-juice apple-juice-84d967bf59-hfpbz 1/1 Running 0 109d
apple-pie apple-pie-68986cd9-j2wtw 1/1 Running 0 66d
apple-pie apple-pie-68986cd9-s828j 1/1 Running 0 66d
calico-system calico-kube-controllers-75888fc669-94wvd 1/1 Running 1 (109d ago) 110d
calico-system calico-node-4vk9b 1/1 Running 1 (109d ago) 110d
calico-system calico-typha-65559b55d4-f7m88 1/1 Running 1 (109d ago) 110d
calico-system csi-node-driver-csrrk 2/2 Running 4 (87d ago) 110d
kube-system coredns-5d56f5d988-5w57b 1/1 Running 0 33d
kube-system coredns-5d56f5d988-8wgf2 1/1 Running 0 33d
kube-system k8sgpt-deployment-846cf64d8d-cn94z 1/1 Running 0 99d
kube-system kube-apiserver-demo-mks-apple1 1/1 Running 0 87d
kube-system kube-controller-manager-demo-mks-apple1 1/1 Running 3 (87d ago) 87d
kube-system kube-proxy-76qgh 1/1 Running 0 87d
kube-system kube-scheduler-demo-mks-apple1 1/1 Running 2 (87d ago) 87d
kube-system kubelet-rubber-stamp-97f995d56-w99n6 1/1 Running 1 (109d ago) 110d
kube-system tigera-operator-587978bb66-f276z 1/1 Running 5 (87d ago) 110d
rafay-infra opencost-8669999467-wbhlm 1/1 Running 0 33d
rafay-infra rafay-prometheus-adapter-5d8f4984f5-rwktx 1/1 Running 0 79d
rafay-infra rafay-prometheus-alertmanager-0 2/2 Running 0 79d
rafay-infra rafay-prometheus-helm-exporter-9979f844f-wdt5v 1/1 Running 0 79d
rafay-infra rafay-prometheus-kube-state-metrics-76b7944987-ccppt 1/1 Running 0 99d
rafay-infra rafay-prometheus-metrics-server-74f59ccb6c-qhvbl 1/1 Running 0 79d
rafay-infra rafay-prometheus-node-exporter-h98nv 1/1 Running 0 79d
rafay-infra rafay-prometheus-server-0 2/2 Running 0 79d
rafay-system cilium-cq49g 1/1 Running 0 33d
rafay-system cilium-operator-9fcbcb8b8-2skck 1/1 Running 0 33d
rafay-system controller-manager-v3-bdc69f44f-qw4nr 1/1 Running 0 26d
rafay-system edge-client-6cccd4b76-bxcx9 1/1 Running 0 2d19h
rafay-system gatekeeper-audit-59767d94cf-h844n 2/2 Running 1 (79d ago) 79d
rafay-system gatekeeper-controller-manager-849854cc75-44d5x 2/2 Running 0 79d
rafay-system gatekeeper-controller-manager-849854cc75-9ghr5 2/2 Running 0 79d
rafay-system gatekeeper-controller-manager-849854cc75-z696g 2/2 Running 0 79d
rafay-system rafay-connector-v3-7bd5d49cb4-jn92v 1/1 Running 0 26d
rafay-system v2-relay-agent-76786f9c4d-bw86w 1/1 Running 0 26d
With Grep¶
The user can now leverage the "grep plugin" to have a dramatically simpler experience. As you can see from the example below, out of long list of pods on the cluster, only two pods have the name "apple-pie" in their name. The developer was able to answer their question literally in 1 second.
kubectl grep po -A apple-pie
NAMESPACE NAME READY STATUS RESTARTS AGE
apple-pie apple-pie-68986cd9-j2wtw 1/1 Running 0 66d
apple-pie apple-pie-68986cd9-s828j 1/1 Running 0 66d
Try It Out¶
Sign up here for a free trial and try it out yourself. We have invested heavily on curated Get Started Guides that will help you get familiar with capabilities of Rafay's Kubernetes Operations Platform.
Sincere thanks to readers of our blog who spend time reading our product blogs. Please Contact the Rafay Product Team if you would like us to write about other topics.