Skip to main content

A tool to backup Kubernetes YAML configurations.

Project description

KSave

ksave.py is a command-line interface (CLI) tool for backing up Kubernetes objects in YAML format. It supports various Kubernetes object types, such as Pods, Deployments, DaemonSets, Secrets, and more ...

Python 3.6

Architecture

Usage

Command:

ksave.py <object_type> <object_name> [options] > <output_file>

Supported Object Types:

-pods: Back up your Kubernetes Pod objects
-deployments: Back up your Kubernetes Deployments objects
-daemonsets: Back up your Kubernetes Daemonsets objects
-statefulsets: Back up your Kubernetes Statefulsets objects
-cronjobs: Back up your Kubernetes CronJob objects
-jobs: Back up your Kubernetes Job objects
-secrets: Back up your Kubernetes Secrets objects
-configmaps: Back up your Kubernetes ConfigMap objects
-ingress: Back up your Kubernetes Ingress objects
-services: Back up your Kubernetes Services objects
-storageclass: Back up your Kubernetes StorageClass objects
-persistentvolumes: Back up your Kubernetes PersistentVolume objects
-peristentvolumeclaims: Back up your Kubernetes PersistentVolumeClaim objects
-serviceaccount: Back up your Kubernetes ServiceAccount objects
-roles: Back up your Kubernetes Role objects
-rolebindings: Back up your Kubernetes RoleBinding objects
-clusterroles: Back up your Kubernetes ClusterRole objects
-clusterrolebindings: Back up your Kubernetes ClusterRoleBinding objects

Options:

  • --namespace <namespace>: Specify the namespace of the Kubernetes object.
  • --all: Backup objects from all namespaces.

Examples:

To backup a specific Pod object:

ksave.py pods my_pod > my_pod.backup.yaml

To backup a Deployment object in a specific namespace:

ksave.py deployments my_deployment --namespace my_namespace > my_deployment.my_namespace.backup.yaml

To backup all DaemonSet objects:

ksave.py daemonsets --all > all_daemonsets.backup.yaml

To backup a Secret object:

ksave.py secrets my_secret > my_secret.backup.yaml

Help:

To display this help message and see all available options, use the --help flag:

ksave.py --help

Sample --help Output:

Usage: ksave [-h] {pods,deployments,daemonsets,statefulsets,cronjobs,jobs,secrets,configmaps,ingress,services,storageclass,persistentvolumes,peristentvolumeclaims,serviceaccount,roles,rolebindings,clusterroles,clusterrolebindings} ...

positional arguments:
  {pods,deployments,daemonsets,statefulsets,cronjobs,jobs,secrets,configmaps,ingress,services,storageclass,persistentvolumes,peristentvolumeclaims,serviceaccount,roles,rolebindings,clusterroles,clusterrolebindings}
                        sub-command help
    pods                Back up your Kubernetes Pod objects
    deployments         Back up your Kubernetes Deployments objects
    daemonsets          Back up your Kubernetes Daemonsets objects
    statefulsets        Back up your Kubernetes Statefulsets objects
    cronjobs            Back up your Kubernetes CronJob objects
    jobs                Back up your Kubernetes Job objects
    secrets             Back up your Kubernetes Secrets objects
    configmaps          Back up your Kubernetes ConfigMap objects
    ingress             Back up your Kubernetes Ingress objects
    services            Back up your Kubernetes Services objects
    storageclass        Back up your Kubernetes StorageClass objects
    persistentvolumes   Back up your Kubernetes PersistentVolume objects
    peristentvolumeclaims
                        Back up your Kubernetes PersistentVolumeClaim objects
    serviceaccount      Back up your Kubernetes ServiceAccount objects
    roles               Back up your Kubernetes Role objects
    rolebindings        Back up your Kubernetes RoleBinding objects
    clusterroles        Back up your Kubernetes ClusterRole objects
    clusterrolebindings
                        Back up your Kubernetes ClusterRoleBinding objects

options:
  -h, --help            show this help message and exit

Installation

To activate individual virtual environment:

pip install virtualenv 

To create and start in project root:

virtualenv venv
source venv/bin/activate

Install dependencies in virtual environment:

pip install -r requirements.txt

Documentation

In this project, the Kubernetes Python Client proposed by kubernetes.io was used.
Kubernetes Python Client API Endpoint List -- Referance List
This CLI application is coded with arge-parse .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ksave-0.1.1.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

ksave-0.1.1-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page