Skip to content

Add deployment schema#1

Open
cpmores wants to merge 2 commits into
bazelment:mainfrom
cpmores:add-deployment-schema
Open

Add deployment schema#1
cpmores wants to merge 2 commits into
bazelment:mainfrom
cpmores:add-deployment-schema

Conversation

@cpmores

@cpmores cpmores commented Jun 8, 2026

Copy link
Copy Markdown

Title: Add Deployments as a queryable resource type

Body

Adds Kubernetes Deployments as the fifth resource type that kq can
load and query, alongside pods, nodes, namespaces, and daemon_sets.

What this does

Users can now include a "deployments" array in their snapshot JSON
and query it via the deployments SQL view:

SELECT metadata.name, status.replicas, status.readyReplicas
FROM deployments
WHERE status.availableReplicas < spec.replicas;


Changes by layer

┌─────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│              Layer              │                                                                What changed                                                                │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/schema/kubernetes.rs         │ Import k8s-openapi Deployment types; add deployments field to ClusterSnapshot and SnapshotSummary                                          │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/schema/nested.rs             │ Add deployments_nested_schema() — metadata, spec (replicas, selector, strategy, template), status (replicas, conditions), ready_percentage │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/schema/mod.rs                │ Add flat deployments_schema() in SchemaRegistry                                                                                            │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/loader/resource_table.rs     │ Register deployments → deployments.ndjson.gz / .arrow / .parquet                                                                           │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/loader/mod.rs                │ Add ConvertingDeployments loading phase                                                                                                    │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/query/mod.rs                 │ Add table description for deployments                                                                                                      │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/synthetic/mod.rs             │ Generate 10 synthetic Deployment workloads with replica counts, conditions, and container specs                                            │
├─────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kq/tests/golden_deployment.json │ Golden test fixture for nested schema parsing                                                                                              │
└─────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

How I tested

Unit tests across all affected crates

  bazel test -c opt //kq:kq_lib_test \
    //kq/loader:loader_test \
    //kq/query:query_test \
    //kq/schema:schema_test \
    //kq/synthetic:synthetic_test \
    //kq/tests:synthetic_snapshot_tests

End-to-end: generate a synthetic snapshot with deployments and query it

  bazel run -c opt //kq/tools:synthetic_snapshot -- \
    --output /tmp/kq-deployments --cluster demo --nodes 10 --overwrite
  bazel-bin/kq/kq /tmp/kq-deployments \
    --query "SELECT metadata.name, spec.replicas, status.readyReplicas FROM deployments"

Verify all five views are registered

 bazel-bin/kq/kq /tmp/kq-deployments --query ".tables"

Note

Medium Risk
New public SQL view and snapshot field extend the documented contract; changes are additive and mirror existing daemon_set patterns with broad test coverage.

Overview
Adds Kubernetes Deployments as a fifth loadable, SQL-queryable resource alongside pods, nodes, namespaces, and daemon sets.

Snapshots can include a "deployments" array (or deployments.ndjson.gz / Arrow / Parquet artifacts). The loader registers the resource via RESOURCE_TABLES, adds a ConvertingDeployments loading phase, and exposes the deployments DataFusion view. Schema work adds k8s-openapi Deployment types on ClusterSnapshot, flat and nested Arrow schemas (metadata, spec including template containers, status, ready_percentage), plus a golden JSON fixture and synthetic generator output for ten sample workloads.

Tests and docs expectations are updated so deployments is part of the pinned user-facing view set.

Reviewed by Cursor Bugbot for commit a5993ab. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant