Skip to content

[FEATURE]: Add config option to not delete PVCs when running cleanup deploy command #7701

@eysi09

Description

@eysi09

Feature Request

Add config option for not deleting certain actions (specifically PVCs) when running the garden cleanup deploy command. This could be configured at the action level by adding something like a removeOnCleanup flag which would default to true which is the current behaviour. In this case it's not PVC specific per se, and could be applied to any action.

Alternatively we could have a flag at the Kubernetes provider level which could be PVC specific, e.g. cleanUpPVCs which would also default to true. This is probably more difficult to implement and not as flexible.

(We can definitely find better names for these fields and have a different default, like if we add skipPVCsOnCleanup.)

Background / Motivation

When you run helm uninstall, Helm intentionally does not delete PVCs so that you have data still available if you install the release again. You could argue that Garden should support the same behaviour, in particular since it's heavily used for development and keeping PVCs around would be useful in many cases.

What should the user be able to do?

Decide at the config level whether a given Deploy action should be deleted when running the garden cleanup deploy command or, alternatively, explicit configure Garden to not delete PVCs (could apply to both garden cleanup deploy and garden cleanup namespace).

Current workaround

There are currently workarounds to avoid PVCs being deleted.

You can e.g. disable the relevant actions when running a cleanup command which means Garden won't delete it. To explicitly disable a action when running garden cleanup deploy you can do:

kind: Deploy
type: kubernetes
name: my-pvc
# Ignore this action when running 'garden cleanup deploy'
disabled: ${command.name == 'cleanup deploy'}
spec:
  - manifestFiles: [./my-pvc.yaml]

You could also disable it on any cleanup command (i.e. cleanup deploy and cleanup namespace):

kind: Deploy
type: kubernetes
name: my-pvc
# Ignore this action when running any 'garden cleanup' command
disabled: ${command.name contains 'cleanup'}
spec:
  - manifestFiles: [./my-pvc.yaml]

You can also explicitly list the Deploy actions you want to cleanup:

garden cleanup deploy my-deploy-a my-deploy-b # <--- don't include the pvc Deploy action

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions