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
Add customizable restore order for core Kubernetes resources
Problem: Hardcoded restore order "1" for all Secrets/ConfigMaps is too
inflexible. Different resources may need different restore orders (e.g.,
CA secrets in order 1, service secrets in order 5).
Changes:
1. Webhook respects existing labels (doesn't overwrite user customization)
2. Added section on manual labeling for immediate customization
3. Designed OpenStackBackupConfig CRD for future configuration
4. Updated helper function to check existing labels before applying defaults
5. Added precedence: Manual labels > Config CRD > Hardcoded defaults
Implementation phases:
- Phase 1: Manual labeling (available immediately)
- Phase 4: CRD-based configuration with OpenStackBackupConfig
Benefits:
- Users can pre-label resources with custom restore orders
- Future: centralized configuration via CRD
- No hardcoded assumptions about restore order
- Flexible per-deployment customization
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
**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.
247
263
264
+
## Customizing Restore Order for Core Resources
265
+
266
+
### Manual Labeling (Available Immediately)
267
+
268
+
Users can pre-label Secrets, ConfigMaps, PVCs, and cert-manager resources to customize their restore order. The webhook respects existing labels and won't overwrite them.
269
+
270
+
**Example: CA secret restored in order 1, service secret in order 5**
271
+
272
+
```bash
273
+
# CA certificate secret (restored early)
274
+
oc label secret openstack-ca-cert \
275
+
openstack.org/backup-restore=true \
276
+
openstack.org/backup-category=all \
277
+
openstack.org/backup-restore-order=1 \
278
+
-n openstack
279
+
280
+
# Service-specific secret (restored after infrastructure)
281
+
oc label secret nova-cell1-config \
282
+
openstack.org/backup-restore=true \
283
+
openstack.org/backup-category=controlplane \
284
+
openstack.org/backup-restore-order=5 \
285
+
-n openstack
286
+
```
287
+
288
+
**How it works:**
289
+
1. User creates and labels resource with desired restore order
290
+
2. Webhook checks if resource already has `openstack.org/backup-restore: "true"`
291
+
3. If yes, webhook skips labeling (preserves user's custom order)
292
+
4. If no, webhook applies default labels
293
+
294
+
### Configuration via CRD (Future - Phase 4)
295
+
296
+
When the Golang controller is implemented, restore order defaults can be configured via CRD:
297
+
298
+
```yaml
299
+
apiVersion: core.openstack.org/v1beta1
300
+
kind: OpenStackBackupConfig
301
+
metadata:
302
+
name: backup-config
303
+
namespace: openstack
304
+
spec:
305
+
# Default restore orders for core Kubernetes resources
306
+
restoreDefaults:
307
+
secrets:
308
+
category: "all"
309
+
order: "1"
310
+
configmaps:
311
+
category: "all"
312
+
order: "1"
313
+
persistentvolumeclaims:
314
+
category: "all"
315
+
order: "8"
316
+
issuers: # cert-manager Issuer
317
+
category: "all"
318
+
order: "2"
319
+
networkattachmentdefinitions:
320
+
category: "all"
321
+
order: "1"
322
+
323
+
# Custom overrides for specific resources
324
+
customOrders:
325
+
- resource:
326
+
kind: Secret
327
+
name: openstack-ca-cert
328
+
category: "all"
329
+
order: "1"
330
+
- resource:
331
+
kind: Secret
332
+
name: nova-cell1-config
333
+
category: "controlplane"
334
+
order: "5"
335
+
```
336
+
337
+
**Benefits of CRD-based configuration:**
338
+
- Centralized configuration for all restore order defaults
339
+
- Easy to customize per deployment
340
+
- No need to manually label every resource
341
+
- Can be backed up and restored along with other CRs
342
+
343
+
**Implementation approach:**
344
+
1. Webhook reads OpenStackBackupConfig CR to get default orders
345
+
2. Applies configured defaults instead of hardcoded values
346
+
3. Still respects existing labels (manual overrides take precedence)
347
+
4. Fallback to hardcoded defaults if no config CR exists
348
+
248
349
## Restore Order
249
350
250
351
The restore sequence is critical for maintaining dependencies between resources.
@@ -366,24 +467,47 @@ Use case: Full restore of all labeled resources (default)
366
467
367
468
### Phase 1: Webhook & CRD Annotations (No Controller)
368
469
369
-
**Goal**: Automatic labeling of resources for backup
470
+
**Goal**: Automatic labeling of resources for restore
370
471
371
472
**Changes:**
372
473
1. Add CRD annotations to all operator CRDs
373
-
2. Implement mutating webhook in openstack-operator
374
-
3. Deploy webhook configuration
375
-
4. Test that resources get labeled on creation
474
+
2. Implement mutating webhook in openstack-operator (reuse ValidateCreate pattern)
475
+
3. Implement generic helper function in lib-common (respects existing labels)
476
+
4. Deploy webhook configuration
477
+
5. Test that resources get labeled on creation
376
478
377
479
**Backward Compatibility**: Existing Ansible backup/restore continues to work
378
480
481
+
**Features:**
482
+
- Automatic labeling of user-provided resources (no ownerReferences)
0 commit comments