Learning center

Explain why a Kubernetes named resource grant does not allow an unfiltered list

When a Role restricts access with resourceNames, look for the object name on a get or a matching metadata.name field selector on a list or watch.

Suppose a fictional job may get and list ConfigMap report-format in reports. Its Role sets resourceNames: ["report-format"], and a named get succeeds. The library's unfiltered list fails. Use the same credential context to check the list with a selector for the approved name.

kubectl get configmaps -n reports \
  --field-selector metadata.name=report-format -o name

If the job only reads one known ConfigMap, a named get may meet its needs with a narrower verb set. If a list or watch is necessary, inspect the client's actual request to make sure it passes the selector. Removing resourceNames from a list rule can reveal every ConfigMap in the namespace. Kubernetes RBAC resourceNames behavior ยท Kubernetes field selectors

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