Skip to content

Resolve convert placeholders from cluster resources#101

Open
ArnobKumarSaha wants to merge 1 commit into
masterfrom
arnob-convert
Open

Resolve convert placeholders from cluster resources#101
ArnobKumarSaha wants to merge 1 commit into
masterfrom
arnob-convert

Conversation

@ArnobKumarSaha

Copy link
Copy Markdown
Contributor

What

Improves kubectl kubestash convert so that, for database backups, it resolves values from the live cluster instead of emitting ### Set Valid X ### placeholders that operators must fill in by hand.

The command already built a Kubernetes client and then discarded it; this wires it up.

How

For BackupConfiguration / RestoreSession whose target is an AppBinding:

  • TargetAppBinding.spec.appRef (the real KubeDB object: apiGroup/kind/name/namespace).
  • Addon ← the KubeDB catalog version's spec.archiver.addon.name (e.g. postgres-addon), falling back to the <kind>-addon convention. Catalog versions are read unstructured, so no extra scheme is needed.
  • Tasklogical-backup / logical-backup-restore constants.
  • encryptionSecret ← new --encryption-secret-name / --encryption-secret-namespace flags.
  • directory<namespace>/<name> of the resolved target.

Behaviour on errors

  • Cluster unreachable → keep the existing placeholder behaviour (offline conversion still succeeds), with a klog warning.
  • Cluster reachable but AppBinding/version NotFound → hard fail, rather than papering over a real misconfiguration.

Fields still needing operator attention (directory, encryptionSecret when flags omitted, snapshot) get a review YAML line-comment.

Scope

  • Workload targets (StatefulSet/Deployment/DaemonSet) and BackupBlueprint keep their existing behaviour.

Notes

  • kmodules.xyz/custom-resources moves from indirect to direct in go.mod (already vendored).

Use the live cluster to resolve the target, addon and task for AppBinding-backed
BackupConfiguration/RestoreSession instead of emitting placeholders:

- Capture the client convert already built (was discarded) and register the
  appcatalog scheme so AppBindings can be fetched.
- resolveAppBindingTarget looks up the AppBinding -> spec.appRef (real KubeDB
  target) and the KubeStash addon name from the catalog version's
  spec.archiver.addon.name (falling back to <kind>-addon). Backup/restore tasks
  use the logical-backup / logical-backup-restore constants.
- If the cluster is unreachable, keep the existing placeholder behaviour; only
  hard-fail when a referenced AppBinding/version is genuinely NotFound.
- Add --encryption-secret-name / --encryption-secret-namespace flags to fill the
  encryptionSecret; set repository.directory to <namespace>/<name> of the target.
- Emit review YAML line-comments for fields that still need operator attention.

Signed-off-by: Arnob Kumar Saha <arnob@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants