Skip to content

Latest commit

 

History

History
77 lines (58 loc) · 2.06 KB

README_examples.md

File metadata and controls

77 lines (58 loc) · 2.06 KB

kubectl-sql Logo

kubectl-sql

Examples

All namespaces

# Get pods that hase name containing "ovs"
kubectl-sql --all-namespaces get pods where "name ~= 'ovs'"
AMESPACE    	NAME               	PHASE  	hostIP        	CREATION_TIME(RFC3339)       	
openshift-cnv	ovs-cni-amd64-5vgcg	Running	192.168.126.58	2020-02-10T23:26:31+02:00    	
openshift-cnv	ovs-cni-amd64-8ts4w	Running	192.168.126.12	2020-02-10T22:01:59+02:00    	
openshift-cnv	ovs-cni-amd64-d6vdb	Running	192.168.126.53	2020-02-10T23:13:45+02:00
...

Using Regexp

# 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
...

SI Units

# 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"

...  json
{
  "storage": "10Gi"
}
...

Comparing fields

# Get replicas sets with 3 replicas but less ready relicas
kubectl-sql --all-namespaces get rs where "spec.replicas = 3 and status.readyReplicas < spec.replicas"

...

Join

# 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
...

Print help

kubectl-sql --help
...