Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoshet committed Oct 18, 2024
1 parent 0aadb96 commit 301ed88
Show file tree
Hide file tree
Showing 15 changed files with 414 additions and 127 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,26 @@ jobs:
format-and-clippy:
uses: ./.github/workflows/format-workflow.yaml
secrets: inherit
tests:
uses: ./.github/workflows/tests-workflow.yaml
secrets: inherit
build:
runs-on: ubuntu-latest
needs: [format-and-clippy]
needs: [format-and-clippy, tests]
strategy:
fail-fast: true
matrix:
include:
- name: "library"
path: "."
- name: "client"
path: "snap-kube-client"
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
toolchain: ${{ env.RUST_VERSION }}
- name: Build
- name: Cargo Build ${{ matrix.name }}
run: cargo build --verbose
working-directory: ${{ matrix.path }}
24 changes: 24 additions & 0 deletions .github/workflows/tests-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tests Pipeline

on:
workflow_call:

env:
RUST_VERSION: 1.81.0

jobs:
tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
toolchain: ${{ env.RUST_VERSION }}
- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-nextest
- name: Run tests
run: cargo nextest run --all
78 changes: 75 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[package]
name = "pvc-snapshotter"
name = "snap-kube"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "The pvc-snapshotter is a Rust tool that can backup and restore k8s PVCs using EBS snapshots"
description = "The snap-kube is a Rust tool that can backup and restore k8s PVCs using EBS snapshots"
readme = "README.md"
homepage = "https://github.com/nikoshet/pvc-snapshotter"
repository = "https://github.com/nikoshet/pvc-snapshotter"
homepage = "https://github.com/nikoshet/snap-kube"
repository = "https://github.com/nikoshet/snap-kube"
keywords = ["k8s", "pvc", "snapshot", "ebs", "backup", "restore", "aws"]
documentation = "https://docs.rs/pvc-snapshotter"
documentation = "https://docs.rs/snap-kube"
exclude = ["script.sh"]

[workspace]
members = ["pvc-snapshotter-client"]
members = ["snap-kube-client"]

