┌─┐┌─┐┬─┐┬ ┬┌┐ ┌─┐┌─┐┌┬┐┬
└─┐│ ├┬┘│ │├┴┐├┤ │ │ │
└─┘└─┘┴└─└─┘└─┘└─┘└─┘ ┴ ┴─┘
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
- Configurable pruning: Remove global paths (e.g.
status) or kind-specific paths (e.g..metadata.revisionfor ConfigMaps). - Embedded default config: Bundled sensible defaults.
- Config lookup:
--config /path/to/config.yaml$SCRUBECTLPATH/config.yaml~/.config/scrubectl/config.yaml- Embedded default
- Export template:
--export-templatewrites out the default config for easy customization. - On-the-fly removals:
--path metadata.annotations.footo add extra pruning rules.
kubectl krew install scrubectlgit clone https://github.com/valinor/scrubectl.git
cd scrubectl
make all # builds bin/scrubectl# 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# Clean an existing YAML file
cat manifest.yaml | scrubectl > manifest.cleaned.yaml
# Read from stdin with custom config
scrubectl -- --config ./config.yaml < manifest.yamlscrubectl --export-template > ~/.config/scrubectl/config.yamlCustomize 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]--config <file>flag- Directory in
SCRUBECTLPATHenvironment variable $HOME/.config/scrubectl/config.yaml- Embedded defaults
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: RunningCommand:
scrubectl get deploy nginxOutput:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3PRs welcome!