Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

role binding : apiGroup definition instead of namespace #213

Open
heurtematte opened this issue May 18, 2022 · 3 comments
Open

role binding : apiGroup definition instead of namespace #213

heurtematte opened this issue May 18, 2022 · 3 comments

Comments

@heurtematte
Copy link
Contributor

As part of the definition of "rbac.authorization.k8s.io/v1", namespace attribute doesn't exist on RoleRef and Subjects attributes definition. Instead it must be the attribut "apiGroup".

Example : https://github.com/eclipse-cbi/jiro/blob/master/instances/automotive.mdmbl/target/k8s/role-binding.json
should be :

"roleRef": {
      "kind": "Role",
      "name": "jenkins-master-owner",
      "apiGroup": "my_api_group"    <=== here
   },
   "subjects": [
      {
         "kind": "ServiceAccount",
         "name": "mdmbl",
         "apiGroup": "my_api_group"         <=== here
      }
   ]

And apiGroup should have a name: https://github.com/eclipse-cbi/jiro/blob/master/instances/automotive.mdmbl/target/k8s/role.json

   "rules": [
      {
         "apiGroups": [
            "my_api_group"             <=== here
         ],
         "resources": [
            "pods",
            "pods/exec"
         ],
@fredg02
Copy link
Contributor

fredg02 commented May 18, 2022

@mbarbero
Copy link
Member

There is a difference between a clusterrolebinding and a rolebinding (as there is for role and clusterrole). A clusterrolebinding is not namespaced, ie it applies to the whole cluster, while a rolebinding is only about a specific namespace. It's very important to keep those a rolebinding and not clusterrolebinding and as such to keep the namespace part, otherwise you will grant permission to the whole cluster 😱

@mbarbero
Copy link
Member

My bad, I read this one too quickly.

IIRC, namespace in roleref was something in the beta version of the RBAC API rbac.authorization.k8s.io/v1. It may still be accepted for backward compatibility reason.

Regarding apiGroups, the core one does not need to be specified (see https://kubernetes.io/docs/reference/using-api/#api-groups)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants