helm-release-pruner

by joaquinito2051

Helm chartv2.0.0App 1.1.0

This charts launches a cronjob to purge stale Helm releases and associated namespaces

About this chart

Helm Release Pruner Chart

This chart deploys a cronjob that purges stale Helm releases and associated namespaces. Releases are selected based on regex patterns for release name and namespace along with a Bash date command date string to define the stale cutoff date and time.

One use-case for this chart is purging ephemeral release releases after a period of inactivity.

Example usage values file

The following values will purge all releases matching ^feature-.+-web$ in namespace matching ^feature-.+ older than 7 days. job.dryRun can be toggled to output matches without deleting anything.

job:
  schedule: "0 */4 * * *"
  dryRun: False

pruneProfiles:
  - olderThan: "7 days ago"
    helmReleaseFilter: "^feature-.+-web$"
    namespaceFilter: "^feature-.+"

Configuration

The following table lists the configurable parameters of the helm-release-pruner chart and their default values.

ParameterDescriptionDefaultRequired
image.pullPolicyImage pull policyIfNotPresentno
image.repositoryRepo for image that the job runs on.quay.io/reactiveops/ci-imagesno
image.tagImage tag.v8-alpineno
job.backoffLimitJob backoff limit.3no
job.dryRunOutput purge candidates without taking any action.Trueno
job.restartPolicyJob restart policy.Neverno
job.scheduleCron format schedule for job.0 */4 * * *no
job.serviceAccount.createCreate a service account for the job.trueno
job.serviceAccount.nameService account for the job to run as.""no
pruneProfilesFilters to use to find purge candidates. See example usage above for details.[]yes
tiller.namespaceNamespace where tiller resides. Used by job for helm commands.kube-systemno
rbac_manager.enabledIf true, creates an RbacDefinition to manage access.falseno
rbac_manager.namespaceLabellabel to match namespaces to grant access to.""no

Upgrading

Chart version 1.0.0 introduced RBacDefinitions with rbac-manager to manage access. This is disabled by default. If enabled with the rbac_manager.enabled, the release should be purged and re-installed to ensure helm manages the resources.

Deploy helm-release-pruner with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has helm-release-pruner on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charthelm-release-pruner is pinned at v2.0.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply