Skip to content

Commit 442b8cb

Browse files
stuggiclaude
andcommitted
Clarify full backup with selective restore strategy
Resolves compatibility topic #2 (Full Namespace Backup vs Selective Backup). Changes: 1. Backup strategy: Full namespace backup with smart exclusions - Backup ALL Secrets, ConfigMaps, CRs (complete snapshot) - Exclude operator-managed resources: pods, replicasets, jobs, events, statefulsets - PVCs filtered by openstack.org/backup: "true" label 2. Restore strategy: Selective by webhook labels - Only restore resources with openstack.org/backup-restore: "true" - Webhook labels user-provided resources (no ownerReferences) - Operator-managed resources excluded (recreated by operators) 3. Added detailed restore strategy explanation showing: - User-provided Secrets → Labeled → Restored - Operator-created Secrets → Not labeled → Recreated - Same logic for ConfigMaps and other resources 4. Updated Goals section to emphasize "Full Backup, Selective Restore" Decision: Backup everything (complete snapshot), restore selectively (webhook labels). This matches current Ansible approach but with automatic filtering via webhooks. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 73f83ce commit 442b8cb

1 file changed

Lines changed: 47 additions & 9 deletions

File tree

docs/dev/backup-restore-webhook-design.md

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ This document describes a webhook-based approach to backup and restore for OpenS
66

77
## Goals
88

9-
1. **Full Namespace Backup**: Backup everything in the namespace to ensure complete snapshot
10-
2. **Selective Restore**: Use webhook-added labels to restore only necessary resources
11-
3. **Dynamic Resource Discovery**: No hardcoded lists - CRD annotations declare what needs restore
12-
4. **Declarative Restore Order**: Restore order defined in CRD annotations, not in code
9+
1. **Full Backup, Selective Restore**:
10+
- Backup: All user resources (Secrets, ConfigMaps, CRs) - complete snapshot
11+
- Restore: Only webhook-labeled resources - automatic filtering
12+
2. **Dynamic Resource Discovery**: No hardcoded lists - CRD annotations declare what needs restore
13+
3. **Declarative Restore Order**: Restore order defined in CRD annotations, not in code
14+
4. **Operator-Managed Exclusion**: Operators recreate their own resources (not restored from backup)
1315
5. **Kubernetes-Native**: Leverage OADP label selectors for filtering
1416
6. **No Controller Required (Initially)**: Can be used manually with OADP Restore CRs
1517
7. **Optional Automation**: Golang controller for full automation (future enhancement)
@@ -187,7 +189,7 @@ func labelResourceForRestoreIfUserProvided(ctx context.Context, namespace, kind,
187189

188190
#### Full Namespace Backup
189191

190-
One OADP Backup CR captures **everything** in the namespace (complete snapshot):
192+
One OADP Backup CR captures **all user resources** in the namespace (complete snapshot):
191193

192194
```yaml
193195
apiVersion: velero.io/v1
@@ -199,15 +201,33 @@ spec:
199201
includedNamespaces:
200202
- openstack
201203
# NO labelSelector - backup all CRs, Secrets, ConfigMaps
202-
# PVC snapshots are filtered by the openstack.org/backup label (see note below)
204+
# Exclude operator-managed resources that will be recreated
205+
excludedResources:
206+
- pods
207+
- replicasets
208+
- jobs
209+
- events
210+
- statefulsets
203211
snapshotVolumes: true # Enable CSI snapshots for PVCs
204212
defaultVolumesToFsBackup: false
205213
storageLocation: velero-1
206214
ttl: 720h
207215
```
208216

217+
**Backup Strategy:**
218+
- ✅ **All Secrets** in namespace (user-provided AND operator-managed)
219+
- ✅ **All ConfigMaps** in namespace (user-provided AND operator-managed)
220+
- ✅ **All CRs** (OpenStackControlPlane, MariaDBDatabase, DataPlaneNodeSet, etc.)
221+
- ✅ **All NetworkAttachmentDefinitions, Issuers, etc.**
222+
- ✅ **PVCs with label** `openstack.org/backup: "true"` (CSI snapshots)
223+
- ❌ **Excluded**: Pods, ReplicaSets, Jobs, Events, StatefulSets (operator-managed, will be recreated)
224+
225+
**Why backup ALL Secrets/ConfigMaps?**
226+
- Ensures complete snapshot (nothing missed)
227+
- Simple backup logic (no complex filtering)
228+
- Restore is selective via webhook labels (see below)
229+
209230
**Note on PVC Backup:**
210-
- All CRs, Secrets, and ConfigMaps in the namespace are backed up (no label filtering)
211231
- **PVCs are selectively backed up** using the `openstack.org/backup: "true"` label
212232
- OADP's CSI snapshot logic respects the backup label when creating volume snapshots
213233
- Individual PVCs can be excluded using annotation: `backup.velero.io/backup-volumes: "false"`
@@ -255,7 +275,21 @@ spec:
255275

256276
#### Selective Restore (By Order)
257277

258-
Multiple OADP Restore CRs, one per restore order, using labels added by webhooks:
278+
Multiple OADP Restore CRs, one per restore order, using labels added by webhooks.
279+
280+
**Restore Strategy:**
281+
- ✅ **Only resources with** `openstack.org/backup-restore: "true"` **label**
282+
- ✅ **Webhooks add labels to user-provided resources** (no ownerReferences)
283+
- ❌ **Operator-managed resources excluded** (no labels, will be recreated by operators)
284+
285+
This means:
286+
- User-provided Secrets → Labeled by webhook → Restored ✅
287+
- Operator-created Secrets → Not labeled → Not restored, recreated by operator ✅
288+
- User-provided ConfigMaps → Labeled by webhook → Restored ✅
289+
- Operator-created ConfigMaps → Not labeled → Not restored, recreated by operator ✅
290+
- All CRs with annotations → Labeled by webhook → Restored ✅
291+
292+
**Example Restore CRs:**
259293
260294
```yaml
261295
# Restore Order 1: Secrets, ConfigMaps, NADs
@@ -289,7 +323,11 @@ spec:
289323
# And so on for each restore order...
290324
```
291325

292-
**Key Point**: Webhooks add `openstack.org/backup-restore: "true"` labels to resources that need restore. OADP restore uses these labels for selective restore, even though the backup contains everything.
326+
**Key Points:**
327+
- **Backup**: All user resources in namespace (all Secrets, ConfigMaps, CRs) - complete snapshot
328+
- **Restore**: Only resources with `openstack.org/backup-restore: "true"` label - selective filtering
329+
- **Webhooks**: Add restore labels to user-provided resources (no ownerReferences)
330+
- **Operators**: Recreate their own Secrets/ConfigMaps on reconciliation (not restored from backup)
293331

294332
## Customizing Restore Order for Core Resources
295333

0 commit comments

Comments
 (0)