You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 71c654b
Browse filesBrowse the repository at this point in the historyBrowse files
<!-- Thank you for making a contribution! Here are some tips for you:
- Start the PR title with the [label] of Cozystack component:
- For system components: [platform], [system], [linstor], [cilium],
[kube-ovn], [dashboard], [cluster-api], etc.
- For managed apps: [apps], [tenant], [kubernetes], [postgres],
[virtual-machine] etc.
- For development and maintenance: [tests], [ci], [docs], [maintenance].
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `backport` if it's a bugfix that needs to be backported
to a previous version.
-->
## What this PR does
### Release note
<!-- Write a release note:
- Explain what has changed internally and for users.
- Start with the same [label] as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->
Closes#1880
```release-note
Added BackupClass into BackupJob and BackupPlan for simplify UX.
```
The following functions related StorageRef were removed as they are no
longer used after migrating to BackupClass API:
// - resolveBucketStorageRef: Previously resolved S3 credentials from
Bucket storageRef
// - createS3CredsForVelero: Previously created Velero S3 credentials
secrets
// - createBackupStorageLocation: Previously created Velero
BackupStorageLocation resources
// - createVolumeSnapshotLocation: Previously created Velero
VolumeSnapshotLocation resources
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added BackupClass CRD and backupClassName field; webhook enforces and
defaults/validates backupClassName.
* **Refactor**
* Removed inline storageRef/strategyRef from specs; controllers resolve
strategy and parameters from BackupClass. Application apiGroup defaults
to apps.cozystack.io. Velero flow now uses resolved parameters.
* **Tests**
* Added unit tests for BackupClass resolution, BackupJob/Plan factory,
webhook validation, and Velero template rendering.
* **Chores**
* Manager cache/indexing updated to track BackupClass and index
BackupJobs by backupClassName.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
* Set `ownerReferences` so the `BackupJob` is owned by the `Plan`.
153
151
152
+
**Note:** The `BackupJob` controller resolves the `BackupClass` to determine the appropriate strategy and parameters, based on the `ApplicationRef`. The strategy template is processed with a context containing the `Application` object and `Parameters` from the `BackupClass`.
153
+
154
154
The Plan controller does **not**:
155
155
156
156
* Execute backups itself.
@@ -159,17 +159,64 @@ The Plan controller does **not**:
159
159
160
160
---
161
161
162
-
### 4.2 Storage
162
+
### 4.2 BackupClass
163
+
164
+
**Group/Kind**
165
+
`backups.cozystack.io/v1alpha1, Kind=BackupClass`
166
+
167
+
**Purpose**
168
+
Define a class of backup configurations that encapsulate strategy and parameters per application type. `BackupClass` is a cluster-scoped resource that allows admins to configure backup strategies and parameters in a reusable way.
169
+
170
+
**Key fields (spec)**
171
+
172
+
```go
173
+
typeBackupClassSpecstruct {
174
+
// Strategies is a list of backup strategies, each matching a specific application type.
**Note:** Parameters are not stored directly in `Backup`. Instead, they are resolved from `BackupClass` parameters when the backup was created. The storage location is managed by the driver (e.g., Velero's `BackupStorageLocation`) and referenced via parameters in the `BackupClass`.
325
+
274
326
**Key fields (status)**
275
327
276
328
```go
@@ -290,7 +342,8 @@ type BackupStatus struct {
290
342
* Creates a `Backup` in the same namespace (typically owned by the `BackupJob`).
291
343
* Populates `spec` fields with:
292
344
293
-
* The application, storage, strategy references.
345
+
* The application reference.
346
+
* The strategy reference (resolved from `BackupClass` during `BackupJob` execution).
294
347
*`takenAt`.
295
348
* Optional `driverMetadata`.
296
349
* Sets `status` with:
@@ -306,6 +359,8 @@ type BackupStatus struct {
306
359
* Anchor `RestoreJob` operations.
307
360
* Implement higher-level policies (retention) if needed.
308
361
362
+
**Note:** Parameters are resolved from `BackupClass` when the `BackupJob` is created. The driver uses these parameters to determine where to store backups. The storage location itself is managed by the driver (e.g., Velero's `BackupStorageLocation` CRD) and is not directly referenced in the `Backup` resource. When restoring, the driver resolves the storage location from the original `BackupClass` parameters or from the driver's own metadata.
363
+
309
364
---
310
365
311
366
### 4.5 RestoreJob
@@ -353,13 +408,13 @@ type RestoreJobStatus struct {
353
408
* Determines effective:
354
409
355
410
***Strategy**: `backup.spec.strategyRef`.
356
-
***Storage**: `backup.spec.storageRef`.
411
+
***Storage**: Resolved from driver metadata or `BackupClass` parameters (e.g., `backupStorageLocationName` stored in `driverMetadata` or resolved from the original `BackupClass`).
357
412
***Target application**: `spec.targetApplicationRef` or `backup.spec.applicationRef`.
358
413
* If effective strategy’s GVK is one of its supported strategy types → driver is responsible.
359
414
3. Behaviour:
360
415
361
416
* On first reconcile, set `status.startedAt` and `phase = Running`.
@@ -414,8 +469,10 @@ The Cozystack backups core API:
414
469
* Uses a single group, `backups.cozystack.io`, for all core CRDs.
415
470
* Cleanly separates:
416
471
417
-
***When & where** (Plan + Storage) – core-owned.
472
+
***When** (Plan schedule) – core-owned.
473
+
***How & where** (BackupClass) – central configuration unit that encapsulates strategy and parameters (e.g., storage reference) per application type, resolved per BackupJob/Plan.
474
+
***Execution** (BackupJob) – created by Plan when schedule fires, resolves BackupClass to get strategy and parameters, then delegates to driver.
418
475
***What backup artifacts exist** (Backup) – driver-created but cluster-visible.
0 commit comments