-
Notifications
You must be signed in to change notification settings - Fork 11
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
Document required RBAC permissions and why they are needed #379
Comments
Spent some time investigating this today. Testing was done in a kind cluster on my machine with impersonation:
The user foo had no permissions at all initially and I added permissions as I got errors during the installation process to arrive at these roles and rolebindings: # Cluster scoped resources
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: deploy-stackable-cluster
rules:
- apiGroups:
- "apiextensions.k8s.io"
resources:
- customresourcedefinitions
verbs:
- create
- get
- list
- apiGroups:
- "rbac.authorization.k8s.io"
resources:
- clusterroles
- clusterrolebindings
verbs:
- get
- list
- create
- apiGroups:
- "storage.k8s.io"
resources:
- storageclasses
- csidrivers
verbs:
- get
- list
- create
- apiGroups:
- "secrets.stackable.tech"
resources:
- secretclasses
verbs:
- get
- list
- create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: deploy-stackable-cluster
subjects:
- kind: User
name: foo
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: deploy-stackable-cluster
apiGroup: rbac.authorization.k8s.io
# Namespaced Resources
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: deploy-stackable-namespaced
rules:
- apiGroups:
- ""
resources:
- serviceaccounts
- configmaps
- secrets
verbs:
- get
- list
- create
- apiGroups:
- "apps"
resources:
- deployments
verbs:
- get
- list
- create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: deploy-stackable-namespaced
subjects:
- kind: User
name: foo
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: deploy-stackable-namespaced
apiGroup: rbac.authorization.k8s.io This seems to allow installing the operator itself, however the helm chart also deploys serviceaccounts for the operators themselves, which require additional privileges, since users can only grant permissions they hold themselves:
I have started adding these in a separate ClusterRole object to keep them a bit separate: # Rights that are only needed as they are granted to the operator roles during the install
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: deploy-stackable-grant
rules:
- apiGroups:
- "events.k8s.io"
resources:
- events
verbs:
- create
- apiGroups:
- ""
resources:
- configmaps
- endpoints
- pods
- secrets
- serviceaccounts
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- list
- watch
- apiGroups:
- "apps"
resources:
- deployments
- statefulsets
- daemonsets
verbs:
- get
- create
- delete
- list
- patch
- update
- watch
- apiGroups:
- "rbac.authorization.k8s.io"
resources:
- clusterroles
verbs:
- bind
- apiGroups:
- "rbac.authorization.k8s.io"
resources:
- rolebindings
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
# This cluster role binding allows anyone in the "manager" group to read secrets in any namespace.
kind: RoleBinding
metadata:
name: deploy-stackable-grant
subjects:
- kind: User
name: foo
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: deploy-stackable-grant
apiGroup: rbac.authorization.k8s.io Not sure if this works yet, as I still get the full error message shown above. Maybe k8s reports all requested privileges as soon as one is missing .. I ran out of time at this point. |
I've played around with the error message a bit and the following command should be able to convert what k8s outputs to permissions we can stick in a ClusterRole object:
90% of this is to compensate for Kubernetes outputting something that resembles json but isn't:
After those are fixed it is really just piping it through |
Is this something we can document once for all operators or do we need to document this for every operator individually? What could be a good way to document this? Feels like it's very detailed and prone to become outdated. |
No description provided.
The text was updated successfully, but these errors were encountered: