Skip to content

kubectl plugin that loops through Namespaces & Kubernetes API Object types to create a snapshot of the currently installed Kubernetes API objects to filesystem

License

Notifications You must be signed in to change notification settings

oguzhan-yilmaz/kubectl-snapshot-api-objects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kubectl-snapshot-api-objects

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.

Dependencies

Installation

kubectl krew install snapshot-api-objects

Usage

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

Local Installation

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

About

kubectl plugin that loops through Namespaces & Kubernetes API Object types to create a snapshot of the currently installed Kubernetes API objects to filesystem

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages