Repository navigation
Authroization for non-kubernetes resources #178
Replies: 4 comments
|
I don't think that's a good idea to let Perses modify the CR. Only the operator should be allowed to manipulate them. Otherwise there will be a conflict at some point or a permanent update loop where the operator and perses are updating the same object over and over. Perhaps in the perspective where all Perses resources are managed by k8s, ephemeral dashboard does not make sense anymore. Ephemeral dashboard exists primary to do a preview of a dashboard during the Dashboard as Code workflow (when opening a PR for example). In this context, I don't see a PR being able to create an Ephemeral Dashboard to Perses. Regarding the second option, I don't see how you will be able to have readonly object in the Perses database specially if you are configuring Perses to use the Kubernetes authorisation provider. Regarding the third option, that was my initial idea when thinking about how Perses can work with k8s. But this idea was not applied when creating the operator as RedHat wanted to let user being able to create object directly in the Perses database even if they can create CR. |
|
What we wanted to do is to allow that users can edit their dashboards and datasources from applications inside the cluster, either a custom UI or perses UI so at the time the pragmatic solution was to use synchronization. I see possible that we can add a k8s/etcd storage adapter to perses, and remove the synchronization logic from the operator, so it only handles configuration of perses deployments. This will avoid sync loops as the Operator won't update the CRs related to Perses resources like dashboards and datasources. If a perses deployment uses another adapter for example MySQL then the operator can continue to do the synchronization. Readonly resources would be achieved by using the current RBAC and adding the operator as owner of non-user defined dashboards. Ephemeral dashboards might still work as perses is agnostic of the storage layer and it will simply remove outdated resources. |
|
I also really like the third option (Kubernetes Dataplane). it's truly Kubernetes native and using Kubernetes CRDs as the single source of truth eliminates sync issues and leverages k8s' built-in RBAC capabilities. While there might be issues with the load that ETCD can handle, this approach provides the cleanest architectural foundation and could potentially be optimised with proper caching. The Kubernetes dataplane option feels like the most suitable long-term solution. |
|
While I can't really comment on the merits of either way, I think the current situation is kind of bad, as for (end) users it is confusing. Some objects live in CRs and some don't. Docs say "Use |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Howdy y'all! I wanted to start a discussion here about how the kubernetes authorization should handle any non-CRD related resources. Currently, the operator only support the "Perses", "PersesDashboards", "PersesDatasource", and "PersesGlobalDatasource". Additionally, the authorization can use the "project = kubernetes namespace" relationship. However, after that point the kubernetes authorization has no further opinions on how the other perses resources should be governed, such as variable or ephemeraldashboard. The point of this discussion is to propose some options for how these remaining resources should be handled and get feedback or alternative ideas.
Fully Permissive/Rejective
This is how the current implementation of the kubernetes authorization behaves, rejecting all requests that it does not have an opinion on. The issue with this is that as an RBAC system it has large areas which it doesn't cover and could cause issues with the expected behavior of the system.Create Remaining Resources
I believe the most realistic solution would be to add the remaining remaining perses resources as CRD's, and then allow the kubernetes authorization to handle the permissions of those resources. The biggest issue with this solution is that the kubernetes resources and the perses resources can get out of sync. As the perses API endpoints are open any user with sufficient permissions can go and edit the perses Dashboard while leaving the kubernetes PersesDashboard resources as is, leading to desynced data. I can see three potential solutions to this.
Remaining Resources
So in total
PersesVariable,PersesGlobalVariable,PersesEphemeralDashboard, and potentially adding in aPersesSecretor use the already existing kubernetes secret type.Syncronize resource changes
This option would maintain both the current perses database and the kubernetes CRD's as separate entities. Whenever a change is made to one of the perses resources either a request will be made to the operator to change the resource or the perses backend will directly change the resource itself. A time based cron could be used in conjunction with
updatedAttimestamps to ensure syncronization between different perses backends. This option could put some further load on the etcd database for the cluster with a potentially larger amount of changes. This option is the most straightforward for implementing the EphemeralDashboards, as whenever they are deleted by the perses cron that change will be reflected out to the CR.Readonly resources
The second option is to create the resources confined within the CR's as readonly perses resources. This would ensure that changes cannot be made on the backend which would impact the kubernetes resources. The perses database and the kubernetes CR's are kept as separate resources. The readonly attribute could be configured to allow only a single user to update them, either at a global level by passing the serviceaccount name for the perses operator in as a new config option or on a per resource level.
The primary issue with this solution is that all changes to the resources will have to be done on the kubernetes resource, which currently has much more lax creation and error handling requirements. Substantial effort would need to be expended to ensure that the error handling and formatting of the resource is able to be better understood by the users.
EphemeralDashboards are tricky for this solution, as the backend won't be able to delete the CR's, so likely we would need to add on the ttl to the CRD, and then have the operator be in charge of deleting them and then updating the perses backends with those changes.
Kubernetes Dataplane
Unlike the previous solution, this will look to merge the perses database and the kubernetes CRD's, by using the kubernetes CRD's as the sole point of truth and a new database layer for perses. Each perses deployment will need to be given full permission to read and update the perses CR's, directly reading, creating and updating the perses CR's.
The biggest issues with this approach are the extra load placed onto ETCD and the addition of a large number of network calls. The network calls could be looked to potentially be reduced through a caching layer, but then that will just result in the same issue of desyncronizatoin we are trying to resolve. One large positive of this solution is that the perses-operator will no longer need to reflect the changes to CR's down into each perses backend.
As always I'm open to an other options and look forward to hearing everyones thoughts
All reactions