Garbage-collect stale resources
This content is for the v0.1 version. Switch to the latest version for up-to-date documentation.
Use kix gc to remove resources that an earlier Activation managed but the
current cluster definition no longer contains. Every mode also applies the
Activation retention policy.
Review the normal garbage-collection plan
Section titled “Review the normal garbage-collection plan”Run gc with the cluster name:
❱ kix gc how-to-application The normal mode compares the previously deployed Activation with a fresh build of the cluster. It prints every resource and Activation record it plans to delete, then asks for confirmation.
Check the package, kind, namespace, and name of each resource before approving the plan. Kix deletes dependants before their dependencies.
Run without a prompt
Section titled “Run without a prompt”After reviewing the plan, pass --yes in automation:
❱ kix gc how-to-application -y
Loading old activation...
Building cluster 'how-to-application'...
Garbage collection plan
how-to-app
- preview 1.0.0 (3 resources)
Plan: 1 removed, 2 unchanged
1 activation records kept
- deleted PackageInstance/preview@how-to-app
- deleted Service/preview@how-to-app
- deleted Deployment/preview@how-to-app
- deleted ConfigMap/preview@how-to-app
GC complete: 4 deleted, 0 failed, 0 activation record(s) retired, 1 kept This performs the same comparison and deletion without asking for confirmation. The captured run follows an instance being renamed in the cluster definition, so the resources deployed under the old name are the ones Kix removes.
Scan the live cluster for orphans
Section titled “Scan the live cluster for orphans”Use --hard when the local activation cache is unavailable or you need to
find Kix-managed resources outside the previous-to-current build comparison:
❱ kix gc how-to-application --hard Hard mode scans live resources carrying Kix ownership metadata and compares them with the expected resources in the current build.
Resources carrying a Kix label but no kix.run/identity-hash are reported as
unstamped and kept by default. Kix cannot establish that it originally applied
them. Include them only after checking each reported resource:
❱ kix gc how-to-application --hard --include-unstamped Let the operator perform cleanup
Section titled “Let the operator perform cleanup”For an operator-managed cluster, use operator mode:
❱ kix gc how-to-application --operator Kix deletes the Activation records selected by the retention policy. The operator’s finalizers perform the associated resource cleanup.
Use the same --keep, --keep-max, and --keep-for flags in any mode. For
example:
❱ kix gc how-to-application --hard --keep 20 --keep-max 100 --keep-for 90d