Project reference ↗

k8s-cleanup collected several maintenance scripts aimed at reclaiming resources left behind by containers and Kubernetes workloads. Its jobs targeted different things, including unused Docker artifacts, completed workload objects and old etcd directories. It was useful in the historical environments those scripts assumed, but the repository is archived and the tasks do not share one safe modern replacement. First identify the actual cleanup problem and the system that owns it.

Current guidance

The exact upstream onfido/k8s-cleanup repository is archived. Its README describes three different jobs: Docker container/image/volume cleanup, removal of old Kubernetes workload objects, and deletion of empty etcd directories. It also requires the obsolete batch/v2alpha1 CronJob API. These are historical implementation assumptions, not current cluster-maintenance instructions.

Inventory the problem before selecting a replacement. Disk pressure on a containerd node, completed Job retention and control-plane database maintenance are separate issues with different owners. In particular, a Docker cleanup DaemonSet is not a portable solution for every container runtime, and an etcd directory should not be edited through a legacy script simply because it appears empty.

Use the cluster and runtime’s supported garbage-collection settings and workload retention mechanisms for the relevant case. Preserve Deployment revision history needed for rollback and understand persistent-volume reclaim behavior before deleting old objects. Trial any object-cleanup selector against a read-only inventory, then disposable workloads with known retention requirements. Recovery and auditability matter more than achieving the smallest object count; an age threshold is not proof that data or configuration is expendable.

Historical upstream link check · 2026-10-09

The recorded upstream address responded successfully (HTTP 200) on 2026-10-09. GitHub marks onfido/k8s-cleanup as archived. This confirms the repository's read-only archive state; any successor or supported distribution needs separate evidence. Link availability does not certify the historical installation instructions or current security support.

Source for this check ↗

Website availability is separate from project, chart and image support. Use the current guidance and primary sources on this page to assess the distribution.

The original record

Historical Kubedex content

Original publication: 2018-09-25T04:15:55+00:00. Preserved for context. Commands, versions, prices and results below reflect the original research.

Here are 3 cleanups you can apply on your kubernetes cluster:

  • Cleans up exited containers and dangling images/volumes running as a DaemonSet (docker-clean.yml).
  • Cleans up old replica sets, finished jobs and unrecycled evicted pods as a CronJob (k8s-clean.yml).
  • Cleans up empty directory (not used anymore) in etcd as a CronJob (etcd-empty-dir-cleanup.yml).

You must have batch/v2alpha1 enabled on your k8s API server runtime config in order to run the CronJob.

Env vars

In the DaemonSet (docker-clean.yml) you can set DOCKER_CLEAN_INTERVAL to modify the interval when it cleans up exited containers and dangling images/volumes; defaults to 30min (1800s).

In the CronJob (k8s-clean.yml) you can set DAYS to modify the maximum age of replica sets; defaults to 7 days.

Deployment

kubectl –context CONTEXT -n kube-system apply -f rbac.yml
kubectl –context CONTEXT -n kube-system apply -f docker-clean.yml
kubectl –context CONTEXT -n kube-system apply -f k8s-clean.yml
kubectl –context CONTEXT -n kube-system apply -f etcd-empty-dir-cleanup.yml

The post k8s-cleanup appeared first on kubedex.com.

Sources & further reading

  1. Archived cleanup implementation
  2. Recovered historical source

Spotted something that needs another look?

Help improve this page →