Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/sourcegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ In addition to the documented values, all services also support the following va
| openTelemetry.agent.containerSecurityContext.runAsGroup | int | `101` | |
| openTelemetry.agent.containerSecurityContext.runAsUser | int | `100` | |
| openTelemetry.agent.hostPorts | object | `{"grpcOtlp":4317,"httpOtlp":4318,"httpZpages":55679}` | Resource requests & limits for the `otel-agent` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| openTelemetry.agent.kind | string | `"DaemonSet"` | The workload kind for the otel-agent. Valid values are `DaemonSet` and `Deployment`. Use `Deployment` in environments where DaemonSets are restricted (e.g. some managed Kubernetes offerings). When set to `Deployment`, the otel-agent DaemonSet is not created and application pods send traces directly to the existing otel-collector Deployment (otel-collector:4317) instead. |
| openTelemetry.agent.name | string | `"otel-agent"` | Name used by resources. Does not affect service names or PVCs. |
| openTelemetry.agent.resources.limits.cpu | string | `"500m"` | |
| openTelemetry.agent.resources.limits.memory | string | `"500Mi"` | |
Expand Down
5 changes: 5 additions & 0 deletions charts/sourcegraph/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ app.kubernetes.io/name: jaeger

{{- define "sourcegraph.openTelemetryEnv" -}}
{{- if .Values.openTelemetry.enabled -}}
{{- if eq (.Values.openTelemetry.agent.kind | default "DaemonSet") "Deployment" -}}
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://otel-collector:4317
{{- else -}}
# OTEL_AGENT_HOST must be defined before OTEL_EXPORTER_OTLP_ENDPOINT to substitute the node IP on which the DaemonSet pod instance runs in the latter variable
- name: OTEL_AGENT_HOST
valueFrom:
Expand All @@ -178,6 +182,7 @@ app.kubernetes.io/name: jaeger
value: http://$(OTEL_AGENT_HOST):{{ toYaml .Values.openTelemetry.agent.hostPorts.grpcOtlp }}
{{- end }}
{{- end }}
{{- end }}

{{- define "sourcegraph.databaseAuth" -}}
{{- $top := index . 0 -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.openTelemetry.enabled -}}
{{- if and .Values.openTelemetry.enabled (eq (.Values.openTelemetry.agent.kind | default "DaemonSet") "DaemonSet") -}}
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down
42 changes: 42 additions & 0 deletions charts/sourcegraph/tests/otelAgentKind_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
suite: otelAgentKind
tests:
- it: should render a DaemonSet by default
template: otel-collector/otel-agent.DaemonSet.yaml
asserts:
- isKind:
of: DaemonSet
- it: should render a DaemonSet when kind is DaemonSet
template: otel-collector/otel-agent.DaemonSet.yaml
set:
openTelemetry:
agent:
kind: "DaemonSet"
asserts:
- isKind:
of: DaemonSet
- it: should not render a DaemonSet when kind is Deployment
template: otel-collector/otel-agent.DaemonSet.yaml
set:
openTelemetry:
agent:
kind: "Deployment"
asserts:
- hasDocuments:
count: 0
- it: should set OTEL_EXPORTER_OTLP_ENDPOINT to otel-collector when kind is Deployment
template: searcher/searcher.StatefulSet.yaml
set:
openTelemetry:
agent:
kind: "Deployment"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://otel-collector:4317"
- notContains:
path: spec.template.spec.containers[0].env
content:
name: OTEL_AGENT_HOST
5 changes: 5 additions & 0 deletions charts/sourcegraph/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,11 @@ openTelemetry:
agent:
# -- Name used by resources. Does not affect service names or PVCs.
name: "otel-agent"
# -- The workload kind for the otel-agent. Valid values are `DaemonSet` and `Deployment`.
# Use `Deployment` in environments where DaemonSets are restricted (e.g. some managed Kubernetes offerings).
# When set to `Deployment`, the otel-agent DaemonSet is not created and application pods send
# traces directly to the existing otel-collector Deployment (otel-collector:4317) instead.
kind: "DaemonSet"
# -- Resource requests & limits for the `otel-agent` container,
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
hostPorts:
Expand Down
Loading