Skip to content

Commit

Permalink
Configure otel properly (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks authored Apr 22, 2024
1 parent d75a32f commit 13519fc
Show file tree
Hide file tree
Showing 24 changed files with 251 additions and 204 deletions.
2 changes: 1 addition & 1 deletion charts/operator-wandb/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: operator-wandb
description: A Helm chart for deploying W&B to Kubernetes
type: application
version: 0.12.9
version: 0.12.10
appVersion: 1.0.0
icon: https://wandb.ai/logo.svg

Expand Down
2 changes: 1 addition & 1 deletion charts/operator-wandb/charts/app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ spec:

{{- if ne .Values.traceRatio 0.0 }}
- name: GORILLA_TRACER
value: "otlp+grpc://{{ .Release.Name }}-otel:4317?trace_ratio={{ .Values.traceRatio }}"
value: "otlp+grpc://{{ .Release.Name }}-otel-daemonset:4317?trace_ratio={{ .Values.traceRatio }}"
{{- end }}
- name: KAFKA_BROKER_HOST
value: "{{ include "wandb.kafka.brokerHost" . }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- if .Values.serviceAccount.create -}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
12 changes: 6 additions & 6 deletions charts/operator-wandb/charts/otel/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dependencies:
- name: daemonset
repository: file://charts/otel
version: 0.1.0
- name: deployment
repository: file://charts/otel
version: 0.1.0
- name: daemonset
repository: file://charts/agent
version: 0.1.0
- name: deployment
repository: file://charts/agent
version: 0.1.0
digest: sha256:100ba492259cfd34c405ca0e0c4200838639843d66ee08446e66d80c5cf0175c
generated: "2024-04-16T20:55:40.364161-04:00"
10 changes: 6 additions & 4 deletions charts/operator-wandb/charts/otel/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ maintainers:
url: https://wandb.com

dependencies:
- name: daemonset
- alias: daemonset
name: agent
version: "*.*.*"
repository: file://charts/otel
repository: file://charts/agent
condition: daemonset.install
- name: deployment
- alias: deployment
name: agent
version: "*.*.*"
repository: file://charts/otel
repository: file://charts/agent
condition: deployment.install
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: otel
name: agent
type: application
description: A Helm chart for Kubernetes

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{{- define "otelAgent.config" -}}
{{- $data := deepCopy .Values.config }}
{{- $config := .Values.config }}
{{- if .Values.presets.receivers.hostMetrics }}
{{- $config = mustMergeOverwrite (include "otelAgent.hostMetricsReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.logsCollection }}
{{- $config = mustMergeOverwrite (include "otelAgent.logsCollectionReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.kubeletMetrics }}
{{- $config = mustMergeOverwrite (include "otelAgent.kubeletMetricsReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.kubernetesEvent }}
{{- $config = mustMergeOverwrite (include "otelAgent.kubernetesEventReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.kubernetesCluster }}
{{- $config = mustMergeOverwrite (include "otelAgent.kubernetesClusterReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.statsd }}
{{- $config = mustMergeOverwrite (include "otelAgent.statsdReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.otlp }}
{{- $config = mustMergeOverwrite (include "otelAgent.otlpReceiver" . | fromYaml) $config }}
{{- end }}
{{- $config = mustMergeOverwrite (include "otelAgent.extensions" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otelAgent.processors" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otelAgent.service" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otelAgent.exporter" . | fromYaml) $config }}
{{- tpl (toYaml $config) . }}
{{- end }}

{{- define "otelAgent.exporter" -}}
exporters:
debug: {}
debug/detailed:
verbosity: detailed
prometheus:
endpoint: 0.0.0.0:9109
{{- end }}

{{- define "otelAgent.extensions" -}}
extensions:
health_check: {}
memory_ballast:
size_in_percentage: 40
{{- end }}

{{- define "otelAgent.processors" -}}
processors:
batch: {}
memory_limiter:
check_interval: 5s
limit_percentage: 80
spike_limit_percentage: 25
k8sattributes:
filter:
node_from_env_var: K8S_NODE_NAME
passthrough: false
pod_association:
- sources:
- from: resource_attribute
name: k8s.pod.ip
- sources:
- from: resource_attribute
name: k8s.pod.uid
- sources:
- from: connection
extract:
metadata:
- "k8s.namespace.name"
- "k8s.deployment.name"
- "k8s.statefulset.name"
- "k8s.daemonset.name"
- "k8s.cronjob.name"
- "k8s.job.name"
- "k8s.node.name"
- "k8s.pod.name"
- "k8s.pod.uid"
- "k8s.pod.start_time"
annotations:
- tag_name: $$1
key_regex: (.*)
from: pod
labels:
- tag_name: $$1
key_regex: (.*)
from: pod
{{- end }}

{{- define "otelAgent.service" -}}
service:
extensions:
- health_check
- memory_ballast
pipelines: {}
telemetry:
metrics:
address: ${env:POD_IP}:8888
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "otel.name" -}}
{{- define "otelAgent.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -12,7 +12,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "otel.fullname" -}}
{{- define "otelAgent.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -28,37 +28,37 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "otel.chart" -}}
{{- define "otelAgent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "otel.labels" -}}
helm.sh/chart: {{ include "otel.chart" . }}
{{ include "otel.selectorLabels" . }}
{{- define "otelAgent.labels" -}}
helm.sh/chart: {{ include "otelAgent.chart" . }}
{{ include "otelAgent.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
wandb.com/app-name: {{ include "otel.chart" . }}
wandb.com/app-name: {{ include "otelAgent.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "otel.selectorLabels" -}}
app.kubernetes.io/name: {{ include "otel.name" . }}
{{- define "otelAgent.selectorLabels" -}}
app.kubernetes.io/name: {{ include "otelAgent.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "otel.serviceAccountName" -}}
{{- define "otelAgent.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "otel.fullname" .) .Values.serviceAccount.name }}
{{- default (include "otelAgent.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand All @@ -69,7 +69,7 @@ Returns the extraEnv keys and values to inject into containers.
Global values will override any chart-specific values.
*/}}
{{- define "otel.extraEnv" -}}
{{- define "otelAgent.extraEnv" -}}
{{- $allExtraEnv := merge (default (dict) .local.extraEnv) .global.extraEnv -}}
{{- range $key, $value := $allExtraEnv }}
- name: {{ $key }}
Expand All @@ -81,7 +81,7 @@ Global values will override any chart-specific values.
Returns a list of _common_ labels to be shared across all
app deployments and other shared objects.
*/}}
{{- define "otel.commonLabels" -}}
{{- define "otelAgent.commonLabels" -}}
{{- $commonLabels := default (dict) .Values.common.labels -}}
{{- if $commonLabels }}
{{- range $key, $value := $commonLabels }}
Expand All @@ -94,7 +94,7 @@ app deployments and other shared objects.
Returns a list of _pod_ labels to be shared across all
app deployments.
*/}}
{{- define "otel.podLabels" -}}
{{- define "otelAgent.podLabels" -}}
{{- range $key, $value := .Values.pod.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "otel.hostMetricsReceiver" -}}
{{- define "otelAgent.hostMetricsReceiver" -}}
receivers:
hostmetrics:
root_path: /hostfs
Expand Down Expand Up @@ -48,7 +48,7 @@ receivers:
network:
{{- end }}

{{- define "otel.logsCollectionReceiver" -}}
{{- define "otelAgent.logsCollectionReceiver" -}}
receivers:
filelog:
include: [ /var/log/pods/*/*/*.log ]
Expand Down Expand Up @@ -135,7 +135,7 @@ receivers:
to: body
{{- end }}
{{- define "otel.kubeletMetricsReceiver" -}}
{{- define "otelAgent.kubeletMetricsReceiver" -}}
receivers:
kubeletstats:
collection_interval: 20s
Expand All @@ -144,7 +144,7 @@ receivers:
insecure_skip_verify: true
{{- end }}

{{- define "otel.kubernetesEventReceiver" -}}
{{- define "otelAgent.kubernetesEventReceiver" -}}
receivers:
k8sobjects:
objects:
Expand All @@ -155,19 +155,19 @@ receivers:
- "DELETED"
{{- end }}

{{- define "otel.kubernetesClusterReceiver" -}}
{{- define "otelAgent.kubernetesClusterReceiver" -}}
receivers:
k8s_cluster:
collection_interval: 10s
{{- end }}

{{- define "otel.statsdReceiver" -}}
{{- define "otelAgent.statsdReceiver" -}}
receivers:
statsd:
endpoint: 0.0.0.0:8125
{{- end }}

{{- define "otel.otlpReceiver" -}}
{{- define "otelAgent.otlpReceiver" -}}
receivers:
otlp:
protocols:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "otel.fullname" . }}
name: {{ include "otelAgent.fullname" . }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "wandb.commonLabels" . | nindent 4 }}
{{- include "otel.commonLabels" . | nindent 4 }}
{{- include "otel.labels" . | nindent 4 }}
{{- include "otelAgent.commonLabels" . | nindent 4 }}
{{- include "otelAgent.labels" . | nindent 4 }}
{{- if .Values.clusterRole.labels -}}
{{- toYaml .Values.clusterRole.labels | nindent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "otel.fullname" . }}
name: {{ include "otelAgent.fullname" . }}
labels:
{{- include "wandb.commonLabels" . | nindent 4 }}
{{- include "otel.commonLabels" . | nindent 4 }}
{{- include "otel.labels" . | nindent 4 }}
{{- include "otelAgent.commonLabels" . | nindent 4 }}
{{- include "otelAgent.labels" . | nindent 4 }}
{{- if .Values.clusterRole.labels -}}
{{- toYaml .Values.clusterRole.labels | nindent 4 }}
{{- end }}
Expand All @@ -16,8 +16,8 @@ metadata:
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
name: {{ include "otel.fullname" . }}
name: {{ include "otelAgent.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "otel.serviceAccountName" . }}
name: {{ include "otelAgent.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "otel.fullname" . }}
name: {{ include "otelAgent.fullname" . }}
labels:
{{- include "wandb.commonLabels" . | nindent 4 }}
{{- include "otel.commonLabels" . | nindent 4 }}
{{- include "otel.labels" . | nindent 4 }}
{{- include "otelAgent.commonLabels" . | nindent 4 }}
{{- include "otelAgent.labels" . | nindent 4 }}
{{- if .Values.configMap.labels -}}
{{- toYaml .Values.configMap.labels | nindent 4 }}
{{- end }}
Expand All @@ -15,4 +15,4 @@ metadata:
{{- end }}
data:
config: |
{{- include "otel.config" . | nindent 4 -}}
{{- include "otelAgent.config" . | nindent 4 -}}
Loading

0 comments on commit 13519fc

Please sign in to comment.