HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

kubectl auth — Inspect access permissions in a Kubernetes cluster. More information: <https://kubernetes.io/docs/re

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandkubectl authaccesscliclusterkubernetespermissionsinspect

Problem

How to use the kubectl auth command: Inspect access permissions in a Kubernetes cluster. More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_auth/>.

Solution

kubectl auth — Inspect access permissions in a Kubernetes cluster. More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_auth/>.

Check if the current user can perform all actions on all resources in a specific namespace:
kubectl auth can-i '*' '*' {{[-n|--namespace]}} {{namespace}}


Check if the current user can perform a specific verb on a specific resource:
kubectl auth can-i {{verb}} {{resource}} {{[-n|--namespace]}} {{namespace}}


Check if a specific user or service account can perform an action on a resource:
kubectl auth can-i {{verb}} {{resource}} {{[-n|--namespace]}} {{namespace}} --as {{user_or_sa}}


List all actions the current user is allowed to perform in a namespace:
kubectl auth can-i --list {{[-n|--namespace]}} {{namespace}}

Code Snippets

Check if the current user can perform all actions on all resources in a specific namespace

kubectl auth can-i '*' '*' {{[-n|--namespace]}} {{namespace}}

Check if the current user can perform a specific verb on a specific resource

kubectl auth can-i {{verb}} {{resource}} {{[-n|--namespace]}} {{namespace}}

Check if a specific user or service account can perform an action on a resource

kubectl auth can-i {{verb}} {{resource}} {{[-n|--namespace]}} {{namespace}} --as {{user_or_sa}}

List all actions the current user is allowed to perform in a namespace

kubectl auth can-i --list {{[-n|--namespace]}} {{namespace}}

Context

tldr-pages: common/kubectl auth

Revisions (0)

No revisions yet.