Platform · Safe deletion
Demolition in Dependency Order: Safe, Re-runnable Offboarding
One workflow drains workloads, removes the GitOps and autoscaler layers, destroys infrastructure, returns network space, then cancels subscriptions, in the order that avoids orphans and stuck deletes.
// Overview
Offboarding is triggered from a form or manually. It reverses onboarding: it removes the app-bootstrap file so workloads are deleted gracefully, destroys the GitOps and autoscaler layers, destroys the infrastructure, releases network ranges, cancels subscriptions and resets Vault state. It handles HA (primary and secondary clusters) and lower, upper or both.
// The problem
Deleting a subscription or cluster out of order leaves orphaned load balancers, stuck cluster deletes, ghost registrations in the autoscaler dashboard, and reusable network ranges that collide with live networks.
// Flow
- Prepareread Vault, check the cluster exists, detect HA, cache everything as an artifact
- Workload cleanupremove the bootstrap kustomization via auto-merged PR; wait for reconciliation
- Destroy GitOpsTerraform destroy of the Flux bootstrap root
- Destroy autoscalerTerraform destroy plus API cleanup, non-blocking
- Destroy infrastructurelower and upper roots destroyed in parallel
- Gate: release network gateranges returned to the pool only if destroys succeeded
- Side jobsremove lock, archive chat channels (non-blocking)
- Network watcher cleanupdelete the group created by policy outside Terraform
- Destroy subscriptionscancelled asynchronously by the cloud provider
- Reset statelock cleared and team removed from the registry
// Design decisions & guardrails
- Artifact-based resilience: data is fetched once and cached for 90 days. Fallback chain: Vault, cached artifact, naming convention, then fail with recovery instructions.
- Plan-destroy first; a Destroy-only action skips the plan for emergencies.
- Every destroy job has a paired skip job that logs why it was skipped.
- The network release guard prevents range reuse while a VNet may still exist.
- Concurrency per team with cancel-in-progress off, so a running teardown is never interrupted.
- continue-on-error is used only for optional jobs. Documented failure modes include stuck node resource groups, peering delete failures and Key Vault purge protection.
// Outcome
About ten numbered jobs, seven safety mechanisms and a pipeline that can be re-run after any failure.