diff --git a/core/Cargo.toml b/core/Cargo.toml index dc859b96..9102ca79 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -27,10 +27,10 @@ uuid = { version = "0.8", features = ["v4"] } jatsl = "0.1.0" # Tracing -opentelemetry = { version = "0.13.0", features = ["rt-tokio"] } -opentelemetry-otlp = "0.6.0" -opentelemetry-semantic-conventions = "0.5.0" -opentelemetry-http = "0.2.0" +opentelemetry = { version = "0.13", features = ["rt-tokio"] } +opentelemetry-otlp = "0.6" +opentelemetry-semantic-conventions = "0.5" +opentelemetry-http = "0.2" # API juniper = { git = "https://github.com/TilBlechschmidt/juniper", branch = "patch-1", optional = true, features = ["expose-test-schema"] } diff --git a/distribution/kubernetes/chart/templates/_helpers.tpl b/distribution/kubernetes/chart/templates/_helpers.tpl index 6fa03535..64f94027 100644 --- a/distribution/kubernetes/chart/templates/_helpers.tpl +++ b/distribution/kubernetes/chart/templates/_helpers.tpl @@ -88,4 +88,15 @@ Allow customization of the image tag used */}} {{- define "web-grid.imageTag" -}} {{- default .Chart.AppVersion .Values.image.tag }} -{{- end }} \ No newline at end of file +{{- end }} + +{{/* +Create the name of the telemetry endpoint +*/}} +{{- define "web-grid.telemetryEndpoint" -}} +{{- if .Values.telemetry.demo }} +{{- printf "https://%s-telemetry:4317" (include "web-grid.fullname" .) }} +{{- else }} +{{ .Values.telemetry.endpoint }} +{{- end }} +{{- end }} diff --git a/distribution/kubernetes/chart/templates/api.yaml b/distribution/kubernetes/chart/templates/api.yaml index d3c22045..a61f597a 100644 --- a/distribution/kubernetes/chart/templates/api.yaml +++ b/distribution/kubernetes/chart/templates/api.yaml @@ -58,6 +58,10 @@ spec: fieldPath: metadata.name - name: RUST_LOG value: {{ .Values.logLevel }} + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} livenessProbe: tcpSocket: port: status diff --git a/distribution/kubernetes/chart/templates/configMap.yaml b/distribution/kubernetes/chart/templates/configMap.yaml index 82675443..98e3647b 100644 --- a/distribution/kubernetes/chart/templates/configMap.yaml +++ b/distribution/kubernetes/chart/templates/configMap.yaml @@ -3,7 +3,7 @@ kind: ConfigMap metadata: name: {{ include "web-grid.fullname" . }}-redis labels: - web-grid/component: orchestrator + web-grid/component: redis {{- include "web-grid.labels" . | nindent 6 }} data: # ------- TODO Replace maxmemory with calculated value! ------- @@ -95,6 +95,10 @@ data: - name: STORAGE_DIRECTORY value: "/storage" {{- end }} + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} - name: CRF value: "{{ .Values.recording.quality.crf }}" - name: MAX_BITRATE diff --git a/distribution/kubernetes/chart/templates/manager.yaml b/distribution/kubernetes/chart/templates/manager.yaml index e623400d..9ffbaaf3 100644 --- a/distribution/kubernetes/chart/templates/manager.yaml +++ b/distribution/kubernetes/chart/templates/manager.yaml @@ -58,6 +58,10 @@ spec: fieldPath: metadata.name - name: RUST_LOG value: {{ .Values.logLevel }} + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} livenessProbe: tcpSocket: port: status diff --git a/distribution/kubernetes/chart/templates/metrics.yaml b/distribution/kubernetes/chart/templates/metrics.yaml index 17123558..d5f7c2ff 100644 --- a/distribution/kubernetes/chart/templates/metrics.yaml +++ b/distribution/kubernetes/chart/templates/metrics.yaml @@ -53,6 +53,10 @@ spec: value: "{{ include "web-grid.redisURL" . }}" - name: RUST_LOG value: {{ .Values.logLevel }} + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} livenessProbe: tcpSocket: port: status diff --git a/distribution/kubernetes/chart/templates/orchestrator.yaml b/distribution/kubernetes/chart/templates/orchestrator.yaml index dc6710ab..d4b13ed0 100644 --- a/distribution/kubernetes/chart/templates/orchestrator.yaml +++ b/distribution/kubernetes/chart/templates/orchestrator.yaml @@ -71,6 +71,10 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} livenessProbe: tcpSocket: port: status diff --git a/distribution/kubernetes/chart/templates/proxy.yaml b/distribution/kubernetes/chart/templates/proxy.yaml index 6bdd9a41..7527995d 100644 --- a/distribution/kubernetes/chart/templates/proxy.yaml +++ b/distribution/kubernetes/chart/templates/proxy.yaml @@ -50,6 +50,10 @@ spec: value: "{{ include "web-grid.redisURL" . }}" - name: RUST_LOG value: {{ .Values.logLevel }} + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} livenessProbe: tcpSocket: port: status diff --git a/distribution/kubernetes/chart/templates/redis.yaml b/distribution/kubernetes/chart/templates/redis.yaml index f7f7b6c8..20538b03 100644 --- a/distribution/kubernetes/chart/templates/redis.yaml +++ b/distribution/kubernetes/chart/templates/redis.yaml @@ -96,6 +96,10 @@ spec: value: {{ .Values.logLevel }} - name: SESSION_RETENTION_DURATION value: "{{ .Values.config.garbageCollector.retentionDuration }}" + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} livenessProbe: tcpSocket: port: status diff --git a/distribution/kubernetes/chart/templates/storage.yaml b/distribution/kubernetes/chart/templates/storage.yaml index bfcc138b..c582e90c 100644 --- a/distribution/kubernetes/chart/templates/storage.yaml +++ b/distribution/kubernetes/chart/templates/storage.yaml @@ -80,6 +80,10 @@ spec: fieldPath: status.podIP - name: STORAGE_DIRECTORY value: "/storage" + {{- if .Values.telemetry.enabled }} + - name: TRACE_ENDPOINT + value: {{ include "web-grid.telemetryEndpoint" . }} + {{- end}} livenessProbe: tcpSocket: port: status diff --git a/distribution/kubernetes/chart/templates/telemetryDemo.yaml b/distribution/kubernetes/chart/templates/telemetryDemo.yaml new file mode 100644 index 00000000..10474f25 --- /dev/null +++ b/distribution/kubernetes/chart/templates/telemetryDemo.yaml @@ -0,0 +1,124 @@ +{{- if .Values.telemetry.demo }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "web-grid.fullname" . }}-telemetry + labels: + {{- include "web-grid.labels" . | nindent 6 }} +data: + otel.yaml: | + receivers: + otlp: + protocols: + grpc: + + exporters: + logging: + loglevel: debug + + jaeger: + endpoint: localhost:14250 + insecure: true + + processors: + batch: + + extensions: + health_check: + + service: + extensions: [health_check] + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [logging, jaeger] + metrics: + receivers: [otlp] + processors: [batch] + exporters: [logging] +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "web-grid.fullname" . }}-telemetry + labels: + {{- include "web-grid.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "web-grid.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "web-grid.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.nodeSelector.telemetryDemo }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity.telemetryDemo }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations.telemetryDemo }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: otel-config + configMap: + name: {{ include "web-grid.fullname" . }}-telemetry + containers: + - image: otel/opentelemetry-collector-dev:latest + imagePullPolicy: IfNotPresent + name: {{ .Chart.Name }}-otelcol + args: ['--config=/config/otel.yaml'] + ports: + - name: grpc + containerPort: 4317 + protocol: TCP + - name: status + containerPort: 13133 + protocol: TCP + volumeMounts: + - name: otel-config + mountPath: /config + livenessProbe: + tcpSocket: + port: status + resources: + {{- toYaml .Values.resources.telemetryDemo | nindent 12 }} + - image: jaegertracing/all-in-one:latest + name: {{ .Chart.Name }}-jaeger + imagePullPolicy: IfNotPresent + ports: + - name: jaeger-ui + containerPort: 16686 + protocol: TCP + - name: data-ingress + containerPort: 14250 + protocol: TCP + resources: + {{- toYaml .Values.resources.telemetryDemo | nindent 12 }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "web-grid.fullname" . }}-telemetry + labels: + {{- include "web-grid.labels" . | nindent 4 }} +spec: + ports: + - port: 4317 + targetPort: grpc + protocol: TCP + name: grpc + - port: 16686 + targetPort: jaeger-ui + protocol: TCP + name: jaeger-ui + selector: + {{- include "web-grid.selectorLabels" . | nindent 4 }} +{{- end}} diff --git a/distribution/kubernetes/chart/values.yaml b/distribution/kubernetes/chart/values.yaml index f77e0876..08a9caa3 100644 --- a/distribution/kubernetes/chart/values.yaml +++ b/distribution/kubernetes/chart/values.yaml @@ -2,7 +2,11 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -logLevel: debug,hyper=warn,warp=warn,sqlx=warn +logLevel: debug,hyper=warn,warp=warn,sqlx=warn,tower=warn,h2=warn + +service: + type: ClusterIP + port: 80 config: orchestrator: @@ -33,6 +37,15 @@ recording: # Note: The storage class needs to support concurrent access by multiple pods! (e.g. a hostPath based PV) storageClassName: local-path +telemetry: + # Whether request traces should be collected + enabled: false + # OpenTelemetry collector gRPC endpoint where traces are pushed to. + endpoint: "" + # Whether to deploy a OpenTelemetry collector and Jaeger "all-in-one" demo. Overwrites the endpoint. + # NOTE: This is intended for demonstration purposes ONLY and may impact performance when used in production! + demo: false + replicaCount: proxy: 1 manager: 1 @@ -73,6 +86,7 @@ resources: requests: cpu: '1' memory: 3000Mi + telemetryDemo: {} nodeSelector: redis: {} @@ -83,6 +97,7 @@ nodeSelector: session: {} storage: {} api: {} + telemetryDemo: {} tolerations: redis: [] @@ -93,6 +108,7 @@ tolerations: session: [] storage: [] api: [] + telemetryDemo: [] affinity: redis: {} @@ -103,7 +119,4 @@ affinity: session: {} storage: {} api: {} - -service: - type: ClusterIP - port: 80 + telemetryDemo: {}