Skip to content

SubhrajitPrusty/kubedump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kubedump

A CLI tool that snapshots live Kubernetes cluster resources into a structured local directory tree. Each resource is cleaned through kubectl-neat to strip runtime-only fields (managed fields, last-applied annotations, cluster IPs, resource versions), producing minimal, readable manifests suitable for Git.

Why

kubectl get -o yaml output is cluttered with fields that make diffs noisy and version control impractical. kubedump solves this by discovering all resources of interest, cleaning each one through kubectl-neat, and saving them in a consistent directory layout — one file per resource.

Helm releases are tracked as values.yaml rather than noisy rendered manifests.

Output layout

<cluster>/
  <namespace>/
    <Kind>/
      <resource-name>.yaml       # kubectl-neat cleaned manifest
    HelmRelease/
      <release-name>/
        values.yaml              # helm get values output

Prerequisites

Installation

git clone https://github.com/SubhrajitPrusty/kubedump.git
cd kubedump
go build -o kubedump .
# Move the binary somewhere on your PATH, e.g.:
mv kubedump /usr/local/bin/

Configuration

Create a kubedump.yaml file in your working directory mapping local directory names to kubectl context names. And optionally, a list of resource kinds to skip during discover/refresh.

Example kubedump.yaml:

clusters:
  api-cluster: arn:aws:eks:ap-south-1:123456789:cluster/api-cluster
  ws-cluster: arn:aws:eks:ap-south-1:123456789:cluster/ws-cluster
ignore_kinds:
  - ConfigMap
  - Secret

Usage

discover

Fetch all resources from every cluster (or a specific one) and write them to the directory tree.

# All clusters from kubedump.yaml
kubedump discover

# Include resources owned by Helm
kubedump discover --include-helm

# Single namespace / explicit context
kubedump discover --namespace default --context my-ctx --cluster my-cluster

# Custom resource kinds
kubedump discover --kinds Deployment,Service,ConfigMap

Default kinds fetched: Deployment, StatefulSet, DaemonSet, CronJob, Service, Ingress, ConfigMap, HorizontalPodAutoscaler, ServiceAccount, PodDisruptionBudget.

refresh

Re-fetch every YAML file that already exists in the directory tree from the live cluster. Useful for keeping snapshots up to date without a full rediscover.

kubedump refresh

# Limit to a specific namespace
kubedump refresh --namespace default

prune-helm

Delete dumped YAML files whose content shows managed-by: Helm. Files inside HelmRelease/ directories are preserved. Empty directories are cleaned up afterwards.

# Preview what would be deleted
kubedump prune-helm --dry-run

# Actually delete
kubedump prune-helm

Global flags

Flag Description
--base-dir <dir> Base directory for the dump (default: current directory)
--dry-run Print actions without writing or deleting anything

Development

go mod tidy
go build -o kubedump .

About

snapshot your kubernetes clusters

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages