A fast and efficient Kubernetes tool for discovering Custom Resources (CRs) in your cluster namespaces.
kgcr (kubectl get CustomResources) is a command-line tool that scans and lists all custom resource instances found. It's designed to be fast and efficient by using concurrent workers to query multiple Custom Resource Definitions (CRDs) in parallel.
- Fast parallel scanning - Uses concurrent workers to query multiple CRDs simultaneously
- Namespace-aware - Automatically uses the current kubectl context's namespace or accepts a custom namespace
- Clean tabular output - Displays results in an easy-to-read table format
- Performance optimized - Pre-computes resource metadata and uses efficient batching strategies
- Configurable timeout - Prevents hanging on slow API responses
curl -fsSL https://raw.githubusercontent.com/itsrishub/kgcr/main/install.sh | sudo bash- Go 1.19 or higher
- Access to a Kubernetes cluster
- Valid kubeconfig file
git clone https://github.com/itsrishub/kgcr.git
cd kgcr
go build -o kgcr main.goScan the current namespace from your kubectl context:
kgcrScan a specific namespace:
kgcr -n production
or
kgcr -namespace productionScan a specific namespace:
kgcr -A
or
kgcr -all-namespacesSet a custom timeout for the operation (default: 30s):
kgcr -n production -timeout 60sCRD RESOURCE NAME
certificates.cert-manager.io certificates api-cert
applications.argoproj.io applications root
- CRD Discovery: Lists all Custom Resource Definitions in the cluster
- Filtering: Filters out cluster-scoped CRDs, keeping only namespaced resources
- Parallel Processing: Distributes CRDs among concurrent workers
- Resource Listing: Each worker queries the Kubernetes API for instances of assigned CRDs
- Result Aggregation: Collects and sorts all found resources
- Output Formatting: Displays results in a clean, tabular format
The tool is optimized for performance with:
- Concurrent processing with worker pool sized based on CPU cores
- Pre-computed resource metadata to avoid repeated calculations
- Buffered channels for efficient inter-goroutine communication
- Reusable memory allocations to reduce garbage collection pressure
- Configurable QPS and burst limits for API requests
The tool respects standard Kubernetes client configuration:
- Uses the default kubeconfig location (
~/.kube/config) - Respects
KUBECONFIGenvironment variable - Uses the current kubectl context
- Requires appropriate RBAC permissions to list CRDs and custom resources
Contributions are welcome! Please feel free to submit a Pull Request.