Skip to content

Commit 83785c8

Browse files
authored
Add openshift resource detector for distribution: openshift (#2330)
* Add openshift resource detector for distribution: openshift Enable the openshift resource detection processor when distribution is set to openshift. This provides cloud.provider, cloud.platform, cloud.region, and k8s.cluster.name attributes via the OpenShift API (no IMDS dependency). - Add openshift detector and resource_attributes config in _common.tpl - Add config.openshift.io RBAC permissions to clusterRole - Fix bug where non-EKS clusters on AWS would not have cloud attributes set * fixes * chlog update * fix aks * fix gcp and add unit tests * update test, fix schema * fix value for resource detector * rm already default attr * rm not needed extra config * add more tests for resdet * clean up changelog
1 parent d1a44b2 commit 83785c8

28 files changed

+548
-38
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, operator, chart, other)
4+
component: agent, clusterReceiver, gateway
5+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
6+
note: Fix resource detection for non-EKS Kubernetes clusters on AWS
7+
# One or more tracking issues related to the change
8+
issues: [2330]
9+
# (Optional) One or more lines of additional information to render under the primary note.
10+
# These lines will be padded with 2 spaces and then inserted directly into the document.
11+
# Use pipe (|) for multiline entries.
12+
subtext: |
13+
For non-EKS Kubernetes clusters on AWS (cloudProvider=aws with distribution unset or
14+
set to openshift), EC2 instance metadata (host.id, cloud.account.id,
15+
cloud.availability_zone, etc.) was never collected. Two issues contributed to this:
16+
1. The chart used the eks detector, which only works on actual EKS clusters — it checks
17+
for EKS-specific signals (IRSA/Pod Identity token paths, OIDC issuer, Kubernetes
18+
version string) and returns an empty resource when those are absent. Switched to the
19+
ec2 detector, which works on any AWS instance with IMDS access.
20+
2. This code path only matched when distribution was unset (empty string), so OpenShift
21+
clusters on AWS (distribution=openshift, cloudProvider=aws) were excluded entirely.
22+
Broadened the condition to also match the openshift distribution.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, operator, chart, other)
4+
component: agent, clusterReceiver, gateway
5+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
6+
note: Add OpenShift resource detection support
7+
# One or more tracking issues related to the change
8+
issues: [2330]
9+
# (Optional) One or more lines of additional information to render under the primary note.
10+
# These lines will be padded with 2 spaces and then inserted directly into the document.
11+
# Use pipe (|) for multiline entries.
12+
subtext: |
13+
When distribution is set to "openshift", the openshift resource detector is now enabled
14+
in the resourcedetection processor. Previously, OpenShift clusters only had cloud-provider
15+
detectors (azure for cloudProvider=azure, gcp for cloudProvider=gcp) but no
16+
OpenShift-specific detector, and no detector at all for cloudProvider=aws (see the
17+
ec2 bug fix in this release). The openshift detector auto-discovers `k8s.cluster.name`,
18+
`cloud.provider`, `cloud.platform`, and `cloud.region` via the OpenShift API
19+
(`config.openshift.io/v1/infrastructures`). The `cloud.platform` value reflects the
20+
actual hosting environment (e.g., `aws_openshift`, `gcp_openshift`, `azure.openshift`).
21+
22+
Cloud-provider-specific detectors remain enabled alongside the openshift detector to
23+
collect instance-level metadata: ec2 on AWS, gcp on GCP, and azure on Azure. The
24+
openshift detector is listed first to ensure the correct `cloud.platform` is set before
25+
cloud-provider detectors run.
26+
27+
The `clusterName` Helm value is now optional for OpenShift (same as EKS and GKE). When
28+
not set, the openshift detector auto-discovers it from the cluster API. When explicitly
29+
set, the static value takes precedence.

examples/distribution-openshift/rendered_manifests/clusterRole.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ rules:
2222
- get
2323
- list
2424
- watch
25+
- apiGroups:
26+
- config.openshift.io
27+
resources:
28+
- infrastructures
29+
- infrastructures/status
30+
verbs:
31+
- get
32+
- list
33+
- watch
2534
- apiGroups:
2635
- ""
2736
resources:

examples/distribution-openshift/rendered_manifests/configmap-agent.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ data:
142142
resourcedetection:
143143
detectors:
144144
- env
145+
- openshift
145146
- system
146147
override: true
147148
timeout: 15s

examples/distribution-openshift/rendered_manifests/configmap-cluster-receiver.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ data:
6767
resourcedetection:
6868
detectors:
6969
- env
70+
- openshift
7071
- system
7172
override: true
7273
timeout: 15s

examples/distribution-openshift/rendered_manifests/daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ spec:
3131
component: otel-collector-agent
3232
release: default
3333
annotations:
34-
checksum/config: 86b9e237230bff778e5a9261f569f61444c70c0b8bbca028a6309255f08670a2
34+
checksum/config: dc83bd8c776d052e99a56059e662b006ea49495536000ae73aed876f0f80157d
3535
kubectl.kubernetes.io/default-container: otel-collector
3636
spec:
3737
hostNetwork: true

examples/distribution-openshift/rendered_manifests/deployment-cluster-receiver.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
component: otel-k8s-cluster-receiver
3131
release: default
3232
annotations:
33-
checksum/config: 5763ea975670663f85a27d6986d38a869f1863c466dc6e8f4c2f2123074fff45
33+
checksum/config: 51aef421dc69c2e928b632dc6fad058e1003ee654fbdf24425661e5ad2ac5af2
3434
spec:
3535
serviceAccountName: default-splunk-otel-collector
3636
nodeSelector:

functional_tests/functional/functional_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ func validateResourceAttributes(t *testing.T, clientset *kubernetes.Clientset, k
676676

677677
internal.CopyFileFromPod(t, clientset, kubeConfig, internal.DefaultNamespace, podName, "otel-collector", podPathFile, tmpFile.Name())
678678

679-
actualResourceAttributes := readAndNormalizeMetrics(t, tmpFile.Name(), "k8s.cluster.name").ResourceMetrics().At(0).Resource().Attributes()
680-
expectedResourceAttributes := readAndNormalizeMetrics(t, expectedResourceAttributesFile, "k8s.cluster.name").ResourceMetrics().At(0).Resource().Attributes()
679+
actualResourceAttributes := readAndNormalizeMetrics(t, tmpFile.Name(), "k8s.cluster.name", "cloud.platform").ResourceMetrics().At(0).Resource().Attributes()
680+
expectedResourceAttributes := readAndNormalizeMetrics(t, expectedResourceAttributesFile, "k8s.cluster.name", "cloud.platform").ResourceMetrics().At(0).Resource().Attributes()
681681

682682
require.True(t, expectedResourceAttributes.Equal(actualResourceAttributes), "Resource Attributes comparison failed for %s , expected values %s , actual values %s", collectorType, internal.FormatAttributes(expectedResourceAttributes), internal.FormatAttributes(actualResourceAttributes))
683683

functional_tests/functional/testdata/expected_aks_values/expected_resource_attributes_agent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resourceMetrics:
66
stringValue: abcd
77
- key: cloud.platform
88
value:
9-
stringValue: abcd
9+
stringValue: azure.aks
1010
- key: cloud.provider
1111
value:
1212
stringValue: abcd

functional_tests/functional/testdata/expected_aks_values/expected_resource_attributes_cluster_receiver.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resourceMetrics:
66
stringValue: abcd
77
- key: cloud.platform
88
value:
9-
stringValue: abcd
9+
stringValue: azure.aks
1010
- key: cloud.provider
1111
value:
1212
stringValue: abcd

0 commit comments

Comments
 (0)