Score:1

How to know what roles are missing in RBAC

jp flag

How can I figure out what role is missing in a service account?

Like I have the following:

kubectl auth can-i create taskrun --all-namespaces --as=system:serviceaccount:default:default

no

Ok, but where to go from here :-)

in flag
The verb and resources are [mostly straightforward](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#referring-to-resources), but I don't believe there is any built-in "create an RBAC Role for me" tooling in kubernetes; what have you already tried and what is giving you trouble?
jp flag
It is just that I need to figure out, what kind of role I need to bind to a service account.
in flag
Right, but my point is that no (built in) process will magically know what the `ServiceAccount` is _trying_ to interact with. Does it need `Secret` access? _Write_ access to `Secret`s? _Delete_? if you don't care and just want it to work, then bind `cluster-admin` to that `ServiceAccount` and it'll for sure work. If you do care, then enumerating the verbs and resources required is the only way
jp flag
Cool, thanks for info. I will look at the resource and add verbs accordingly to what I want to do to a rols and bind it to the sa to be used.
Score:1
in flag

Posting the answer as community wiki, feel free to edit and expand.


As @mdaniel has already mentioned, there are no built-in tools in kubernetes which will figure out required access for a service account for you and then create a Role and RoleBinding.

As a temporary solution it can be used a clusterrole - cluster-admin, however best practice is to provide only minimun possible and required access rights.


Below are links to documentation which will be helpful:

API request verb - API verbs like get, list, create, update, patch, watch, delete, and deletecollection are used for resource requests

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.