Creating the Required RBAC Resources Automatically
The Alauda Build of OpenTelemetry v2 Operator automatically creates the necessary cluster-level RBAC resources when certain Collector components require access to Kubernetes resources across the cluster. For some components, such as the k8s_attributes processor or the k8s_objects receiver, additional RBAC permissions are needed beyond the default Operator scope.
TOC
Automatic RBAC creationPermissions required of the user creating the CollectorProcedureRemoving the RBAC resourcesAutomatic RBAC creation
The Operator can automatically create the required ClusterRole and ClusterRoleBinding resources when the OpenTelemetry Collector configuration includes components that require cluster-wide access.
To enable the automatic RBAC creation capability, you must complete the steps in the Procedure section below to grant the Operator the necessary permissions for managing cluster-level RBAC resources.
The following are examples of components that typically require additional RBAC permissions:
k8s_attributesprocessor: Requires permissions to query Pod, Namespace, Node, ReplicaSet, and Deployment resources for enriching telemetry data with Kubernetes metadata.k8s_objectsreceiver: Requires permissions to watch and list Kubernetes resources such as Events, Pods, and Nodes.kubelet_statsreceiver: Requires permissions to access kubelet endpoints for node and pod metrics.resource_detectionprocessor: Requires permissions to access Node resources for resource detection.
Permissions required of the user creating the Collector
Automatic RBAC creation is subject to a privilege escalation check. When the Operator would generate a ClusterRole for an OpenTelemetryCollector resource, it verifies that the user submitting the resource also holds the permissions being granted. If the user does not hold them, the resource is rejected by the admission webhook.
- When the Collector uses a
ServiceAccountcreated by the Operator, the full set of generated permissions is checked against the submitting user. - When the Collector reuses an existing
ServiceAccountthroughspec.serviceAccount, only the permissions that account is missing are checked.
If creating a Collector fails with a permissions error even though the Operator itself is correctly authorized, grant the submitting user the same permissions the Collector needs, or have a user who already holds them create the resource.
Procedure
-
Create the
ClusterRole: -
Create the
ClusterRoleBinding: -
(Optional) Restart the Alauda Build of OpenTelemetry v2 Operator to pick up the new RBAC permissions:
TIPThis step is only required if the Operator was already running before you created the
ClusterRoleandClusterRoleBinding. If you created them before installing the Operator, you can skip this step.
Removing the RBAC resources
When you no longer need the Operator to create cluster-level RBAC resources automatically, remove the ClusterRole and ClusterRoleBinding created in the Procedure section to release the granted permissions.
Delete the OpenTelemetryCollector resources that rely on automatic RBAC creation before you remove these permissions. Once the Operator loses the permissions, it can no longer reclaim the cluster-level RBAC resources it generated for those Collectors, and those resources are left behind in the cluster.
Procedure
Execute the following commands to remove the RBAC resources: