Managing OAuth Scopes for kubectl

OAuth scopes decide who can do what in Kubernetes. If they’re wrong, commands fail or, worse, grant too much power. Managing OAuth scopes for kubectl is not optional—it’s the line between control and chaos.

Kubectl uses your kubeconfig to authenticate requests. When OAuth is in play, scopes define the exact privileges your access token carries. A scope might allow listing pods, but not deleting them. Another might grant node administration. Every token issued by your IdP (Identity Provider) needs the right scopes—or kubectl becomes either powerless or dangerous.

To manage OAuth scopes for kubectl:

  1. Identify Required Scopes – Map each Kubernetes action to its API verbs. For example, get and list for read access, create, update, and delete for write operations.
  2. Configure OAuth in the IdP – In Okta, Auth0, or your enterprise IdP, define custom scopes that match Kubernetes RBAC roles.
  3. Update Kubeconfig – Ensure the user section points to the OAuth token endpoint with those exact scopes. Add or edit the auth-provider configuration to request the scopes on login or token refresh.
  4. Test Permissions – Use kubectl auth can-i to verify if the current token and scopes allow planned actions.
  5. Rotate and Audit – Expire unused tokens. Audit scope usage to prevent privilege creep.

Fine-grained scope management is critical for multi-team clusters, CI/CD pipelines, and production security. It pairs with Kubernetes RBAC, but operates at the OAuth layer—controlling what the access token delivers to kubectl before RBAC even evaluates the request.

Get this wrong and you’ll lose either capability or security. Get it right and you’ll control Kubernetes with precision.

Want to see OAuth scopes management for kubectl done right? Check out hoop.dev and experience it live in minutes.