What is Kubernetes API analog for `kubectl auth can-i`

Viewed 339

kubectl has the auth can-i subcommand. Which K8s API does the command use? I tried authorization.k8s.io/v1 SelfSubjectAccessReview but it requires the extra permissions to perform the request. Does anybody know how it works in the kubectl?

1 Answers

The kubectl auth can-i command makes the following API request:

POST /apis/authorization.k8s.io/v1/selfsubjectaccessreviews

With a SelfSubjectAccessReview object as a body parameter named body.

You can see this by executing the kubectl command with increased verbosity, for example:

kubectl auth can-i create pods -v 6

And you can find the documentation of the API endpoint in the API reference.

Related