kubebuilder
kubebuilder copied to clipboard
:sparkles: Add RBAC permissions to allow Prometheus to access metrics
Signed-off-by: João Vilaça [email protected]
Following https://github.com/kubernetes-sigs/kubebuilder/pull/2827, in which the user must manually create and manage the necessary RBAC resources for Prometheus to be able to access the controller metrics, with this PR kubebuilder will be able to generate the necessary RBAC resources that will be deployed alongside the controller and the Prometheus ServiceMonitor if the user chooses to do so.
Hi @machadovilaca. Thanks for your PR.
I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: machadovilaca
Once this PR has been reviewed and has the lgtm label, please assign pwittrock for approval by writing /assign @pwittrock in a comment. For more information see:The Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/ok-to-test
@machadovilaca: PR needs rebase.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Following https://github.com/kubernetes-sigs/kubebuilder/pull/2827, in which the user must manually create and manage the necessary RBAC resources for Prometheus to be able to access the controller metrics, with this PR kubebuilder will be able to generate the necessary RBAC resources that will be deployed alongside the controller and the Prometheus ServiceMonitor if the user chooses to do so.
The problem is that there are two personas at play here:
- The operator author
- The cluster admin
The collection of metrics and the permissions required in order to collect metrics are in the domain of the cluster admin, not the operator author. This PR seems to be proposing a way for operator authors to accomplish a cluster admin task, which I am pretty strongly against.
I think the problem that needs to be solved is discoverability and delegating control: i.e. how does an operator author tell a cluster admin what sorts of permissions to configure and how does an admin apply those permissions? The operator author is the expert on what permissions an operator needs, the cluster admin is the owner of applying those permissions to the cluster. Perhaps we should consider a new set of APIs where the operator can include permission requests in the bundle such that the cluster admin can see them and decide how to act on them. This is actually an area that maintainers in the Operator Framework projects are thinking about now.
Hi @joelanford,
Thank you for the input.
The collection of metrics and the permissions required in order to collect metrics are in the domain of the cluster admin, not the operator author. This PR seems to be proposing a way for operator authors to accomplish a cluster admin task, which I am pretty strongly against.
+1000. IHMO Operators should not change configurations outside of its domain In this case, the propose solution change the Prometheus permissions for the whole cluster and it is outside of the Operator scope.
I think the problem that needs to be solved is discoverability and delegating control: i.e. how does an operator author tell a cluster admin what sorts of permissions to configure and how does an admin apply those permissions? The operator author is the expert on what permissions an operator needs, the cluster admin is the owner of applying those permissions to the cluster. Perhaps we should consider a new set of APIs where the operator can include permission requests in the bundle such that the cluster admin can see them and decide how to act on them. This is actually an area that maintainers in the Operator Framework projects are thinking about now.
Kubebuilder has not the purpose to sort it out. However, OLM seems a project that would like to address this kind of need. @machadovilaca if you wish, I think would be great to raise an issue in the OLM repo describing the problem/scenario so that it might help provide a mechanism to address these needs.
Another option is to raise an issue in the Prometheus Operator and also see if they can provide a helper to sort this problem and make eaiser or less challanble the instructions for Operators authors provide to cluster admins, for example, over how to achieve this goal.
Also, I am moving forward and closing this one as defered. However, feel free to raise new issues and PR if you see that fits.