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
[processor/k8sattributes] support extracting labels and annotations from Deployments (#38343)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Add support for extraction of labels and annotations from Deployments.
This change comes with elevated RBAC permissions - adding Deployment
permissions to the ClusterRole
<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes#37957
---------
Signed-off-by: odubajDT <[email protected]>
## Extracting attributes from pod labels and annotations
229
229
230
-
The k8sattributesprocessor can also set resource attributes from k8s labels and annotations of pods, namespaces and nodes.
231
-
The config for associating the data passing through the processor (spans, metrics and logs) with specific Pod/Namespace/Node annotations/labels is configured via "annotations" and "labels" keys.
232
-
This config represents a list of annotations/labels that are extracted from pods/namespaces/nodes and added to spans, metrics and logs.
230
+
The k8sattributesprocessor can also set resource attributes from k8s labels and annotations of pods, namespaces, deployments and nodes.
231
+
The config for associating the data passing through the processor (spans, metrics and logs) with specific Pod/Namespace/Deployment/Node annotations/labels is configured via "annotations" and "labels" keys.
232
+
This config represents a list of annotations/labels that are extracted from pods/namespaces/deployments/nodes and added to spans, metrics and logs.
233
233
Each item is specified as a config of tag_name (representing the tag name to tag the spans with),
234
234
key (representing the key used to extract value) and from (representing the kubernetes object used to extract the value).
235
-
The "from" field has only three possible values "pod", "namespace" and "node" and defaults to "pod" if none is specified.
235
+
The "from" field has only three possible values "pod", "namespace", "deployment" and "node" and defaults to "pod" if none is specified.
236
236
237
237
A few examples to use this config are as follows:
238
238
@@ -344,7 +344,7 @@ rules:
344
344
resources: ["pods", "namespaces", "nodes"]
345
345
verbs: ["get", "watch", "list"]
346
346
- apiGroups: ["apps"]
347
-
resources: ["replicasets"]
347
+
resources: ["replicasets", "deployments"]
348
348
verbs: ["get", "list", "watch"]
349
349
- apiGroups: ["extensions"]
350
350
resources: ["replicasets"]
@@ -373,6 +373,8 @@ k8sattributes:
373
373
```
374
374
With the namespace filter set, the processor will only look up pods and replicasets in the selected namespace. Note that with just a role binding, the processor cannot query metadata such as labels and annotations from k8s `nodes` and `namespaces` which are cluster-scoped objects. This also means that the processor cannot set the value for `k8s.cluster.uid` attribute if enabled, since the `k8s.cluster.uid` attribute is set to the uid of the namespace `kube-system` which is not queryable with namespaced rbac.
375
375
376
+
Please note, when extracting the workload related attributes, these workloads need to be present in the `Role` with the correct permissions. For example, an extraction of `k8s.deployment.label.*` attributes, `deployments` need to be present in `Role`.
377
+
376
378
Example `Role` and `RoleBinding` to create in the namespace being watched.
0 commit comments