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.
More on Control plane, RBAC, webhooks and autoscaling
A developer gets `Error from server (Forbidden): pods is forbidden: User "[email protected]" cannot list resource "pods" in API group "" in the namespace "payments"`.BeginnerA CI pipeline fails with `deployments.apps "api" is forbidden: User "system:serviceaccount:ci:deployer" cannot patch resource "deployments" in API group "apps" in the namespace "prod"`.BeginnerCreating a RoleBinding fails with `is attempting to grant RBAC permissions not currently held`.IntermediateEvery `kubectl apply` fails with `Internal error occurred: failed calling webhook "validate.kyverno.svc-fail": failed to call webhook: Post "https://kyverno-svc.kyverno.svc:443/validate/fail?timeout=10s": context deadline exceeded`.AdvancedCreating a Certificate fails with `failed calling webhook "webhook.cert-manager.io": ... no endpoints available for service "cert-manager-webhook"`.IntermediateA webhook fails with `failed calling webhook ... tls: failed to verify certificate: x509: certificate signed by unknown authority`.Intermediate