Interview Prep/Kubernetes/Control plane, RBAC, webhooks and autoscaling

A user can `get pods` but `kubectl logs` fails with `cannot get resource "pods/log"` and `kubectl exec` fails with `cannot create resource "pods/exec"`.

BeginnerTroubleshootingControl plane, RBAC, webhooks and autoscaling
Answer

Likely causes → Subresources need their own RBAC rules. pods/log needs get; pods/exec, pods/attach and pods/portforward need create.

Diagnose →

kubectl auth can-i get pods --subresource=log -n app --as [email protected]
kubectl auth can-i create pods --subresource=exec -n app --as [email protected]

Fix →

rules:
  - apiGroups: [""]
    resources: ["pods", "pods/log"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["pods/exec"]
    verbs: ["create"]

Prevent → Separate "read" and "debug" roles; exec in production only through a break-glass group with audit logging.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Control plane, RBAC, webhooks and autoscaling