Skip to content

Commit

Permalink
mutiple otel agents
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Apr 18, 2024
1 parent 6105c97 commit d75a32f
Show file tree
Hide file tree
Showing 19 changed files with 259 additions and 75 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.8
version: 0.12.9
appVersion: 1.0.0
icon: https://wandb.ai/logo.svg

Expand Down
9 changes: 9 additions & 0 deletions charts/operator-wandb/charts/otel/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: daemonset
repository: file://charts/otel
version: 0.1.0
- name: deployment
repository: file://charts/otel
version: 0.1.0
digest: sha256:100ba492259cfd34c405ca0e0c4200838639843d66ee08446e66d80c5cf0175c
generated: "2024-04-16T20:55:40.364161-04:00"
10 changes: 10 additions & 0 deletions charts/operator-wandb/charts/otel/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ maintainers:
- name: wandb
email: [email protected]
url: https://wandb.com

dependencies:
- name: daemonset
version: "*.*.*"
repository: file://charts/otel
condition: daemonset.install
- name: deployment
version: "*.*.*"
repository: file://charts/otel
condition: deployment.install
15 changes: 15 additions & 0 deletions charts/operator-wandb/charts/otel/charts/otel/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v2
name: otel
type: application
description: A Helm chart for Kubernetes

version: 0.1.0
appVersion: "0.33.0"

home: https://wandb.ai
icon: https://wandb.ai/logo.svg

