Repository navigation
Kubernetes RBAC Support #135
Replies: 1 comment 3 replies
|
Hi @PeterYurkovich. First of all thank you for this very detailed description of the situation and different possibilities. I'm pretty sure it took time for you and you're saving us a lot of headaches on that topic! My preference would go on the third solution. I'm personally not against integrating more k8s dep, if it's officially exposed k8s API and lib dedicated to that. We already have the k8s discovery if I remember well? Or maybe this is an unimplemented nutshell 🤔 I would be curious to see if you already started some implementations / poc in that direction. Do you have also some documentations from k8s explaining how to be a relying party for k8s "identity provider" and authorization system? |




Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This discussion is put forth to foster discussion on how Perses and its k8s RBAC based authorization may take place. This feature is needed to ease dashboard management by keeping and reusing existing roles and users from k8s, while retaining the granular control that Perses's existing RBAC system encompasses.
Background
Use Cases
The implementation options were considered noting the following perses-operator use cases:
a.
perses/corebackend deployedb. Embedded Perses Frontend
a.
perses/corebackend deployedb. Perses frontend deployed
c. (optional) Embedded Frontend
Perses API
The Perses API endpoints generally map well to the k8s RBAC, so the following section discusses some locations where it doesn't or where specific implementations may not map correctly.
Perses API
Projects
All non-project API endpoints contain project or unbound permissions (ie. see ALL GlobalDatasources). However, the get projects should only return the projects which the user has access to. This would be an issue for the sidecar implementations which provide authorization before accessing the endpoint.
As the operator looks to map namespaces to projects, the project API endpoints could be not exposed for this use case, and instead embedded perses UI's could use the k8s api to retrieve namespaces they have access to. This solution wouldn't work for headful deployments of the operator
Global Datasource/Variable
The
perses/operatorcurrently doesn't support GlobalDatasource or GlobalVariable as a resource type, so they will need to be added.Upon creation of the PersesGlobalDatasource and PersesGlobalVariable types, a ClusterRole and ClusterRoleBinding should be used to perform k8s authentication
Variable/Ephemeral Dashboard
The
perses/operatorcurrently doesn't support Variable or EphemeralDashboard as a resource type, so they will need to be added.Users/Role/RoleBindings
Architecture Options
Synchronize Perses RBAC with k8s RBAC
This option would run
perses/corewith k8s authentication (k8s token) and have theperses/operatorbe responsible for syncing with k8s RBAC. This would requireperses/operatorto watch all Users, Roles, RoleBindings, ClusterRoles, and ClusterRoleBindings for relevant change, then connect and update eachperses/coredeployment. This solution feels like it would have a difficult time scaling into large clusters, and as such is not considered for the remainder of this discussion.Auth-less Perses with Sidecar(s)
This solution would run Perses without authentication and authorization, instead looking to offload the k8s authentication and authorization onto one or more sidecars. This solution would require minimal changes in
perses/core, but would require substantial downstream re-implementation of theperses/coreAPI RBAC setup from Perses within the sidecar configurations on a route-by-route basis. It would also require continuous downstream maintenance of these sidecar configurations to keep them up to date withperses/coreAPI.Sidecars
#### [brancz/kube-rbac-proxy](https://github.com/brancz/kube-rbac-proxy) This sidecar performs authentication based on k8s tokens and authorization based on k8s RBAC. It can use "rewrites" to protect a general route through query params or request headers. For example: - `/dashboards?namespace=test` - `curl https://perses.perses/api/v1/dashboards -H 'Namespace: test'` However it can't protect general locations: - `/projects` or can't protect path locations: - `/projects//datasources` If sidecars are decided on as the approach, a small change on the frontend to set a namespace header onto all appropriate requests would be required.Separate Authorization Sidecars
observatorium/opa-openshift
This sidecar does not perform authentication, but instead receives requests about if a user or group has access to an item and responds in a positive or negative manner.
In addition to the sidecar's authorization, authentication could be provided in a separate sidecare or be added as an authentication option into
perses/coreAdd k8s Authentication and Authorization to Perses
This solution would look to add a new authentication option (k8s tokens) to
perses/core. It would also look to add a second authorization flow toperses/corewhich connects to the k8s API and makes SubjectAccessReview requests. This solution would allow the creation of a direct mapping between the k8s and Perses RBAC roles and subjects, which could prevent downstream drift between the two. This option will add k8s specific code intoperses/corewhich may not be desirable.Feedback
Let me know if you have any feedback, especially any information or preferences on:
All reactions