Skip to content

Commit

Permalink
add otel agent to help deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Sep 22, 2024
1 parent b6e9fd7 commit f2d21b3
Show file tree
Hide file tree
Showing 17 changed files with 758 additions and 3 deletions.
7 changes: 5 additions & 2 deletions charts/ctrlplane/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ dependencies:
- name: event-worker
repository: file://charts/event-worker
version: 0.1.6
digest: sha256:6ae2f2e02680d3694444d67aba248dfd3a0352678d7c58d2bce30c8bfdf7be1f
generated: "2024-08-28T21:15:56.001463-05:00"
- name: otel
repository: file://charts/otel
version: 0.1.0
digest: sha256:a787c72024ab9ccde1b53b471ea5e8c23583f20649e8ae9bd9c48bcbc3a835f6
generated: "2024-09-21T23:19:52.598333-04:00"
5 changes: 4 additions & 1 deletion charts/ctrlplane/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: ctrlplane
description: Ctrlplane Helm chart for Kubernetes
type: application
version: 0.1.23
version: 0.1.24
appVersion: "1.16.0"

maintainers:
Expand All @@ -26,3 +26,6 @@ dependencies:
- name: event-worker
version: "*.*.*"
repository: "file://charts/event-worker"
- name: otel
version: "*.*.*"
repository: "file://charts/otel"
23 changes: 23 additions & 0 deletions charts/ctrlplane/charts/otel/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions charts/ctrlplane/charts/otel/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: otel
type: application
description: A Helm chart for Kubernetes

version: 0.1.0
appVersion: "0.109.0"
7 changes: 7 additions & 0 deletions charts/ctrlplane/charts/otel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
We had to create a seperate chart, because the offical one does not support

1. We need to send an otlphttp to the console server. The name of this service
is dynamic. TEL helm chart does not support dynamic pipeline values
2. We could do the above as a config map, and pass it into the agent... however,
otel helm does not support using custom config maps names because they need
to be based on the release name.
99 changes: 99 additions & 0 deletions charts/ctrlplane/charts/otel/templates/_config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{{- define "otel.config" -}}
{{- $data := deepCopy .Values.config }}
{{- $config := .Values.config }}
{{- if .Values.presets.receivers.hostMetrics }}
{{- $config = mustMergeOverwrite (include "otel.hostMetricsReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.logsCollection }}
{{- $config = mustMergeOverwrite (include "otel.logsCollectionReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.kubeletMetrics }}
{{- $config = mustMergeOverwrite (include "otel.kubeletMetricsReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.kubernetesEvent }}
{{- $config = mustMergeOverwrite (include "otel.kubernetesEventReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.kubernetesCluster }}
{{- $config = mustMergeOverwrite (include "otel.kubernetesClusterReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.statsd }}
{{- $config = mustMergeOverwrite (include "otel.statsdReceiver" . | fromYaml) $config }}
{{- end }}
{{- if .Values.presets.receivers.otlp }}
{{- $config = mustMergeOverwrite (include "otel.otlpReceiver" . | fromYaml) $config }}
{{- end }}
{{- $config = mustMergeOverwrite (include "otel.extensions" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.processors" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.service" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.exporter" . | fromYaml) $config }}
{{- tpl (toYaml $config) . }}
{{- end }}

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

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

{{- define "otel.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 "otel.service" -}}
service:
extensions:
- health_check
- memory_ballast
pipelines: {}
telemetry:
metrics:
address: ${env:POD_IP}:8888
{{- end }}
102 changes: 102 additions & 0 deletions charts/ctrlplane/charts/otel/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Expand the name of the chart.
*/}}
{{- define "otel.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
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" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "otel.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" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
ctrlplane.com/app-name: {{ include "otel.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

{{/*
Create the name of the service account to use
*/}}
{{- define "otel.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "otel.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Returns the extraEnv keys and values to inject into containers.
Global values will override any chart-specific values.
*/}}
{{- define "otel.extraEnv" -}}
{{- $allExtraEnv := merge (default (dict) .local.extraEnv) .global.extraEnv -}}
{{- range $key, $value := $allExtraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end -}}
{{- end -}}

{{/*
Returns a list of _common_ labels to be shared across all
app deployments and other shared objects.
*/}}
{{- define "otel.commonLabels" -}}
{{- $commonLabels := default (dict) .Values.common.labels -}}
{{- if $commonLabels }}
{{- range $key, $value := $commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end -}}
{{- end -}}

{{/*
Returns a list of _pod_ labels to be shared across all
app deployments.
*/}}
{{- define "otel.podLabels" -}}
{{- range $key, $value := .Values.pod.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end -}}

Loading

0 comments on commit f2d21b3

Please sign in to comment.