Skip to content

Valinor/scrubectl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scrubectl

┌─┐┌─┐┬─┐┬ ┬┌┐ ┌─┐┌─┐┌┬┐┬  
└─┐│  ├┬┘│ │├┴┐├┤ │   │ │  
└─┘└─┘┴└─└─┘└─┘└─┘└─┘ ┴ ┴─┘

scrubectl is a versatile CLI tool and kubectl plugin for sanitizing Kubernetes YAML manifests by stripping out unwanted fields. It can be used as:

  • A kubectl plugin: kubectl scrubectl ...
  • A standalone filter: cat myfile.yaml | scrubectl

Features

  • Configurable pruning: Remove global paths (e.g. status) or kind-specific paths (e.g. .metadata.revision for ConfigMaps).
  • Embedded default config: Bundled sensible defaults.
  • Config lookup:
    1. --config /path/to/config.yaml
    2. $SCRUBECTLPATH/config.yaml
    3. ~/.config/scrubectl/config.yaml
    4. Embedded default
  • Export template: --export-template writes out the default config for easy customization.
  • On-the-fly removals: --path metadata.annotations.foo to add extra pruning rules.

Installation

Via Krew (not working, work in progress)

kubectl krew install scrubectl

From Source

git clone https://github.com/valinor/scrubectl.git
cd scrubectl
make all      # builds bin/scrubectl

Usage

with kubectl (not a plugin currently, work in progress)

# Basic: strip default paths
scrubectl get deploy mydeploy

# With explicit config
scrubectl get pod mypod --config ./config.yaml

# Add extra removal paths
scrubectl get svc mysvc --path metadata.annotations.foo

Standalone filter

# Clean an existing YAML file
cat manifest.yaml | scrubectl > manifest.cleaned.yaml

# Read from stdin with custom config
scrubectl -- --config ./config.yaml < manifest.yaml

Export default config template

scrubectl --export-template > ~/.config/scrubectl/config.yaml

Customize config.yaml:

# ~/.config/scrubectl/config.yaml
paths:
  - [status]
  - [metadata, annotations, kubectl.kubernetes.io/last-applied-configuration]
kindPaths:
  ConfigMap:
    - [metadata, revision]
  Deployment:
    - [spec, template, metadata, annotations, rollout]

Configuration Precedence

  1. --config <file> flag
  2. Directory in SCRUBECTLPATH environment variable
  3. $HOME/.config/scrubectl/config.yaml
  4. Embedded defaults

Example

Given a Deployment YAML with status and rollout annotation:

apiVersion: apps/v1
kind: Deployment
metadata:
  uid: 4c2e3d1a-b1d2-4f7a-9b76-1d9e3e15c47a
  resourceVersion: "123456"
  creationTimestamp: "2025-08-18T10:12:34Z"
  name: nginx
  annotations:
    rollout: v2.0
status:
  availableReplicas: 3
spec:
  replicas: 3
status:
  phase: Running

Command:

scrubectl get deploy nginx

Output:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 3

Contributing

PRs welcome!


License

MIT

About

CLI tool and kubectl plugin for sanitizing Kubernetes YAML manifests

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors