Skip to content

v0.2.3

Choose a tag to compare

@github-actions github-actions released this 02 May 17:06
6deafba

v0.2.3 — Multi-snapshot / trending

New commands

kubectl snapshot history
Lists all previously captured snapshots from a local index (~/.kubectl-snapshot/history.json).
The index is maintained automatically — every successful capture adds an entry.
Use --no-index to skip indexing a specific capture, or --index <path> to use a custom index file.

# List all indexed snapshots (newest first)
kubectl snapshot history
kubectl snapshot history --index /custom/path/history.json

kubectl snapshot trend [snapshot.json ...]
Compares pod counts, node counts, total restarts, and warning event counts across two or more snapshots.
Pass files explicitly or omit them to read the last N entries from the history index.

# Compare two specific snapshots
kubectl snapshot trend before.json after.json

# Compare the 5 most recent captures from history
kubectl snapshot trend --last 5

# Compare 3 snapshots from a custom index
kubectl snapshot trend --index /custom/path/history.json --last 3

New flags

capture --selector/-l <selector>
Scopes a capture to resources matching a Kubernetes label selector — forwarded to every API list call.

kubectl snapshot capture -o snap.json --selector app=frontend
kubectl snapshot capture -o snap.json -l env=prod

analyze --namespace/-n <namespace>
Restricts the analysis report to a single namespace.
Cluster-scoped records (nodes, PersistentVolumes, etc.) are always included regardless of this filter.

kubectl snapshot analyze snap.json --namespace production
kubectl snapshot analyze snap.json -n staging

Internals

  • internal/snapshot/history.goLoadIndex, SaveIndex, AddToIndex, DefaultIndexPath
  • internal/snapshot/trend.goComputeTrend, RenderTrend, TrendPoint, TrendReport
  • internal/snapshot/io.go — added StatBundle helper for recording file sizes in the history index
  • Namespace filter applied before both the pre-pass index-building loop and the main analysis loop so cross-reference indexes (service set, network policy map) are also namespace-scoped

Install

# krew
kubectl krew install snapshot

# direct (linux/amd64)
curl -L https://github.com/whtssub/kubectl-snapshot/releases/download/v0.2.3/kubectl-snapshot_Linux_x86_64.tar.gz | tar xz
mv kubectl-snapshot ~/.local/bin/