feat: add probe-port-mismatch and enforce-limits to rootnode-real-ops bundle

This commit is contained in:
2026-08-17 12:45:16 -05:00
parent e31b051f4e
commit 6ddfb1cbde
3 changed files with 129 additions and 1 deletions
@@ -0,0 +1,69 @@
{
"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 - <<EOF\napiVersion: v1\nkind: LimitRange\nmetadata:\n name: resource-defaults\n namespace: workloads\nspec:\n limits:\n - type: Container\n default:\n cpu: 500m\n memory: 256Mi\n defaultRequest:\n cpu: 100m\n memory: 128Mi\nEOF"
},
{
"title": "3. Verify the defaults are injected",
"body": "Deploy a test pod with no resource block into the workloads namespace. Then describe it and check that the container shows the LimitRange defaults under Limits and Requests.",
"command": "kubectl run test-limits --image=nginx:1.25 -n workloads\nkubectl describe pod test-limits -n workloads | grep -A6 'Limits:'"
}
],
"setup_commands": [
{ "command": "kubectl create namespace workloads --dry-run=client -o yaml | kubectl apply -f -" }
],
"validation": {
"description": "Checks that the LimitRange exists with the correct default values.",
"commands": [
{
"description": "LimitRange 'resource-defaults' exists in workloads namespace",
"command": "kubectl get limitrange resource-defaults -n workloads -o jsonpath='{.metadata.name}' 2>/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" }
]
}