Query kubernetes clusters using SQL
Install locally (editable mode)
pip install -e .
Install from git
pip install git+https://github.com/LobsterMan/kubesql.git
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
####Full usage
SELECT
[ * | expression [ [ AS ] output_name ] [, ...] ]
[ FROM kubernetes_resource]
[ WHERE condition ]
[ LIMIT count ]
expression can be "column" name, or fuc(column_name)
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
Supported conditions are:
namespace - kubernetes namespace. If no namespace is selected, --all-namespaces
will be used
Any valid kubernetes resource type
- 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