Skip to content

[Discussion] Do we deprecate or improve the prune: false template annotation injection? #1844

@foot

Description

@foot

TL;DR

Is automatic injection of the kustomize.toolkit.fluxcd.io/prune: disabled annotation in CAPITemplates either

  • useful and we should improve it, or is it
  • dangerous (in that one could accidentally prevent deletion of expensive AWS resources) and we should remove the feature and ask template authors to manually add it where appropriate instead?

Background

When rendering a CAPITemplate we automatically inject a kustomize.toolkit.fluxcd.io/prune: disabled annotation into every resource in the spec.resourcetemplates that is not a cluster.x-k8s.io.Cluster and not a gitops.weave.works.GitopsCluster.

The intention here is stop flux from explicitly deleting subresources of the Cluster like AWSCluster, KubeadmControlPlane, AWSMachineTemplate etc and let the capi-controllers remove them itself.

This is the pattern recommended in the capi-quickstart guide https://cluster-api.sigs.k8s.io/user/quick-start.html#clean-up it has a nice big warning on that page that looks like this:


image


Current state of things

As of #1830 you can enabled / disable this automatic injection of prune: disabled annotations with an annotation on the template itself (templates.weave.works/inject-prune-annotation": "true")

  • CAPITemplate: the default value for this annotation is "true" and we will inject the prune: false annotations
  • GitopsTemplate: the default value for this annotation is "false" and we don't inject

This issue

If a kustomization / helmrelease is included in a CAPITemplate it receives the prune: false and is not cleaned up, this feels like a bug.

When considering how to fix this bug the question was posed whether we should keep this feature at all.

Pros:

  • Nicer UX in that a template author doesn't have to understand the subtleties of CAPI x flux when authoring templates.

Cons:

  • We can't really know exactly which resources to annotate with prune: false
    • Could accidentally leave expensive resources around
    • We can make a better guess than currently, e.g. prune: false on anything that is apiVersion: /.*cluster.x-k8s.io.*/ and not kind: Cluster.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions