Learning center

Check pods/log when kubectl can read a pod but cannot read its logs

Kubernetes authorizes a pod read and a pod log read against different resource names. A rule for get on pods does not cover get on pods/log.

In a fictional on-call rotation, an operator can inspect a pod in reports but kubectl logs returns Forbidden. Run both authorization queries in the same user context so the subresource is the only difference.

kubectl auth can-i get pod/report-worker-7d46d -n reports
kubectl auth can-i get pod/report-worker-7d46d --subresource=log -n reports

These requests ask about authorization and do not fetch log content. If the checks return yes and no respectively, take the named subresource and namespace to the policy owner. Ask whether the log content is within the operator's role. If authorization already allows the request, read the original error and check whether the client used the same identity, pod and cluster. RBAC resource and subresource syntax ยท kubectl auth can-i

Trace another denied request.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading