Skip to content

Garbage-collect stale resources

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.

Run gc with the cluster name:

Run in kix-examples/
❱ 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.

After reviewing the plan, pass --yes in automation:

Run in kix-examples/
❱ 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.

Use --hard when the local activation cache is unavailable or you need to find Kix-managed resources outside the previous-to-current build comparison:

Run in kix-examples/
❱ 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:

Run in kix-examples/
❱ kix gc how-to-application --hard --include-unstamped

For an operator-managed cluster, use operator mode:

Run in kix-examples/
❱ 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:

Run in kix-examples/
❱ kix gc how-to-application --hard --keep 20 --keep-max 100 --keep-for 90d