estadea operator

A Kubernetes operator that automatically force-deletes pods stuck in Terminating, Pending, Unknown or Failed state for longer than a configurable grace period.

Release License Kubernetes Helm

Overview

Estadea watches your cluster for pods that get stuck in a terminating or broken state. When a pod remains stuck longer than the configured graceTimeout, the operator removes its finalizers and force-deletes it, keeping your namespaces clean without manual intervention.

It is configured through a cluster-scoped Custom Resource (PodReaper) that lets you define which namespaces to watch, which pod states to target, and how aggressively to clean them up.

Prerequisites

  • Kubernetes 1.25+
  • Helm 3.10+
  • Cluster-admin permissions to install CRDs and ClusterRoles

Installation

Add the Helm repository

helm repo add estadea https://heimops.github.io/estadea
helm repo update

Install the operator

helm install estadea estadea/estadea \
  --namespace estadea-system \
  --create-namespace
✓ What gets installed The CRD podreapers.reaper.estadea.io, a ClusterRole and ClusterRoleBinding, a ServiceAccount, and the operator Deployment — all in the estadea-system namespace.

Verify the operator is running

kubectl get pods -n estadea-system
# Expected output:
NAME                                   READY   STATUS    RESTARTS   AGE
estadea-controller-manager-xxxx-yyyy   1/1     Running   0          30s

Uninstall

helm uninstall estadea -n estadea-system

# CRDs are kept by default. Remove manually only if needed:
kubectl delete crd podreapers.reaper.estadea.io

Quick start

  1. Install the operator using the Helm command above.
  2. Create a PodReaper resource to define the cleanup rules:
    kubectl apply -f - <<EOF
    apiVersion: reaper.estadea.io/v1alpha1
    kind: PodReaper
    metadata:
      name: cluster-reaper
    spec:
      podStates:
        - Terminating
      graceTimeout: "5m"
      checkInterval: "30s"
    EOF
  3. Check it's working:
    kubectl get podreaper

The PodReaper resource

PodReaper is a cluster-scoped CRD. You can have multiple instances, each with different targets and thresholds — for example a lenient one for your development namespaces and an aggressive one for production.

apiVersion: reaper.estadea.io/v1alpha1
kind: PodReaper
metadata:
  name: my-reaper
spec:
  namespaces:           # optional — omit to watch ALL namespaces
    - default
    - production
  podStates:            # which stuck states to clean up
    - Terminating
    - Unknown
  graceTimeout: "5m"   # wait this long before force-deleting
  checkInterval: "30s" # how often to scan

Examples

Clean all stuck Terminating pods across the whole cluster

apiVersion: reaper.estadea.io/v1alpha1
kind: PodReaper
metadata:
  name: global-reaper
spec:
  podStates:
    - Terminating
  graceTimeout: "5m"
  checkInterval: "30s"

Aggressive cleanup for a CI namespace

apiVersion: reaper.estadea.io/v1alpha1
kind: PodReaper
metadata:
  name: ci-reaper
spec:
  namespaces:
    - ci
  podStates:
    - Terminating
    - Failed
    - Unknown
  graceTimeout: "2m"
  checkInterval: "15s"

Watch multiple production namespaces conservatively

apiVersion: reaper.estadea.io/v1alpha1
kind: PodReaper
metadata:
  name: prod-reaper
spec:
  namespaces:
    - production
    - staging
  podStates:
    - Terminating
  graceTimeout: "15m"
  checkInterval: "1m"

Checking status

List all PodReaper instances

kubectl get podreaper
# short alias:
kubectl get pr

Inspect a specific instance

kubectl describe podreaper cluster-reaper

The status section shows:

FieldDescription
lastRunTimeTimestamp of the last reconciliation sweep
totalPodsDeletedCumulative count of pods force-deleted since creation
conditionsReady and Running condition entries

Watch the operator logs

kubectl logs -n estadea-system -l control-plane=controller-manager -f

Spec reference

FieldTypeDefaultDescription
namespaces []string all Namespaces to watch. Omit or leave empty to watch every namespace in the cluster.
podStates []string ["Terminating"] Pod states that trigger cleanup. Valid values: Terminating, Pending, Unknown, Failed.
graceTimeout string "5m" Minimum time a pod must remain in a qualifying state before being force-deleted. Go duration format: 30s, 5m, 1h30m.
checkInterval string "30s" How often the operator scans for stuck pods. Go duration format.

Helm values

ParameterDefaultDescription
replicaCount1Number of operator replicas
image.repositoryghcr.io/heimops/estadeaOperator image repository
image.tagchart appVersionImage tag override
image.pullPolicyIfNotPresentImage pull policy
namespace.createtrueCreate the operator namespace
namespace.nameestadea-systemNamespace for the operator
leaderElecttrueEnable leader election (recommended in production)
resources.limits.cpu100mCPU limit
resources.limits.memory64MiMemory limit
resources.requests.cpu10mCPU request
resources.requests.memory32MiMemory request
metrics.enabledtrueExpose Prometheus metrics on :8080
metrics.serviceMonitor.enabledfalseCreate a Prometheus ServiceMonitor
crds.installtrueInstall CRDs via Helm
crds.keeptrueKeep CRDs on helm uninstall
defaultPodReaper.enabledfalseDeploy a default PodReaper instance on install

Override example

helm install estadea estadea/estadea \
  --namespace estadea-system \
  --create-namespace \
  --set leaderElect=true \
  --set metrics.serviceMonitor.enabled=true \
  --set defaultPodReaper.enabled=true \
  --set defaultPodReaper.spec.graceTimeout=10m

RBAC

The operator requires a ClusterRole with the following permissions:

API GroupResourcesVerbs
reaper.estadea.iopodreapers, podreapers/status, podreapers/finalizersget, list, watch, create, update, patch, delete
corepodsget, list, watch, update, patch, delete
corenamespacesget, list, watch
coreeventscreate, patch
coordination.k8s.ioleasesget, list, watch, create, update, patch, delete
⚠ Note on pod deletion The operator needs delete on pods and update/patch to strip finalizers before force-deleting. These permissions are cluster-wide when namespaces is empty.