Skip to content

Feature Request: Introduce a deletionPolicy for deleting resources when the Kustomization is suspended #1613

@dan0sh

Description

@dan0sh

This issue has been identified as a feature request, it's not a bug.

Original issue description:

Describe the bug

When a Flux Kustomization resource is removed from the cluster, the Kubernetes resources managed by that Kustomization remain in the cluster ("orphaned") instead of being deleted.

It appears that the default value for .spec.deletionPolicy=MirrorPrune is not working as expected to clean up resources upon deletion of the parent object. Explicitly setting .spec.deletionPolicy=Delete is required to successfully garbage collect the resources.

Note that setting .spec.deletionPolicy: Delete will not trigger garbage collection if the Kustomization is suspended (.spec.suspend: true) at the time of deletion. The Kustomization must be active for the finalizer to execute the prune logic

Steps to reproduce

  1. Deploy a Flux Kustomization without .spec.deletionPolicy set.
  2. Observe that resources are synced to the cluster.
  3. Delete the Kustomization manifest/object.
  4. Observe that the child resources remain running in the cluster.

Expected behavior

When the Kustomization is deleted, all resources defined in the path should be garbage collected from the cluster.

Screenshots and recordings

No response

OS / Distro

k8s v1.33.9 - Linux 9.6 (Blue Onyx)

Flux version

2.7.3

Flux check

✗ flux 2.7.3 <2.8.1 (new CLI version is available, please upgrade) ✔ Kubernetes 1.33.9 >=1.32.0-0 ► checking version in cluster ✔ distribution: flux-v2.7.3 ✔ bootstrapped: true ► checking controllers ✔ helm-controller: deployment ready ► ghcr.io/fluxcd/helm-controller:v1.4.3 ✔ kustomize-controller: deployment ready ► ghcr.io/fluxcd/kustomize-controller:v1.7.2 ✔ notification-controller: deployment ready ► ghcr.io/fluxcd/notification-controller:v1.7.4 ✔ source-controller: deployment ready ► ghcr.io/fluxcd/source-controller:v1.7.3 ► checking crds ✔ alerts.notification.toolkit.fluxcd.io/v1beta3 ✔ buckets.source.toolkit.fluxcd.io/v1 ✔ externalartifacts.source.toolkit.fluxcd.io/v1 ✔ gitrepositories.source.toolkit.fluxcd.io/v1 ✔ helmcharts.source.toolkit.fluxcd.io/v1 ✔ helmreleases.helm.toolkit.fluxcd.io/v2 ✔ helmrepositories.source.toolkit.fluxcd.io/v1 ✔ kustomizations.kustomize.toolkit.fluxcd.io/v1 ✔ ocirepositories.source.toolkit.fluxcd.io/v1 ✔ providers.notification.toolkit.fluxcd.io/v1beta3 ✔ receivers.notification.toolkit.fluxcd.io/v1 ✔ all checks passed

Git provider

No response

Container Registry provider

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions