{ "id": "rootnode-enforce-limits", "title": "Stop the Next Outage: Enforce Resource Defaults", "category": "Observability & Ops", "difficulty": "Hard", "type": "task", "weight": 10, "description": "## Stop the Next Outage: Enforce Resource Defaults\n\nThe `node-metrics` incident happened because a workload was deployed with an unbounded resource request. The immediate fix was to right-size that deployment — but the root cause is still live: **nothing stops the next engineer from deploying into the `workloads` namespace without any resource constraints at all**.\n\nThis scenario is about closing that gap. A LimitRange is a namespace-level policy object that automatically injects default resource requests and limits into any container that omits them. One object, applied once, protects every workload in the namespace going forward — without requiring every developer to remember to set resources manually.\n\n**Your task:** Create a LimitRange named `resource-defaults` in the `workloads` namespace that enforces the following defaults for every container:\n\n| Field | Value |\n|---|---|\n| Default CPU limit | `500m` |\n| Default CPU request | `100m` |\n| Default memory limit | `256Mi` |\n| Default memory request | `128Mi` |\n\nOnce the LimitRange is in place, validate that a pod deployed **without any resource block** automatically receives these defaults.\n\n> This is governance, not cleanup. The goal is a policy that survives the next deployment.", "hints": [ { "title": "1. Check the namespace", "body": "The workloads namespace should already exist. Confirm it is there before applying anything — if it is missing, create it first.", "command": "kubectl get namespace workloads" }, { "title": "2. Write the LimitRange manifest", "body": "A LimitRange with type Container and a default/defaultRequest block is what you need. The default field sets limits; defaultRequest sets requests. Save it to a file and apply with kubectl apply -f.", "command": "kubectl apply -f - </dev/null || echo ''", "expected_output": "resource-defaults", "match": "exact" }, { "description": "Default CPU limit is 500m", "command": "kubectl get limitrange resource-defaults -n workloads -o jsonpath='{.spec.limits[0].default.cpu}' 2>/dev/null || echo ''", "expected_output": "500m", "match": "exact" }, { "description": "Default memory limit is 256Mi", "command": "kubectl get limitrange resource-defaults -n workloads -o jsonpath='{.spec.limits[0].default.memory}' 2>/dev/null || echo ''", "expected_output": "256Mi", "match": "exact" }, { "description": "Default CPU request is 100m", "command": "kubectl get limitrange resource-defaults -n workloads -o jsonpath='{.spec.limits[0].defaultRequest.cpu}' 2>/dev/null || echo ''", "expected_output": "100m", "match": "exact" }, { "description": "Default memory request is 128Mi", "command": "kubectl get limitrange resource-defaults -n workloads -o jsonpath='{.spec.limits[0].defaultRequest.memory}' 2>/dev/null || echo ''", "expected_output": "128Mi", "match": "exact" } ] }, "default_namespace": "workloads", "teardown_commands": [ { "command": "kubectl delete limitrange resource-defaults -n workloads --ignore-not-found" }, { "command": "kubectl delete namespace workloads --ignore-not-found --wait=false" } ] }