A kubectl plugin for easier query and operate k8s cluster.

kube-query

LICENSE

A kubectl plug-in that makes it easier to query and manipulate K8S clusters. (what is kubectl plug-in ?)

demo

Kube-query support some resource shortcut query, like: pods, deploy, service, configmap, dameonset, job, nodes. We can get their simple information, relationship or login container.

Kube-query accepts the same commands as the kubectl, except you don't need to provide the kubectl prefix. So it doesn't require the additional cost to use this cli.

Installation

Downloading standalone binary

Binaries are available from (github release).

macOS (darwin) - amd64
wget https://github.com/Shadow-linux/kube-query/releases/download/v1.0.0/kube-query_v1.0.0_darwin_amd64.zip
unzip kube-query_v1.0.0_darwin_amd64.zip
chmod +x kube-query.darwin-amd64
sudo mv bin/kube-query.darwin-amd64 /usr/local/bin/kube-query
Linux - amd64
wget https://github.com/Shadow-linux/kube-query/releases/download/v1.0.0/kube-query_v1.0.0_linux_amd64.zip
unzip kube-query_v1.0.0_linux_amd64.zip
chmod +x kube-query.linux-amd64
sudo mv bin/kube-query.linux-amd64 /usr/local/bin/kube-query
Source code
# install go version 1.17+ first.
wget https://github.com/Shadow-linux/kube-query.git
cd kube-query
make build
mv bin/kube-query /usr/local/bin/kube-query

Goal

Hopeful easier to query and manipulate K8S cluster.

Usage

  • config your kubeconfig
export KUBECONFIG=~/.kube/config

Start way

  1. use in kubectl
mv /usr/local/bin/kube-query /usr/local/bin/kubectl-query
kubectl query [--debug]
  1. standalone
./kube-query [--debug]

Basic Command

  • Clear console
kube-query ~ > clear
  • Show help info for kube-query and kubectl native command.
kube-query ~ > help
  • Set global namespace
kube-query ~ > use default
Set namespace default
kube-query ~ > use kube-system
Set namespace kube-system
# all namespace can not use in native kubectl command.
# set namespace all is not safety operation. 
kube-query ~ > use all
Set namespace all
  • Run shell command. We can easier auto complete the file path, when you input a word start with / or ./.
kube-query ~ > @ ls /tmp;
  • Close console.
# exit | quit | ctrl + D
kube-query ~ > exit

Resource command

resource format: ResourceName.Namespace,

  • Output mode.
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default [-o desc]
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default -o [yaml|desc|json]
  • Show labels
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default -l
Labels: 
app=jtthink-ngx
pod-template-hash=8669b5c9d
  • Show events
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default -e
Events: 
TYPE    REASON  MESSAGE 
  • Show relationship
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default -r
Relevant relationship:
##### Service #####
NAME                    TYPE            CLUSTER-IP      EXTERNAL-IP     PORTS        
jtthink-ngx-svc         ClusterIP       10.99.226.31                    38080/TCP       
jtthink-ngx-svc-1       NodePort        10.99.47.202                    81:30080/TCP    

##### ReplicaSet #####
NAME                    DESIRED CURRENT READY 
jtthink-ngx-8669b5c9d   1       1       1       

##### Deployment #####
NAME            READY   UP-TO-DATE      AVAILABLE 
jtthink-ngx     1/1     1               1   
  • Connect to container
# connect specify container name and shell.
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default -i jt-nginx -s /bin/sh
Connect to container: jtthink-ngx-8669b5c9d-xwljg.jt-nginx
Commannd: /bin/sh 
/ # exit
Connection closed.

# connect default container.
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default -i
Connect to container: jtthink-ngx-8669b5c9d-xwljg.
Commannd: sh 
/ # exit
Connection closed.
  • Use grep command to filter info;
kube-query ~ > pods jtthink-ngx-8669b5c9d-xwljg.default -l |grep -A 1  -i labels
Labels: 
app=jtthink-ngx

Native kubectl command

  • example: get
# we can use `Tab` to auto complete. 
kube-query ~ > get nodes k8s-01;
kube-query ~ > get pods;
kube-query ~ > get svc;

The same way you normally use Kubectl anyway, just you do not need input kubectl.

Author

ShadowYD

LICENSE

This software is licensed under the MIT License (See LICENSE).