[workspace.dependencies]
anyhow = "1.0.89"
Expand All @@ -31,7 +31,8 @@ serde_json = "1.0.128"
tokio = { version = "1", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
pvc-snapshotter = { path = ".", version = "0.1" }
snap-kube = { path = ".", version = "0.1" }
mockall = "0.13"

[dependencies]
anyhow.workspace = true
Expand All @@ -50,12 +51,13 @@ serde_json.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
mockall.workspace = true

[lib]
test = true
edition = "2021"
crate-type = ["lib"]
name = "pvc_snapshotter"
name = "snap_kube"

[features]
default = ["full"]
Expand Down
30 changes: 12 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
<h1 align="center">PVC-Snapshotter</h1>
<h1 align="center">SnapKube</h1>
<div align="center">
<strong>
A Rust 🦀 tool supports PVC snapshots across Kubernetes namespaces (Velerust/Rustero)
A Rust 🦀 tool supports (for now) PVC snapshots across Kubernetes namespaces
</strong>
</div>

<br />

<div align="center">
<!-- Github Actions -->
<a href="https://github.com/nikoshet/pvc-snapshotter/actions/workflows/ci.yaml?query=branch%3Amain">
<img src="https://img.shields.io/github/actions/workflow/status/nikoshet/pvc-snapshotter/ci.yaml?branch=main&style=flat-square" alt="actions status" /></a>
<a href="https://github.com/nikoshet/snap-kube/actions/workflows/ci.yaml?query=branch%3Amain">
<img src="https://img.shields.io/github/actions/workflow/status/nikoshet/snap-kube/ci.yaml?branch=main&style=flat-square" alt="actions status" /></a>
<!-- Version -->
<a href="https://crates.io/crates/pvc-snapshotter">
<img src="https://img.shields.io/crates/v/pvc-snapshotter.svg?style=flat-square"
<a href="https://crates.io/crates/snap-kube">
<img src="https://img.shields.io/crates/v/snap-kube.svg?style=flat-square"
alt="Crates.io version" /></a>
<!-- Docs -->
<a href="https://docs.rs/pvc-snapshotter">
<a href="https://docs.rs/snap-kube">
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" alt="docs.rs docs" /></a>
<!-- Downloads -->
<a href="https://crates.io/crates/pvc-snapshotter">
<img src="https://img.shields.io/crates/d/pvc-snapshotter.svg?style=flat-square" alt="Download" />
<a href="https://crates.io/crates/snap-kube">
<img src="https://img.shields.io/crates/d/snap-kube.svg?style=flat-square" alt="Download" />
</a>
</div>

## Overview
The PVC-Snapshotter Tool is a Rust-based utility that allows Kubernetes users to backup and restore Persistent Volume Claim (PVC) snapshots. The tool provides robust mechanisms to back up data to AWS Elastic Block Store (EBS) and restore it to any Kubernetes namespace. This tool is designed to work with Kubernetes VolumeSnapshot resources, making backup and restoration operations seamless.
The SnapKube Tool is a Rust-based utility that allows Kubernetes users to backup and restore Persistent Volume Claim (PVC) snapshots. The tool provides robust mechanisms to back up data to AWS Elastic Block Store (EBS) and restore it to any Kubernetes namespace. This tool is designed to work with Kubernetes VolumeSnapshot resources, making backup and restoration operations seamless.

The tool supports three primary modes of operation:

Backup: Create snapshots of one or more PVCs.
Restore: Restore PVCs from existing snapshots.
Full: Run both backup and restore operations in a single process.


<br>
> [!NOTE]
> Average percentage of time saved by PVC-Snapshotter compared to [Velero](https://github.com/vmware-tanzu/velero): **X%**.
<br>
## Features
- **Backup**: Create Kubernetes VolumeSnapshots from existing PVCs
- **Restore**: Restore PVCs to any namespace from a VolumeSnapshot
Expand All @@ -48,7 +42,7 @@ The tool supports three primary modes of operation:
- **Error Handling**: Robust error handling and retries to ensure operations complete reliably

## Prerequisites
Before using PVC-Snapshotter, please ensure you have the following:
Before using SnapKube, please ensure you have the following:
- You need Rust installed to compile the tool. Install Rust via rustup
- An AWS Account with the appropriate access policy
- AWS EBS CSI Driver: Required to be installed in your Kubernetes cluster, which is a CSI Driver to manage the lifecycle of EBS Volumes
Expand All @@ -61,7 +55,7 @@ In order to use the tool as a client, you can use `cargo`.

The tool provides 3 features for running it, which are `backup` `restore`, and `full` (default).
```shell
Usage: pvc-snapshotter-client full [OPTIONS] --source-ns <SOURCE_NS> --target-ns <TARGET_NS> --volume-snapshot-class <VOLUME_SNAPSHOT_CLASS> --volume-snapshot-name-prefix <VOLUME_SNAPSHOT_NAME_PREFIX> --target-snapshot-content-name-prefix <TARGET_SNAPSHOT_CONTENT_NAME_PREFIX> --storage-class-name <STORAGE_CLASS_NAME>
Usage: snap-kube-client full [OPTIONS] --source-ns <SOURCE_NS> --target-ns <TARGET_NS> --volume-snapshot-class <VOLUME_SNAPSHOT_CLASS> --volume-snapshot-name-prefix <VOLUME_SNAPSHOT_NAME_PREFIX> --target-snapshot-content-name-prefix <TARGET_SNAPSHOT_CONTENT_NAME_PREFIX> --storage-class-name <STORAGE_CLASS_NAME>

Options:
--region <REGION>
Expand Down
13 changes: 7 additions & 6 deletions pvc-snapshotter-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "pvc-snapshotter-client"
name = "snap-kube-client"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "The pvc-snapshotter-client is a Rust tool that can backup and restore k8s PVCs using EBS snapshots"
description = "The snap-kube-client is a Rust tool that can backup and restore k8s PVCs using EBS snapshots"
readme = "../README.md"
homepage = "https://github.com/nikoshet/pvc-snapshotter"
repository = "https://github.com/nikoshet/pvc-snapshotter"
homepage = "https://github.com/nikoshet/snap-kube"
repository = "https://github.com/nikoshet/snap-kube"
keywords = ["k8s", "pvc", "snapshot", "ebs", "backup", "restore", "aws"]
documentation = "https://docs.rs/pvc-snapshotter-client"
documentation = "https://docs.rs/snap-kube-client"

[dependencies]
anyhow.workspace = true
Expand All @@ -27,7 +27,8 @@ serde_json.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
pvc-snapshotter.workspace = true
snap-kube.workspace = true
mockall = "0.13.0"

[features]
default = ["full"]
Expand Down
6 changes: 3 additions & 3 deletions pvc-snapshotter-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use anyhow::Result;
use clap::{Parser, Subcommand};
use colored::Colorize;
#[cfg(feature = "backup")]
use pvc_snapshotter::backup::{backup_operator::BackupOperator, backup_payload::BackupPayload};
use snap_kube::backup::{backup_operator::BackupOperator, backup_payload::BackupPayload};
#[cfg(feature = "restore")]
use pvc_snapshotter::k8s_ops::vsc::retain_policy::VSCRetainPolicy;
use snap_kube::k8s_ops::vsc::retain_policy::VSCRetainPolicy;
#[cfg(feature = "restore")]
use pvc_snapshotter::restore::{
use snap_kube::restore::{
restore_operator::RestoreOperator, restore_payload::RestorePayload,
};
use tracing::info;
Expand Down
Loading

0 comments on commit 301ed88

Please sign in to comment.