Skip to content

Commit

Permalink
[collector] add node ip to kubeletstats
Browse files Browse the repository at this point in the history
In some scenarios, it's desirable to use the node IP instead of the node name to gather kubelet metrics.
This commit makes it possible for the user to specify the `presets.kubeletMetrics.useNodeIp` flag
so that the node ip is used as an endpoint instead of the node name.
  • Loading branch information
alextricity25 committed Jul 1, 2024
1 parent 829ce87 commit 8cfed7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions charts/opentelemetry-collector/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ receivers:
kubeletstats:
collection_interval: 20s
auth_type: "serviceAccount"
{{- if .Values.presets.kubeletMetrics.useNodeIp }}
endpoint: "${env:K8S_NODE_IP}:10250"
{{- else }}
endpoint: "${env:K8S_NODE_NAME}:10250"
{{- end }}
{{- end }}

{{- define "opentelemetry-collector.applyLogsCollectionConfig" -}}
Expand Down
4 changes: 4 additions & 0 deletions charts/opentelemetry-collector/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ containers:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: K8S_NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIp
{{- end }}
{{- if and (.Values.useGOMEMLIMIT) ((((.Values.resources).limits).memory)) }}
- name: GOMEMLIMIT
Expand Down
3 changes: 3 additions & 0 deletions charts/opentelemetry-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ presets:
# See https://opentelemetry.io/docs/kubernetes/collector/components/#kubeletstats-receiver for details on the receiver.
kubeletMetrics:
enabled: false
# Instead of using the K8s Node name to gather kubelet metrics, use it's IP.
# This can be useful when running the collector on k8s clusters where the node name isn't resovled in pods
useNodeIp: false
# Configures the collector to collect kubernetes events.
# Adds the k8sobject receiver to the logs pipeline
# and collects kubernetes events by default.
Expand Down

0 comments on commit 8cfed7d

Please sign in to comment.