Skip to content

LobsterMan/kubesql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kubesql

Query kubernetes clusters using SQL

Installation

Install locally (editable mode)

pip install -e .

Install from git

pip install git+https://github.com/LobsterMan/kubesql.git

Usage

Basic Usage

kubesql SELECT * from pods WHERE namespace = 'kube-system' > pods.csv

Basic query

SELECT * from pods WHERE namespace = 'kube-system'

Select specific columns

Functions

SQL Syntax

####Full usage

SELECT
    [ * | expression [ [ AS ] output_name ] [, ...] ]
    [ FROM kubernetes_resource]
    [ WHERE condition ]
    [ LIMIT count ]

expression

expression can be "column" name, or fuc(column_name)

functions

cell() - Applied by default. If the cell is a list, will return "", if the cell is dict, will return "" else will return the string representation of the cell

This default behavior is to keep outputs readable when selecting *

str() - Returns the string representation of the cell

json() - returns the json representation of the cell

condition

Supported conditions are:

namespace - kubernetes namespace. If no namespace is selected, --all-namespaces will be used

kubernetes_resource

Any valid kubernetes resource type

TODO

  • SELECT sub columns (e.g. metadata.name)
  • SELECT lists (e.g. spec.pods[].image)
  • WHERE Conditions applied to data (other than namespace)
  • output type (csv or table)
  • refactor object oriented
  • ORDER BY

Credits

https://github.com/mozilla/moz-sql-parser

https://github.com/jgehrcke/python-cmdline-bootstrap

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages