This is a really simple controller used in a side-project for raising OOCKilled (Out of Compute / Out of CPU) when exceeding CPU limits in a cluster. Works in a similar way to OOMKilled (when a pod exceeds memory limits).
Latest tag: docker pull colwill/ooc-controller:v1.0.0
Please ⭐ if you find this useful 💚
Controller polls Kubernetes Metrics API for CPU usage across all running pods. For each container it compares usage against the container's limits.cpu (or requests.cpu, configurable). If usage exceeds the threshold, the pod is killed and a Kubernetes Warning event is raised against it with OOCKilled as the reason.
NAMESPACE LAST SEEN TYPE REASON OBJECT MESSAGE
default 1s Warning OOCKilled pod/test-123 CPU limits: using 750m, limits is 500mExample config file (note: kube-system & kube-public are ignored in default.yaml):
ignore:
namespace:
- dev
- prod
deployments:
- myapp
pollInterval: "30s"
# compare against "limits" or "requests"
thresholdSource: "limits"- Go 1.25+
- Docker
- kind
- kubectl
make kind-up
kubectl logs -f -n ooc-system deployment/ooc-controller
kubectl get events --all-namespaces --field-selector reason=OOCKilled -w
make deploy-local
make test-e2e
make kind-downmake build
make test
make lint
make docker-buildThe controller requires metrics-server to be installed in the target cluster.
# Deploy with default configuration
kubectl apply -k deploy/manifests/
# Or customise the ConfigMap first
kubectl edit configmap ooc-controller-config -n ooc-system
kubectl rollout restart deployment/ooc-controller -n ooc-systemThe controller needs the following permissions:
get,list,watch,deleteonpods(core API)get,listonpods(metrics.k8s.io API)create,patchonevents(core API)
These are defined in deploy/manifests/rbac.yaml.