Skip to content

KubeDeckio/KubeTidy

KubeTidy

Publish Release CI PowerShell Gallery Version Downloads Krew Version License

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.

Features

  • 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, or yaml
  • Export of selected contexts to a filtered kubeconfig
  • Merge of multiple kubeconfig files while preserving supported fields and reporting duplicate-name skips
  • Multi-file KUBECONFIG support with configurable merge strategy
  • Shell completion generation for bash, zsh, fish, and PowerShell

Installation

PowerShell Gallery

Install-Module -Name KubeTidy -Repository PSGallery -Scope CurrentUser

Krew

kubectl krew install kubetidy

From source

go install github.com/KubeDeckio/KubeTidy/cmd/kubetidy@latest

Usage

Native 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 powershell

PowerShell 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"

Documentation

Full documentation is published at docs.kubetidy.io.

Development

make tidy
make test
make build

The roadmap is tracked in ROADMAP.md.

About

KubeTidy - A PowerShell tool for cleaning up Kubernetes kubeconfig files by removing unreachable clusters, users, and contexts. Simplify your multi-cluster Kubernetes management with ease. Supports exclusion lists, automated backups, and a detailed summary report. Available on the PowerShell Gallery.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Contributors