KubeTidy helps you clean up and manage Kubernetes kubeconfig files. It removes unreachable clusters, keeps related contexts and users in sync, exports selected contexts, and merges multiple kubeconfig files without stripping supported auth or cluster fields.
- CLI support for Linux, macOS, and Windows
- PowerShell support via
Invoke-KubeTidy - Krew plugin support via
kubectl kubetidy - Cleanup of unreachable clusters with backup and dry-run support
- Configurable probe timeout for slow or distant cluster endpoints
- Listing of clusters and contexts
- Kubeconfig report mode for orphaned contexts, unused users, and duplicate servers
- Kubeconfig doctor mode for health checks and actionable warnings
- Structured output in
text,json, oryaml - Export of selected contexts to a filtered kubeconfig
- Merge of multiple kubeconfig files while preserving supported fields and reporting duplicate-name skips
- Multi-file
KUBECONFIGsupport with configurable merge strategy - Shell completion generation for bash, zsh, fish, and PowerShell
Install-Module -Name KubeTidy -Repository PSGallery -Scope CurrentUserkubectl krew install kubetidygo install github.com/KubeDeckio/KubeTidy/cmd/kubetidy@latestNative CLI:
kubetidy --kubeconfig "$HOME/.kube/config" --listclusters
kubetidy --kubeconfig "$HOME/.kube/config" --report --output json
kubetidy doctor --kubeconfig "$HOME/.kube/config" --output yaml
kubetidy --kubeconfig "$HOME/.kube/config" --exportcontexts "prod-a,prod-b" --destinationconfig "$HOME/.kube/filtered-config"
kubetidy --mergeconfigs config1.yaml --mergeconfigs config2.yaml --destinationconfig "$HOME/.kube/config" --merge-strategy keep-first
kubetidy completion powershellPowerShell wrapper:
Invoke-KubeTidy -KubeConfigPath "$HOME\.kube\config" -ListClusters
Invoke-KubeTidy -KubeConfigPath "$HOME\.kube\config" -Report -Output json
Invoke-KubeTidy -KubeConfigPath "$HOME\.kube\config" -Doctor -Output yaml
Invoke-KubeTidy -ExportContexts "prod-a,prod-b" -DestinationConfig "$HOME\.kube\filtered-config"
Invoke-KubeTidy -MergeConfigs "config1.yaml","config2.yaml" -DestinationConfig "$HOME\.kube\config"Full documentation is published at docs.kubetidy.io.
make tidy
make test
make buildThe roadmap is tracked in ROADMAP.md.
