- Split `scenarios/scenarios.json` into individual JSON files under `scenarios/data/` named `<scenario-id>.json` - Split `scenarios/bundles.json` into individual JSON files under `scenarios/bundles/` named `<bundle-id>.json` - Updated `backend/server.js` to dynamically load scenario and bundle files from their respective directories - Updated documentation in `scenarios/SCHEMA.md` and `README.md` to reflect the new repository layout and contributor workflow Signed-off-by: Abhinav Sinha <[email protected]>
50 lines
2.1 KiB
JSON
50 lines
2.1 KiB
JSON
{
|
|
"id": "cks-rbac-clusterrole",
|
|
"title": "Cluster-Level RBAC",
|
|
"category": "Cluster Security",
|
|
"difficulty": "Medium",
|
|
"type": "task",
|
|
"weight": 5,
|
|
"description": "## Cluster Roles and Bindings\n\nSome resources, like Nodes, are cluster-scoped and cannot be accessed using normal Roles and RoleBindings.\n\n**Your task:**\n\n1. Create a ServiceAccount named `monitor-sa` in the `monitoring` namespace.\n2. Create a ClusterRole named `node-viewer` that grants `get`, `list`, and `watch` permissions on `nodes`.\n3. Create a ClusterRoleBinding named `monitor-node-binding` to bind the ClusterRole to the ServiceAccount.\n\n```bash\n# Verify your permissions:\nkubectl auth can-i list nodes --as=system:serviceaccount:monitoring:monitor-sa\n```",
|
|
"hints": [
|
|
{
|
|
"title": "Imperative Commands",
|
|
"body": "Create the SA, then the ClusterRole, then the ClusterRoleBinding.",
|
|
"command": "kubectl create sa monitor-sa -n monitoring && kubectl create clusterrole node-viewer --verb=get,list,watch --resource=nodes && kubectl create clusterrolebinding monitor-node-binding --clusterrole=node-viewer --serviceaccount=monitoring:monitor-sa"
|
|
}
|
|
],
|
|
"setup_commands": [
|
|
{
|
|
"command": "kubectl create namespace monitoring --dry-run=client -o yaml | kubectl apply -f -"
|
|
}
|
|
],
|
|
"validation": {
|
|
"commands": [
|
|
{
|
|
"description": "monitor-sa exists in monitoring namespace",
|
|
"command": "kubectl get sa monitor-sa -n monitoring -o jsonpath='{.metadata.name}'",
|
|
"expected_output": "monitor-sa",
|
|
"match": "exact"
|
|
},
|
|
{
|
|
"description": "ServiceAccount can list nodes",
|
|
"command": "kubectl auth can-i list nodes --as=system:serviceaccount:monitoring:monitor-sa",
|
|
"expected_output": "yes",
|
|
"match": "exact"
|
|
}
|
|
]
|
|
},
|
|
"default_namespace": "default",
|
|
"teardown_commands": [
|
|
{
|
|
"command": "kubectl delete sa monitor-sa -n monitoring --ignore-not-found"
|
|
},
|
|
{
|
|
"command": "kubectl delete clusterrole node-viewer --ignore-not-found"
|
|
},
|
|
{
|
|
"command": "kubectl delete clusterrolebinding monitor-node-binding --ignore-not-found"
|
|
}
|
|
]
|
|
}
|