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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file ksave-0.1.1.tar.gz.

File metadata

  • Download URL: ksave-0.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.6

File hashes

Hashes for ksave-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9fe32efb4c49b11ffdd6ea4d31bd8771c0eb7b748204219bd8352b2008e7248c
MD5 7a26cf5eed67cea575f3615d63a66ad7
BLAKE2b-256 964d02d5abdc82d07e543e8ecf62d3636bf9f4996d25cdd91faf459415197122

See more details on using hashes here.

File details

Details for the file ksave-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ksave-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.6

File hashes

Hashes for ksave-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f0c8b121e86f9995dc67e3b28737a0ad1ee055b1971d20fd111593c843708d1
MD5 1184ed6b4be39116acf0b91fbf8d49bd
BLAKE2b-256 6de68e031c5a1734ee46e425d7866e6a96ffce61d7eb6f5f1a1ab066efd6ce57

See more details on using hashes here.

Supported by

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