github gianlucam76/k8s-cleaner v0.21.0

9 hours ago

Metric-based resource selection

ResourceSelector now supports querying a Prometheus-compatible endpoint before evaluating each resource. Add metricSource (endpoint URL, optional auth via Secret) and metricQueries (PromQL expressions) to any ResourceSelector — the results are injected into the Lua evaluate script as a global metrics table.

This lets you gate resource actions on live cluster data: scale down Deployments only when their error rate exceeds a threshold, restart Pods only when memory saturation is reported, or skip cleanup entirely when the cluster is under load.

metricSource:
  url: http://prometheus-server.monitoring.svc:9090
metricQueries:
- name: errorRate
  query: sum(rate(http_requests_errors_total[5m])) / sum(rate(http_requests_total[5m]))
evaluate: |
  function evaluate()
    hs = {}
    hs.matching = metrics["errorRate"] ~= nil and metrics["errorRate"] > 0.05
    return hs
  end

Also: upgraded vitest from 3.x to 4.x to fix a critical vulnerability (GHSA-5xrq-8626-4rwp, CVSS 9.8).

Don't miss a new k8s-cleaner release

NewReleases is sending notifications on new releases.