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.
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
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
-
Install the operator using the Helm command above.
-
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 -
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:
| Field | Description |
|---|---|
lastRunTime | Timestamp of the last reconciliation sweep |
totalPodsDeleted | Cumulative count of pods force-deleted since creation |
conditions | Ready and Running condition entries |
Watch the operator logs
kubectl logs -n estadea-system -l control-plane=controller-manager -f
Spec reference
| Field | Type | Default | Description |
|---|---|---|---|
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
| Parameter | Default | Description |
|---|---|---|
replicaCount | 1 | Number of operator replicas |
image.repository | ghcr.io/heimops/estadea | Operator image repository |
image.tag | chart appVersion | Image tag override |
image.pullPolicy | IfNotPresent | Image pull policy |
namespace.create | true | Create the operator namespace |
namespace.name | estadea-system | Namespace for the operator |
leaderElect | true | Enable leader election (recommended in production) |
resources.limits.cpu | 100m | CPU limit |
resources.limits.memory | 64Mi | Memory limit |
resources.requests.cpu | 10m | CPU request |
resources.requests.memory | 32Mi | Memory request |
metrics.enabled | true | Expose Prometheus metrics on :8080 |
metrics.serviceMonitor.enabled | false | Create a Prometheus ServiceMonitor |
crds.install | true | Install CRDs via Helm |
crds.keep | true | Keep CRDs on helm uninstall |
defaultPodReaper.enabled | false | Deploy 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 Group | Resources | Verbs |
|---|---|---|
reaper.estadea.io | podreapers, podreapers/status, podreapers/finalizers | get, list, watch, create, update, patch, delete |
| core | pods | get, list, watch, update, patch, delete |
| core | namespaces | get, list, watch |
| core | events | create, patch |
coordination.k8s.io | leases | get, list, watch, create, update, patch, delete |
delete on pods and update/patch
to strip finalizers before force-deleting. These permissions are cluster-wide when
namespaces is empty.