Skip to content
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

Add automatic RBAC creation for prometheus receiver #3459

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

iblancasa
Copy link
Contributor

@iblancasa iblancasa commented Nov 14, 2024

Link to tracking Issue(s):

Description of the changes:

  • Allowed the operator to create Roles and RoleBindings when using the prometheusreciever based on its configuration
  • Added unit tests and E2E tests
  • Renamed some methods to make it clear when the components methods are returning Roles, RoleBindings, ClusterRoles or ClusterRoleBindings
  • Since the Roles, RoleBindings will be created in a different namespace than the OpenTelemetryCollector instance,they cannot include OwnerReferences. This PR avoids them and ensures the resources are removed when needed
  • Added some tests to controllers/opentelemetrycollector_controller_test.go to check we are not breaking anything

@iblancasa iblancasa self-assigned this Nov 14, 2024
@iblancasa iblancasa requested a review from a team as a code owner November 14, 2024 18:27
Comment on lines +101 to +117
roles, err := Role(params)
if err != nil {
return nil, err
}
// NOTE: we cannot just unpack the slice, the type checker doesn't coerce the type correctly.
for _, role := range roles {
resourceManifests = append(resourceManifests, role)
}

roleBindings, err := RoleBinding(params)
if err != nil {
return nil, err
}
// NOTE: we cannot just unpack the slice, the type checker doesn't coerce the type correctly.
for _, roleBinding := range roleBindings {
resourceManifests = append(resourceManifests, roleBinding)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to fold these into the manifest factory framework, but the idea of changing all the current functions to return slices doesn't seem appealing. Maybe we can instead do the conversion in manifests.Factory? WDYT @jaronoff97 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i think modifying the manifest factory to have a method that allows returning a slice makes sense to me. You could accomplish that in a similar way we do the factory without error today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically create rbac permissions flag for Prometheus receiver
3 participants