|
| 1 | +# Velero Mayastor Restore Plugin |
| 2 | + |
| 3 | +[](https://github.com/openebs/velero-plugin/actions/workflows/build-release.yaml) |
| 4 | + |
| 5 | +This Velero plugin for OpenEBS Mayastor ensures that `PersistentVolumeClaim` annotations related to StatefulSets (`openebs.io/stsAffinityGroup`) are updated correctly during Velero restores — especially when restoring into a different namespace. |
| 6 | + |
| 7 | +## ✨ Features |
| 8 | + |
| 9 | +- Updates the `openebs.io/stsAffinityGroup` annotation on PVCs during restore |
| 10 | +- Ensures StatefulSet PVC grouping works in multiple namespaces |
| 11 | + |
| 12 | +## 🧭 Project Structure |
| 13 | + |
| 14 | +``` |
| 15 | +. |
| 16 | +├── main.go # Entry point that registers the plugin with Velero |
| 17 | +├── pkg/ |
| 18 | +│ └── mayastor/ |
| 19 | +│ └── plugin/ |
| 20 | +│ └── restoreplugin.go # Core restore plugin logic |
| 21 | +├── Dockerfile # Multi-stage Docker build for plugin image |
| 22 | +├── Makefile # Build, lint, container build, and utility targets |
| 23 | +├── _output/ # Output binary and build artifacts |
| 24 | +├── go.mod / go.sum # Go module files |
| 25 | +└── README.md # This documentation |
| 26 | +``` |
| 27 | + |
| 28 | +## 🛠️ Building |
| 29 | + |
| 30 | +### Prerequisites |
| 31 | + |
| 32 | +- [Docker](https://docs.docker.com/get-docker/) |
| 33 | +- [Make](https://www.gnu.org/software/make/) |
| 34 | +- [Go](https://go.dev/doc/install) 1.23+ |
| 35 | + |
| 36 | +### Build Plugin Binary |
| 37 | + |
| 38 | +```sh |
| 39 | +make build |
| 40 | +``` |
| 41 | + |
| 42 | +### Build Docker Image |
| 43 | + |
| 44 | +```sh |
| 45 | +make container |
| 46 | +``` |
| 47 | + |
| 48 | +## 🧹 Linting & Formatting |
| 49 | + |
| 50 | +Run all linters and fail if formatting is required: |
| 51 | + |
| 52 | +```sh |
| 53 | +make lint |
| 54 | +``` |
| 55 | + |
| 56 | +Auto-fix formatting issues: |
| 57 | + |
| 58 | +```sh |
| 59 | +make lint-fix |
| 60 | +``` |
| 61 | + |
| 62 | +## 🧪 Usage with Velero |
| 63 | + |
| 64 | +1. Push the built image to your container registry: |
| 65 | + |
| 66 | +```sh |
| 67 | +docker tag openebs/velero-plugin-mayastor:<tag> <your-registry>/velero-plugin-mayastor:<tag> |
| 68 | +docker push <your-registry>/velero-plugin-mayastor:<tag> |
| 69 | +``` |
| 70 | + |
| 71 | +2. Patch Velero deployment to use the plugin: |
| 72 | + |
| 73 | +```yaml |
| 74 | +spec: |
| 75 | + template: |
| 76 | + spec: |
| 77 | + initContainers: |
| 78 | + - image: docker.io/openebs/velero-plugin-mayastor:develop |
| 79 | + imagePullPolicy: Always |
| 80 | + name: velero-plugin-mayastor |
| 81 | + resources: {} |
| 82 | + terminationMessagePath: /dev/termination-log |
| 83 | + terminationMessagePolicy: File |
| 84 | + volumeMounts: |
| 85 | + - mountPath: /target |
| 86 | + name: plugins |
| 87 | +``` |
| 88 | +
|
| 89 | +## 🔍 How It Works |
| 90 | +
|
| 91 | +- On restore, the plugin checks PVCs for the annotation `openebs.io/stsAffinityGroup`. |
| 92 | +- If it exists, it updates the namespace portion of the annotation value based on Velero’s restore namespace mapping. |
| 93 | +- If the namespace hasn't changed, the plugin logs and skips the update. |
| 94 | +- If the annotation `openebs.io/stsAffinityGroup` doesn't exist it skips the update. |
| 95 | + |
| 96 | +## 🤝 Contributing |
| 97 | + |
| 98 | +See [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) |
0 commit comments