maintainers:
- name: wandb
email: [email protected]
url: https://wandb.com
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
{{- define "otel.config" -}}
{{- $data := deepCopy .Values.config }}
{{- $config := .Values.config }}
{{- if .Values.presets.receiver.hostMetrics }}
{{- $config = mustMergeOverwrite (include "otel.hostMetricsReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receiver.logsCollection }}
{{- $config = mustMergeOverwrite (include "otel.logsCollectionReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receiver.kubeletMetrics }}
{{- $config = mustMergeOverwrite (include "otel.kubeletMetricsReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receiver.kubernetesEvent }}
{{- $config = mustMergeOverwrite (include "otel.kubernetesEventReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receiver.kubernetesCluster }}
{{- $config = mustMergeOverwrite (include "otel.kubernetesClusterReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receiver.statsd }}
{{- $config = mustMergeOverwrite (include "otel.statsdReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receiver.otlp }}
{{- $config = mustMergeOverwrite (include "otel.otlpReceiver" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.statsdAppReceiver" . | fromYaml) $config }}
{{- end }}
{{- $config = mustMergeOverwrite (include "otel.extensions" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.processors" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.service" . | fromYaml) $config }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,7 @@ receivers:
collection_interval: 10s
{{- end }}

{{- define "otel.sqlQueryReceiver" -}}
receivers:
sqlquery:
driver: mysql
datasource: ${env:MYSQL_USER}:${env:MYSQL_PASSWORD}@tcp(${env:MYSQL_HOST}:${env:MYSQL_PORT})/${env:MYSQL_DATABASE}?tls=true
queries:
- sql: "select count(*) as count from users where account_type != 'service'"
metrics:
- metric_name: users.count
value_column: "count"
{{- end }}

{{- define "otel.statsdAppReceiver" -}}
{{- define "otel.statsdReceiver" -}}
receivers:
statsd:
endpoint: 0.0.0.0:8125
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.mode "daemon" -}}
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down Expand Up @@ -130,4 +131,5 @@ spec:
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
hostNetwork: false
hostNetwork: false
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{{- if eq .Values.mode "deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "otel.fullname" . }}-agent
labels:
{{- include "wandb.commonLabels" . | nindent 4 }}
{{- include "otel.commonLabels" . | nindent 4 }}
{{- include "otel.labels" . | nindent 4 }}
{{- if .Values.deployment.labels -}}
{{- toYaml .Values.deployment.labels | nindent 4 }}
{{- end }}
annotations:
{{- include "wandb.deploymentAnnotations" $ | nindent 4 }}
{{- if .Values.deployment.annotations -}}
{{- toYaml .Values.deployment.annotations | nindent 4 }}
{{- end }}
spec:
updateStrategy:
type: RollingUpdate
replica: 1
selector:
matchLabels:
{{- include "wandb.selectorLabels" $ | nindent 6 }}
{{- include "otel.labels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "wandb.podLabels" . | nindent 8 }}
{{- include "otel.commonLabels" . | nindent 8 }}
{{- include "otel.podLabels" . | nindent 8 }}
{{- include "otel.labels" . | nindent 8 }}
annotations:
checksum/configmap: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
{{- if .Values.pod.annotations -}}
{{- toYaml .Values.pod.annotations | nindent 4 }}
{{- end }}
spec:
serviceAccountName: {{ include "otel.serviceAccountName" . }}
{{- if .tolerations }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
{{- end }}
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command:
- /otelcol-contrib
- --config=/conf/config.yaml
ports:
- name: otlp
containerPort: 4317
protocol: TCP
hostPort: 4317
- name: otlp-http
containerPort: 4318
protocol: TCP
hostPort: 4318
- name: prometheus
containerPort: 9109
protocol: TCP
hostPort: 9109
- name: statsd
containerPort: 8125
protocol: TCP
hostPort: 8125
env:
- name: MYSQL_PORT
value: "{{ include "wandb.mysql.port" . }}"
- name: MYSQL_HOST
value: "{{ include "wandb.mysql.host" . }}"
- name: MYSQL_DATABASE
value: "{{ include "wandb.mysql.database" . }}"
- name: MYSQL_USER
value: "{{ include "wandb.mysql.user" . }}"
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "wandb.mysql.passwordSecret" . }}
key: MYSQL_PASSWORD

- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
{{- include "otel.extraEnv" (dict "global" $.Values.global "local" .Values) | nindent 12 }}
{{- include "wandb.extraEnvFrom" (dict "root" $ "local" .) | nindent 12 }}
livenessProbe:
httpGet:
path: /
port: 13133
readinessProbe:
httpGet:
path: /
port: 13133
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /conf
name: config
volumes:
- name: config
configMap:
name: {{ include "otel.fullname" . }}
items:
- key: config
path: config.yaml
hostNetwork: false
{{- end }}
68 changes: 68 additions & 0 deletions charts/operator-wandb/charts/otel/charts/otel/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
mode: "daemonset"

nameOverride: ""
fullnameOverride: ""

config: {}
presets:
receivers:
hostMetrics: false
logsCollection: false
kubeletMetrics: false
kubernetesEvent: false
kubernetesCluster: false
statsd: true
otlp: true

image:
repository: otel/opentelemetry-collector-contrib
tag: 0.97.0
pullPolicy: IfNotPresent
# pullSecrets: []

# Tolerations for pod scheduling
tolerations: []

extraEnv: {}
extraEnvFrom: {}

extraCors: []

service: {}

pod:
securityContext:
fsGroup: 0
fsGroupChangePolicy: "OnRootMismatch"
labels: {}
annotations: {}

clusterRole:
annotations: {}
labels: {}

common:
labels: {}
annotations: {}

daemonSet:
labels: {}
annotations: {}

configMap:
annotations: {}
labels: {}

resources:
requests:
cpu: 200m
memory: 200Mi
limits:
cpu: 500m
memory: 500Mi

serviceAccount:
create: true

role: {}
roleBinding: {}
79 changes: 20 additions & 59 deletions charts/operator-wandb/charts/otel/values.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,20 @@
enabled: true

nameOverride: ""
fullnameOverride: ""

config: {}

image:
repository: otel/opentelemetry-collector-contrib
tag: 0.97.0
pullPolicy: IfNotPresent
# pullSecrets: []

# Tolerations for pod scheduling
tolerations: []

extraEnv: {}
extraEnvFrom: {}

extraCors: []

service: {}

pod:
securityContext:
fsGroup: 0
fsGroupChangePolicy: "OnRootMismatch"
labels: {}
annotations: {}

clusterRole:
annotations: {}
labels: {}

common:
labels: {}
annotations: {}

daemonSet:
labels: {}
annotations: {}

configMap:
annotations: {}
labels: {}

resources:
requests:
cpu: 200m
memory: 200Mi
limits:
cpu: 500m
memory: 500Mi

serviceAccount:
create: true

role: {}
roleBinding: {}
daemonset:
install: true
mode: "daemonset"
presets:
hostMetrics: true
logsCollection: true
kubeletMetrics: true
kubernetesEvent: true
kubernetesCluster: true
statsd: true
otlp: true
config: {}

deployment:
install: true
mode: "deployment"
presets:
statsd: true
otlp: true
config: {}

0 comments on commit d75a32f

Please sign in to comment.