You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TargetAllocator service is named based on the OpenTelemetryCollector CR name. `collector_id` should be unique per
121
+
The TargetAllocator service is named based on the `OpenTelemetryCollector` CR name. For example, if your Collector CR name is `my-collector`, then the TargetAllocator `service` and `deployment` will each be named `my-collector-targetallocator`, and the `pod` will be named `my-collector-targetallocator-<pod_id>`. `collector_id` should be unique per
122
122
collector instance, such as the pod name. The `POD_NAME` environment variable is convenient since this is supplied
123
123
to collector instance pods by default.
124
124
125
125
126
126
### RBAC
127
-
The ServiceAccount that the TargetAllocator runs as, has to have access to the CRs and the namespaces to watch for the pod and service monitors. A role like this will provide that
128
-
access.
127
+
128
+
Before the TargetAllocator can start scraping, you need to set up a Kubernetes RBAC (role-based access controls). This means that you need to have a `ServiceAccount` and corresponding cluster roles so that the TargetAllocator has access to all of the necessary resources to pull metrics from.
129
+
130
+
You can create your own `ServiceAccount`, and reference it in `spec.targetAllocator.serviceAccount` in your `OpenTelemetryCollector` CR. You’ll then need to configure the `ClusterRole` and `ClusterRoleBinding` for this `ServiceAccount`, as per below.
131
+
132
+
```yaml
133
+
targetAllocator:
134
+
enabled: true
135
+
serviceAccount: opentelemetry-targetallocator-sa
136
+
prometheusCR:
137
+
enabled: true
138
+
```
139
+
140
+
> 🚨 **Note**: The Collector part of this same CR *also* has a serviceAccount key which only affects the collector and *not*
141
+
the TargetAllocator.
142
+
143
+
If you omit the `ServiceAccount` name, the TargetAllocator creates a `ServiceAccount` for you. The `ServiceAccount`’s default name is a concatenation of the Collector name and the `-collector` suffix. By default, this `ServiceAccount` has no defined policy, so you’ll need to create your own `ClusterRole` and `ClusterRoleBinding` for it, as per below.
144
+
145
+
The role below will provide the minimum access required for the Target Allocator to query all the targets it needs based on any Prometheus configurations:
146
+
129
147
```yaml
130
148
apiVersion: rbac.authorization.k8s.io/v1
131
149
kind: ClusterRole
@@ -144,8 +162,9 @@ rules:
144
162
- namespaces
145
163
verbs: ["get", "list", "watch"]
146
164
```
147
-
In addition, the TargetAllocator needs the same permissions as a Prometheus instance would to find the matching targets
148
-
from the CR instances.
165
+
166
+
If you enable the the `prometheusCR` (set `spec.targetAllocator.prometheusCR.enabled` to `true`) in the `OpenTelemetryCollector` CR, you will also need to define the following roles. These give the TargetAllocator access to the `PodMonitor` and `ServiceMonitor` CRs. It also gives namespace access to the `PodMonitor` and `ServiceMonitor`.
167
+
149
168
```yaml
150
169
apiVersion: rbac.authorization.k8s.io/v1
151
170
kind: ClusterRole
@@ -177,19 +196,9 @@ rules:
177
196
- nonResourceURLs: ["/metrics"]
178
197
verbs: ["get"]
179
198
```
180
-
These roles can be combined.
181
199
182
-
A ServiceAccount bound with the above permissions in the namespaces that are to be monitored can then be referenced in
183
-
the `targetAllocator:` part of the OpenTelemetryCollector CR.
184
-
```yaml
185
-
targetAllocator:
186
-
enabled: true
187
-
serviceAccount: opentelemetry-targetallocator-sa
188
-
prometheusCR:
189
-
enabled: true
190
-
```
191
-
**Note**: The Collector part of this same CR *also* has a serviceAccount key which only affects the collector and *not*
192
-
the TargetAllocator.
200
+
> ✨ The above roles can be combined into a single role.
0 commit comments