kubebuilder icon indicating copy to clipboard operation
kubebuilder copied to clipboard

:sparkles: Add RBAC permissions to allow Prometheus to access metrics

Open machadovilaca opened this issue 3 years ago • 4 comments
trafficstars

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.

machadovilaca avatar Aug 02 '22 12:08 machadovilaca

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.

k8s-ci-robot avatar Aug 02 '22 12:08 k8s-ci-robot

[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.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Aug 02 '22 12:08 k8s-ci-robot

/ok-to-test

camilamacedo86 avatar Aug 02 '22 16:08 camilamacedo86

@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.

k8s-ci-robot avatar Aug 05 '22 23:08 k8s-ci-robot

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:

  1. The operator author
  2. 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.

joelanford avatar Sep 06 '22 13:09 joelanford

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.

camilamacedo86 avatar Sep 06 '22 14:09 camilamacedo86