Giter Club home page Giter Club logo

kubectl-sql's Introduction

Go Report Card Build Status License

kubectl-sql Logo

kubectl-sql

kubectl-sql is a kubectl plugin that use SQL like language to query the Kubernetes cluster manager

More docs

Install

Using krew plugin manager to install:

kubectl krew install sql
kubectl sql --help

Using Fedora Copr:

dnf copr enable yaacov/kubesql
dnf install kubectl-sql

From source:

git clone [email protected]:yaacov/kubectl-sql.git
cd kubectl-sql

make

What can I do with it ?

kubectl-sql let you select Kubernetes resources based on the value of one or more resource fields, using human readable easy to use SQL like query language. It is also posible to find connected resources useing the join command.

More kubectl-sql examples

# Get all pods from current namespace scope, that has a name starting with "virt-" and
# IP that ends with ".84"
kubectl-sql get pods where "name ~= '^virt-' and status.podIP ~= '[.]84$'"
AMESPACE	NAME                          	PHASE  	hostIP        	CREATION_TIME(RFC3339)       	
default  	virt-launcher-test-bdw2p-lcrwx	Running	192.168.126.56	2020-02-12T14:14:01+02:00
...
# Get all persistant volume clames that are less then 20Gi, and output as json.
kubectl-sql -o json get pvc where "spec.resources.requests.storage < 20Gi"
...
# Display non running pods by nodes for all namespaces.
kubectl-sql join nodes,pods on \
    "nodes.status.addresses.1.address = pods.status.hostIP and not pods.phase ~= 'Running'" -A
...
# Filter replica sets with less ready-replicas then replicas"
kubectl-sql --all-namespaces get rs where "status.readyReplicas < status.replicas"

Output formats:

--output flag Print format
table Table
name Names only
yaml YAML
json JSON

Alternatives

jq

jq is a lightweight and flexible command-line JSON processor. It is possible to pipe the kubectl command output into the jq command to create complicated searches ( Illustrated jq toturial )

https://stedolan.github.io/jq/manual/#select(boolean_expression)

kubectl --field-selector

Field selectors let you select Kubernetes resources based on the value of one or more resource fields. Here are some examples of field selector queries.

https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/

kubectl-sql's People

Contributors

rollandf avatar yaacov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.