MCPcopy Index your code
hub / github.com/aquasecurity/kube-query

github.com/aquasecurity/kube-query @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
49 symbols 179 edges 14 files 31 documented · 63%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

kube-query

kube-query is an extension for osquery, letting you visualize your cluster using sql queries.

Deployment

Prerequisites

Go v1.12+

build

$ export GO111MODULE=on 
$ go build kube-query.go 

Running kube-query

When running kube-query, you should always pass the -kubeconfig flag, specifying the path to your kubeconfig file.

osqueryi

When using the osqueryi tool you can easily register kube-query by passing the -socket parameter to kube-query on another process. For example:
./kube-query -socket="/path/to/osquery/socket" -kubeconfig="/path/to/kubeconfig.yml"

One way to get the path to the osquery socket is like this:

osqueryi --nodisable_extensions
osquery> select value from osquery_flags where name = 'extensions_socket';
+-----------------------------------+
| value                             |
+-----------------------------------+
| /Users/USERNAME/.osquery/shell.em |
+-----------------------------------+

There are many other options to automatically register extensions.

Example Queries

# query all kube-system pods
SELECT * FROM kubernetes_pods WHERE namespace="kube-system";

# query all containers created by kubernetes
SELECT * FROM kubernetes_containers;

# query all pods that runs with a privileged container   
SELECT * 
 FROM kubernetes_containers 
 JOIN kubernetes_pods 
 ON kubernetes_containers.pod_uid=kubernetes_pods.uid
 WHERE privileged="True";

Extension points exported contracts — how you extend this code

Table (Interface)
Table inteface defines the basic Table implementation mechanism for os-query [5 implementers]
tables/types.go

Core symbols most depended-on inside this repo

NewNodesTable
called by 4
tables/nodes.go
NewPodsTable
called by 4
tables/pods.go
NewVolumesTable
called by 4
tables/volumes.go
NewDeploymentsTable
called by 4
tables/deployments.go
NewContainersTable
called by 4
tables/containers.go
Generate
called by 2
tables/nodes.go
Generate
called by 2
tables/pods.go
Generate
called by 2
tables/volumes.go

Shape

Function 22
Method 20
Struct 6
Interface 1

Languages

Go100%

Modules by API surface

tables/volumes.go8 symbols
tables/pods.go5 symbols
tables/nodes.go5 symbols
tables/deployments.go5 symbols
tables/containers.go5 symbols
tables/types.go4 symbols
utils/common.go3 symbols
tables/containers_test.go3 symbols
utils/helpers.go2 symbols
tables/volumes_test.go2 symbols
tables/pods_test.go2 symbols
tables/nodes_test.go2 symbols

For agents

$ claude mcp add kube-query \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact