This plugin loops through namespaces, Kubernetes API Object types and gets the -o yaml
output for all of them, pipes it to kubectl neat
and create a snapshot of the currently installed K8s API objects to filesystem.
- 'kubectl neat' plugin
kubectl krew install neat
kubectl krew install snapshot-api-objects
Snapshot all API Object types from all Namespaces
kubectl snapshot-api-objects
Snapshot selected Namespaces
kubectl snapshot-api-objects -n default,kube-system
Snapshot selected Resource Types
kubectl snapshot-api-objects -r pods,configmaps,deployments
Snapshot selected Resource Types and Namespaces
kubectl snapshot-api-objects \
-r pods,configmaps,deployments \
-n default,kube-system
kubectl snapshot-api-objects --help
Usage: kubectl snapshot-api-objects [OPTIONS]
Options:
-n, --namespace Optional: Specific namespace to export. Defaults to all namespaces
-r, --resource-types Optional: Comma-separated list of resource types to export (e.g., "pods,deployments,services")
Defaults to all resource types
-h, --help Show this help message
Examples:
# Export all resources from all namespaces
kubectl snapshot-api-objects
# Export all resources from default and kube-system namespaces
kubectl snapshot-api-objects -n default,kube-system
# Export only pods and deployments from all namespaces
kubectl snapshot-api-objects -r pods,deployments
# Export pods and deployments from default and kube-system namespaces
kubectl snapshot-api-objects -n default,kube-system -r pods,deployments
EOF
curl -sL https://raw.githubusercontent.com/oguzhan-yilmaz/kubectl-snapshot-api-objects/refs/heads/main/.krew.yaml -o snapshot-api-objects.krew.yaml
kubectl krew uninstall snapshot-api-objects || true
kubectl krew install --manifest=snapshot-api-objects.krew.yaml
# make kubectl krew plugin executable upon local installation
chmod +x ~/.krew/store/snapshot-api-objects/v*/snapshot-api-objects
kubectl snapshot-api-objects -n default