helm-release-pruner

by Fairwinds

Helm chartv4.1.1App v4.1.1Verified publisher

A Go-based daemon for automatically deleting old Helm releases. Runs continuously in your cluster and prunes stale releases at configurable intervals. Supports filtering by release name, namespace, age, or count with regex patterns.

About this chart

Helm Release Pruner Chart

A Go-based daemon for automatically deleting old Helm releases. Runs continuously in your cluster and prunes stale releases at configurable intervals. Supports filtering by release name, namespace, age, or count with regex patterns.

Overview

This chart deploys helm-release-pruner, a Go-based daemon that automatically deletes old Helm releases based on configurable filters. It runs as a Deployment that continuously prunes at configurable intervals.

Features

  • Delete releases older than a specified age
  • Keep only the N most recent releases globally
  • Filter releases by name and namespace using regex patterns
  • Exclude releases and namespaces using regex patterns
  • Clean up empty namespaces after release deletion
  • Clean up orphaned namespaces (namespaces with no Helm releases)
  • Prometheus metrics for monitoring
  • Health endpoints for Kubernetes probes

Example Usage

Basic Usage

Prune feature branch releases older than 2 weeks, checking every hour:

pruner:
  dryRun: false
  interval: "1h"
  olderThan: "2w"
  releaseFilter: "^feature-.+-web$"
  namespaceFilter: "^feature-.+"

serviceMonitor:
  enabled: true

With Release Count Limit

Keep only the 10 most recent matching releases:

pruner:
  dryRun: false
  olderThan: "14d"
  releaseFilter: "^feature-.+"
  maxReleasesToKeep: 10

Orphan Namespace Cleanup

Clean up namespaces that have no Helm releases:

pruner:
  dryRun: false
  olderThan: "2w"
  namespaceFilter: "^feature-.+"
  cleanupOrphanNamespaces: true
  orphanNamespaceFilter: "^feature-.+"

Duration Formats

The olderThan and interval values support:

  • Go durations: 1h, 30m, 336h
  • Days: 14d (14 days)
  • Weeks: 2w (2 weeks)

Prometheus Metrics

The following metrics are exposed on /metrics:

MetricTypeDescription
helm_pruner_releases_deleted_totalCounterTotal releases deleted
helm_pruner_namespaces_deleted_totalCounterTotal namespaces deleted
helm_pruner_cycle_duration_secondsHistogramDuration of prune cycles
helm_pruner_cycle_failures_totalCounterFailed prune cycles
helm_pruner_releases_scanned_totalCounterTotal releases scanned

Health Endpoints

EndpointDescription
/healthzLiveness probe - returns 200 if running
/readyzReadiness probe - returns 200 after initialization
/metricsPrometheus metrics

Upgrading

From v3.x (Bash) to v4.x (Go)

v4.0.0 is a major rewrite from Bash to Go with significant changes:

Changev3.x (Bash)v4.x (Go)
DeploymentCronJobDeployment (daemon)
Duration format"7 days ago"7d, 1w, 168h
Release filterhelmReleaseFilterreleaseFilter
Exclude filterhelmReleaseNegateFilterreleaseExclude
Namespace excludenamespaceNegateFilternamespaceExclude
Health endpointsNone/healthz, /readyz, /metrics
Prometheus metricsNoneSupported
Orphan NS cleanupNot supportedSupported

Migration example:

v3.x values:

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

pruneProfiles:
  - olderThan: "7 days ago"
    helmReleaseFilter: "^feature-.+"
    namespaceFilter: "^feature-.+"
    maxReleasesToKeep: 10

v4.x values:

pruner:
  dryRun: false
  interval: "4h"
  olderThan: "7d"
  releaseFilter: "^feature-.+"
  namespaceFilter: "^feature-.+"
  maxReleasesToKeep: 10

Values

KeyTypeDefaultDescription
image.repositorystring"us-docker.pkg.dev/fairwinds-ops/oss/helm-release-pruner"Image repository
image.tagstring"v4.1.1"Image tag (defaults to appVersion)
image.pullPolicystring"Always"Image pull policy
imagePullSecretslist[]Image pull secrets
nameOverridestring""Override the chart name
fullnameOverridestring""Override the full release name
prunerobject{"cleanupOrphanNamespaces":false,"debug":false,"deleteRateLimit":"100ms","dryRun":true,"interval":"1h","maxReleasesToKeep":0,"namespaceExclude":"","namespaceFilter":"","olderThan":"","orphanNamespaceExclude":"","orphanNamespaceFilter":"","preserveNamespace":false,"releaseExclude":"","releaseFilter":"","systemNamespaces":""}Pruner configuration options (maps to CLI flags)
pruner.dryRunbooltrueIf true, only log what would be deleted without actually deleting
pruner.debugboolfalseEnable debug logging
pruner.intervalstring"1h"How often to run the pruning cycle (daemon mode only) Supports Go duration format: "1h", "30m", "6h"
pruner.olderThanstring""Delete releases older than this duration Supports: Go durations (336h), days (14d), weeks (2w)
pruner.maxReleasesToKeepint0Keep only the N most recent releases globally after filtering (0 = no limit)
pruner.releaseFilterstring""Regex to include matching release names
pruner.releaseExcludestring""Regex to exclude matching release names
pruner.namespaceFilterstring""Regex to include matching namespaces
pruner.namespaceExcludestring""Regex to exclude matching namespaces
pruner.preserveNamespaceboolfalseDon't delete namespaces even when empty after release deletion
pruner.cleanupOrphanNamespacesboolfalseEnable cleanup of namespaces that have no Helm releases
pruner.orphanNamespaceFilterstring""Regex filter for namespaces to consider for orphan cleanup (REQUIRED when using cleanupOrphanNamespaces)
pruner.orphanNamespaceExcludestring""Regex to exclude namespaces from orphan cleanup
pruner.systemNamespacesstring""Comma-separated list of additional namespaces to never delete (kube-system, kube-public, default, kube-node-lease are always protected)
pruner.deleteRateLimitstring"100ms"Minimum duration between delete operations (0 to disable)
replicasint1Number of replicas (should typically be 1)
healthAddrstring":8080"Address for health check and metrics endpoints
service.enabledbooltrueCreate a Service for health/metrics endpoints
service.portint8080Service port
service.annotationsobject{}Service annotations
serviceMonitor.enabledboolfalseCreate a ServiceMonitor for Prometheus scraping
serviceMonitor.intervalstring"30s"Scrape interval
serviceMonitor.additionalLabelsobject{}Additional labels for the ServiceMonitor
serviceAccount.createbooltrueCreate a ServiceAccount
serviceAccount.namestring""Name of an existing ServiceAccount to use (if create is false)
serviceAccount.annotationsobject{}Annotations for the ServiceAccount
rbac.createbooltrueCreate RBAC resources (ClusterRole, ClusterRoleBinding)
podAnnotationsobject{}Additional annotations for pods
podLabelsobject{}Additional labels for pods
resourcesobject{"limits":{"memory":"128Mi"},"requests":{"cpu":"10m","memory":"32Mi"}}Resource requests and limits
nodeSelectorobject{}Node selector for pod scheduling
tolerationslist[]Tolerations for pod scheduling
affinityobject{}Affinity rules for pod scheduling
securityContextobject{"fsGroup":10324,"runAsNonRoot":true,"runAsUser":10324}Pod security context
containerSecurityContextobject{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true}Container security context

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 v4.1.1 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