Similar Resources

A kubectl plugin for finding decoded secret data with productive search flags.

kubectl-secret-data What is it? This is a kubectl plugin for finding decoded secret data. Since kubectl only outputs base64-encoded secrets, it makes

Dec 2, 2022

A 'kubectl' plugin for interacting with Clusternet.

kubectl-clusternet A kubectl plugin for interacting with Clusternet. Installation Install With Krew kubectl-clusternet can be installed using Krew, pl

Aug 14, 2022

Kubectl plugin to run curl commands against kubernetes pods

kubectl-curl Kubectl plugin to run curl commands against kubernetes pods Motivation Sending http requests to kubernetes pods is unnecessarily complica

Dec 22, 2022

A kubectl plugin for finding decoded secret data with productive search flags.

kubectl-secret-data What is it? This is a kubectl plugin for finding decoded secret data. Since kubectl outputs base64-encoded secrets basically, it m

Dec 2, 2022

A kubectl plugin to evict pods

kubectl-evict A kubectl plugin to evict pods. This plugin is good to remove a pod from your cluster or to test your PodDistruptionBudget. 💿 Installat

Dec 7, 2022

kubectl plugin for generating nginx-ingress compatible basic-auth secrets on kubernetes clusters

kubectl-htpasswd kubectl plugin for easily generating hashed basic auth secrets. Supported hash algorithms bcrypt Examples Create the secret on the cl

Jul 17, 2022

🦥 kubectl plugin to easy to view pod

kubectl-lazy Install curl -sSL https://mirror.ghproxy.com/https://raw.githubusercontent.com/togettoyou/kubectl-lazy/main/install.sh | bash Or you can

Oct 13, 2022

A very simple, silly little kubectl plugin / utility that guesses which language an application running in a kubernetes pod was written in.

A very simple, silly little kubectl plugin / utility that guesses which language an application running in a kubernetes pod was written in.

Mar 9, 2022

Kubectl plugin shows pod x node matrix with suitable colors to mitigate troubleshooting effort.

kubectl-pod-node-matrix WORK IN PROGRESS!! This plugin shows pod x node matrix with suitable colors to mitigate troubleshooting effort. Details Troubl

May 11, 2022
A kubectl plugin for getting endoflife information about your cluster.
A kubectl plugin for getting endoflife information about your cluster.

kubectl-endoflife A kubectl plugin that checks your clusters for component compatibility and Kubernetes version end of life. This plugin is meant to a

Jul 21, 2022
A kubectl plugin to query multiple namespace at the same time.

kubemulti A kubectl plugin to query multiple namespace at the same time. $ kubemulti get pods -n cdi -n default NAMESPACE NAME

Mar 1, 2022
kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl
kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl

Kubectl-fzf kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl. Table of Contents Kubectl-fzf Table of Contents Features Requirem

Nov 3, 2021
Kubectl golang - kubectl krew template repo

kubectl krew template repo There's a lot of scaffolding needed to set up a good

Jan 11, 2022
Kubectl Locality Plugin - A plugin to get the locality of pods

Kubectl Locality Plugin - A plugin to get the locality of pods

Nov 18, 2021
K8s-cinder-csi-plugin - K8s Pod Use Openstack Cinder Volume

k8s-cinder-csi-plugin K8s Pod Use Openstack Cinder Volume openstack volume list

Jul 18, 2022
CoreDNS plugin implementing K8s multi-cluster services DNS spec.

corends-multicluster Name multicluster - implementation of Multicluster DNS Description This plugin implements the Kubernetes DNS-Based Multicluster S

Dec 3, 2022
Jan 4, 2022
Kubectl plugin to ease sniffing on kubernetes pods using tcpdump and wireshark
Kubectl plugin to ease sniffing on kubernetes pods using tcpdump and wireshark

ksniff A kubectl plugin that utilize tcpdump and Wireshark to start a remote capture on any pod in your Kubernetes cluster. You get the full power of

Jan 4, 2023
kubectl plugin for signing Kubernetes manifest YAML files with sigstore
kubectl plugin for signing Kubernetes manifest YAML files with sigstore

k8s-manifest-sigstore kubectl plugin for signing Kubernetes manifest YAML files with sigstore ⚠️ Still under developement, not ready for production us

Nov 28, 2022