Retiring an App¶
The reverse of Adding an App. Removing the app from Git makes Flux delete its Kubernetes objects, including its volumes. Backups, 1Password items and files on the NAS stay behind, so they are cleaned up by hand.
Flux deletes the app's volumes
Both ceph-block and openebs-hostpath use reclaimPolicy: Delete, so
the app's PVCs and their data are gone once Flux prunes the app. The
backups are what's left; take a last one first.
Before you start¶
- Decide what to keep. Either keep the backups, so the app can come back later with its data, or remove everything.
-
Take a final backup of every volume and database the app has. Skip this for a stateless app.
-
Volumes (Kopiur)
Take a final snapshot:
just k8s pvc-backup <namespace> <app> kubectl -n <namespace> get snapshot # wait for the new snapshot's PHASE to be SucceededRemoving the app later deletes the
Snapshotobjects from the cluster, but the snapshots stay in the repository on the NAS. -
Database
If the app has an
<app>-postgrescluster or an<app>-mariadb, start a base backup of it:
-
-
Find everything that refers to the app:
Look in particular for
dependsOnentries in other apps'ks.yaml, OIDC clients in Pocket ID, and Grafana dashboards or alert rules elsewhere. Homepage entries are annotations on the app's own route, so they go with it.
The PR¶
- Remove
./<app>/ks.yamlfrom the namespacekustomization.yaml, and deletekubernetes/apps/<namespace>/<app>/. - Remove references found above, such as
dependsOnin other apps. - Last app in its namespace? Delete
kubernetes/apps/<namespace>/entirely (cluster-appsthen prunes the namespace), and remove it fromPLATFORMorWORKLOADSinscripts/docs-applications.py. - Update the docs: run
just docs appsto regenerate the Applications tables, and update any other page that mentions the app. - Validate with
just docs build, andkustomize buildon the namespace.
What Flux and the controllers remove¶
After the merge, these go away without any action:
- the Flux Kustomization, the HelmRelease and everything they created,
including PVCs, Secrets, routes and the CNPG
Clusterwith its volumes - DNS records: both external-dns instances use
policy: sync, so they delete the app's records in UniFi and Cloudflare - the Gatus check, which is generated from the route
- the Kopiur
SnapshotPolicy,SnapshotScheduleandSnapshotobjects (the snapshots themselves stay in the repository; see below)
Check that the Flux Kustomization is gone with flux get ks -A | grep <app>.
If anything is still there, see
KB-003: not every
Kustomization prunes.
What stays behind¶
| What | Where | Remove it |
|---|---|---|
| Kopia snapshots | The nas repository on the NAS, and its B2 mirror |
The Snapshot objects in the cluster are deleted with the app, but the snapshots in the repository are kept. Delete them with Kopia against the repository if the app won't come back; the B2 mirror follows on its next sync |
| Barman base backups and WAL | Garage, s3://postgresql/<app>/ |
Retention stops with the Cluster, so nothing expires. Delete the prefix in Garage |
| MariaDB base backups and binlogs | Garage, s3://mariadb/<app>/ (every v<N>/ timeline and replica/) |
Retention stops with the MariaDB, and binlogs are never pruned. Delete the prefix in Garage |
| Local database dumps | NAS, /mnt/vault/Backups/Database |
Delete the app's files |
| 1Password items | The Homelab vault |
Archive the app's item, and any OIDC or API credentials made for it |
| OIDC client | Pocket ID | Delete the client |
| NFS data | NAS datasets mounted by the app | Delete or archive the directory |
Coming back later restores the old data
If the backups are kept, adding the app again with the same name in the
same namespace restores them. Kopiur rediscovers the snapshots from the
repository on the NAS (as Snapshot objects with origin: discovered),
its Restore fills the new PVC from the latest one, and the CNPG Cluster
bootstraps from Barman by default. For a fresh start,
delete the backups first, or follow New Database for
the database.
Deleting the database backups¶
Delete the Garage prefix only after Flux has pruned the Cluster or
MariaDB; until then the WAL archiver or binlog agent keeps writing into it.
Use the S3 keys from the cloudnative-pg or mariadb 1Password item, list
the prefix first, and keep the trailing slash, so <app> doesn't also match
an app whose name starts with it:
aws s3 ls s3://postgresql/<app>/ --recursive --endpoint-url https://s3.bykaj.io --region <region>
aws s3 rm s3://postgresql/<app>/ --recursive --endpoint-url https://s3.bykaj.io --region <region>
Use the mariadb bucket for MariaDB. garage-ui at garage.bykaj.app can
delete the objects too. Remove the app's folder in
/mnt/vault/Backups/Database on the NAS as well. Deleted objects remain
recoverable for a while from the NAS backups of the Garage stack's data.
Fresh start: delete before redeploying
To bring an app back with an empty database, delete its prefix before
deploying it again with the init label from
New Database. Without the label, the old data is
restored. With the label but old backups in place, a new CNPG cluster
archives into the same path as the old one (skipEmptyWalArchiveCheck
doesn't stop it), so a later rebuild may recover from the wrong backups,
and a new MariaDB never archives binlogs, because the agent only starts
in an empty prefix.
For MariaDB, a fresh start can keep the old backups instead: set
MARIADB_TIMELINE to a number not used before, so the new instance
archives into an empty v<N>/ prefix. See
Rebuilding. CNPG has
no equivalent, because the serverName is always ${APP}.