From ecc53a99309b8dcc9ba06735d406a6590d47e991 Mon Sep 17 00:00:00 2001
From: Povilas Versockas
Date: Wed, 8 Nov 2023 12:30:40 +0200
Subject: [PATCH] [otel-integration] remove kube-state-metrics
---
otel-integration/CHANGELOG.md | 3 +
otel-integration/k8s-helm/Chart.yaml | 6 +-
.../k8s-helm/templates/ksm-cr.yaml | 15 ----
.../k8s-helm/templates/ksm-crb.yaml | 14 ----
otel-integration/k8s-helm/values.yaml | 68 +++++++++++++------
5 files changed, 51 insertions(+), 55 deletions(-)
delete mode 100644 otel-integration/k8s-helm/templates/ksm-cr.yaml
delete mode 100644 otel-integration/k8s-helm/templates/ksm-crb.yaml
diff --git a/otel-integration/CHANGELOG.md b/otel-integration/CHANGELOG.md
index e05e1ad9..9d3d9fa8 100644
--- a/otel-integration/CHANGELOG.md
+++ b/otel-integration/CHANGELOG.md
@@ -2,6 +2,9 @@
## OpenTelemtry-Integration
+### v0.0.33 / 2023-11-08
+* [FIX] Remove Kube-State-Metrics, as K8s Cluster Receiver provides all the needed metrics.
+
### v0.0.32 / 2023-11-03
* [FIX] Ensure correct order of processors for k8s deployment attributes.
diff --git a/otel-integration/k8s-helm/Chart.yaml b/otel-integration/k8s-helm/Chart.yaml
index 1713633f..31fa50b6 100644
--- a/otel-integration/k8s-helm/Chart.yaml
+++ b/otel-integration/k8s-helm/Chart.yaml
@@ -1,7 +1,7 @@
apiVersion: v2
name: otel-integration
description: OpenTelemetry Integration
-version: 0.0.32
+version: 0.0.33
keywords:
- OpenTelemetry Collector
- OpenTelemetry Agent
@@ -24,10 +24,6 @@ dependencies:
version: "0.76.3"
repository: https://cgx.jfrog.io/artifactory/coralogix-charts-virtual
condition: opentelemetry-cluster-collector.enabled
- - name: kube-state-metrics
- version: "5.8.1"
- repository: https://prometheus-community.github.io/helm-charts
- condition: global.extensions.kubernetesDashboard.enabled
sources:
- https://github.com/coralogix/opentelemetry-helm-charts/tree/main/charts/opentelemetry-collector
maintainers:
diff --git a/otel-integration/k8s-helm/templates/ksm-cr.yaml b/otel-integration/k8s-helm/templates/ksm-cr.yaml
deleted file mode 100644
index fe35a4a4..00000000
--- a/otel-integration/k8s-helm/templates/ksm-cr.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-{{- if eq ((.Values.distribution)) "openshift" }}
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: system:openshift:scc:{{ index .Values "kube-state-metrics" "fullnameOverride" }}
-rules:
-- apiGroups:
- - security.openshift.io
- resourceNames:
- - nonroot-v2
- resources:
- - securitycontextconstraints
- verbs:
- - use
-{{- end }}
diff --git a/otel-integration/k8s-helm/templates/ksm-crb.yaml b/otel-integration/k8s-helm/templates/ksm-crb.yaml
deleted file mode 100644
index 470b4a1b..00000000
--- a/otel-integration/k8s-helm/templates/ksm-crb.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-{{- if eq ((.Values.distribution)) "openshift" }}
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- name: system:openshift:scc:{{ index .Values "kube-state-metrics" "fullnameOverride" }}
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: system:openshift:scc:{{ index .Values "kube-state-metrics" "fullnameOverride" }}
-subjects:
-- kind: ServiceAccount
- name: {{ index .Values "kube-state-metrics" "fullnameOverride" }}
- namespace: {{ .Release.Namespace }}
-{{- end }}
diff --git a/otel-integration/k8s-helm/values.yaml b/otel-integration/k8s-helm/values.yaml
index c488832f..51cb9240 100644
--- a/otel-integration/k8s-helm/values.yaml
+++ b/otel-integration/k8s-helm/values.yaml
@@ -329,6 +329,15 @@ opentelemetry-cluster-collector:
k8s_cluster:
collection_interval: 10s
allocatable_types_to_report: [cpu, memory]
+ resource_attributes:
+ k8s.kubelet.version:
+ enabled: true
+ k8s.pod.qos_class:
+ enabled: true
+ metrics:
+ k8s.pod.status_reason:
+ enabled: true
+
prometheus:
config:
scrape_configs:
@@ -367,22 +376,51 @@ opentelemetry-cluster-collector:
- keep_keys(body["object"], ["type", "eventTime", "reason", "regarding", "note", "metadata", "deprecatedFirstTimestamp", "deprecatedLastTimestamp"])
- keep_keys(body["object"]["metadata"], ["creationTimestamp"])
- keep_keys(body["object"]["regarding"], ["kind", "name", "namespace"])
- metricstransform/kube-extra-metrics:
+ metricstransform/k8s-dashboard:
transforms:
- # Replace node name for kube node info with the name of the target node.
- - include: kube_node_info
+ - include: k8s.pod.phase
+ match_type: strict
+ action: insert
+ new_name: kube_pod_status_qos_class
+ - include: k8s.pod.status_reason
+ match_type: strict
+ action: insert
+ new_name: kube_pod_status_reason
+ - include: k8s.node.allocatable_cpu
match_type: strict
- action: update
- operations:
- - action: update_label
- label: node
- new_label: k8s.node.name
+ action: insert
+ new_name: kube_node_info
transform/k8s-dashboard:
error_mode: ignore
metric_statements:
- context: metric
statements:
+ # k8s.pod.phase has changed metric units to follow OTEL semantic conventions
+ # K8s Dashboard uses k8s_pod_phase_1 in their queries.
- set(unit, "1") where name == "k8s.pod.phase"
+ - set(unit, "") where name == "kube_node_info"
+ - context: datapoint
+ statements:
+ # Transforming k8s.pod.phase to kube_pod_status_qos_class format.
+ - set(value_int, 1) where metric.name == "kube_pod_status_qos_class"
+ - set(attributes["qos_class"], resource.attributes["k8s.pod.qos_class"]) where metric.name == "kube_pod_status_qos_class"
+ - set(attributes["pod"], resource.attributes["k8s.pod.name"]) where metric.name == "kube_pod_status_reason"
+ # Transforming k8s.pod.status_reason to kube-state-metrics format
+ - set(attributes["reason"], "Evicted") where metric.name == "kube_pod_status_reason" and value_int == 1
+ - set(attributes["reason"], "NodeAffinity") where metric.name == "kube_pod_status_reason" and value_int == 2
+ - set(attributes["reason"], "NodeLost") where metric.name == "kube_pod_status_reason" and value_int == 3
+ - set(attributes["reason"], "Shutdown") where metric.name == "kube_pod_status_reason" and value_int == 4
+ - set(attributes["reason"], "UnexpectedAdmissionError") where metric.name == "kube_pod_status_reason" and value_int == 5
+ - set(value_int, 0) where metric.name == "kube_pod_status_reason" and value_int == 6
+ - set(value_int, 1) where metric.name == "kube_pod_status_reason" and value_int != 0
+ # Transforming k8s.node.status_reason to kube-state-metrics format
+ - set(value_int, 1) where metric.name == "kube_node_info"
+ - set(attributes["kubelet_version"], resource.attributes["k8s.kubelet.version"]) where metric.name == "kube_node_info"
+ - context: resource
+ statements:
+ - delete_key(attributes, "k8s.pod.qos_class")
+ - delete_key(attributes, "k8s.kubelet.version")
+
resourcedetection/env:
detectors: ["system", "env"]
timeout: 2s
@@ -437,7 +475,7 @@ opentelemetry-cluster-collector:
- coralogix
processors:
- k8sattributes
- - metricstransform/kube-extra-metrics
+ - metricstransform/k8s-dashboard
- transform/k8s-dashboard
- resourcedetection/env
- resourcedetection/region
@@ -485,15 +523,3 @@ opentelemetry-cluster-collector:
opentelemetry-agent-windows:
enabled: false
-
-kube-state-metrics:
- fullnameOverride: coralogix-opentelemetry-kube-state-metrics
- prometheusScrape: false
- collectors:
- - pods
- - nodes
- metricAllowlist:
- - kube_node_info
- - kube_pod_status_reason
- - kube_pod_status_phase
- - kube_pod_status_qos_class