Skip to content

Commit b6ab8ff

Browse files
authored
Enhance otel collector - support set replica and resources (ClickHouse#80)
Resolve https://github.com/hyperdxio/helm-charts/issues/79
1 parent 10c9b2a commit b6ab8ff

File tree

4 files changed

+206
-6
lines changed

4 files changed

+206
-6
lines changed

.changeset/PR-80.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"helm-charts": patch
3+
---
4+
5+
feat: support set replica and resources for otel-collector

charts/hdx-oss-v2/templates/otel-collector-deployment.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
{{- include "hdx-oss.labels" . | nindent 4 }}
88
app: otel-collector
99
spec:
10-
replicas: 1
10+
replicas: {{ .Values.otel.replicas | default 1 }}
1111
selector:
1212
matchLabels:
1313
{{- include "hdx-oss.selectorLabels" . | nindent 6 }}
@@ -17,6 +17,12 @@ spec:
1717
labels:
1818
{{- include "hdx-oss.selectorLabels" . | nindent 8 }}
1919
app: otel-collector
20+
annotations:
21+
{{- if .Values.otel.annotations }}
22+
{{- with .Values.otel.annotations }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end -}}
25+
{{- end }}
2026
spec:
2127
{{- if .Values.otel.nodeSelector }}
2228
nodeSelector:
@@ -36,6 +42,10 @@ spec:
3642
- containerPort: {{ .Values.otel.grpcPort }}
3743
- containerPort: {{ .Values.otel.httpPort }}
3844
- containerPort: {{ .Values.otel.healthPort }}
45+
{{- if .Values.otel.resources }}
46+
resources:
47+
{{- toYaml .Values.otel.resources | nindent 12 }}
48+
{{- end }}
3949
env:
4050
- name: CLICKHOUSE_ENDPOINT
4151
value: "{{ .Values.otel.clickhouseEndpoint | default (printf "tcp://%s-clickhouse:%v?dial_timeout=10s" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}"

charts/hdx-oss-v2/tests/otel-collector_test.yaml

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tests:
2323
- documentIndex: 1
2424
isKind:
2525
of: Service
26-
26+
2727
- it: should not render otel collector when disabled
2828
set:
2929
otel:
@@ -513,3 +513,176 @@ tests:
513513
path: spec.template.spec.containers[0].env
514514
content:
515515
name: CUSTOM_VAR
516+
517+
- it: should use default replica count 1 when not specified
518+
set:
519+
otel:
520+
enabled: true
521+
image:
522+
repository: hyperdx/hyperdx-otel-collector
523+
tag: 2-beta
524+
asserts:
525+
- documentIndex: 0
526+
isKind:
527+
of: Deployment
528+
- documentIndex: 0
529+
equal:
530+
path: spec.replicas
531+
value: 1
532+
533+
- it: should use custom replica count when specified
534+
set:
535+
otel:
536+
enabled: true
537+
replicas: 5
538+
image:
539+
repository: hyperdx/hyperdx-otel-collector
540+
tag: 2-beta
541+
asserts:
542+
- documentIndex: 0
543+
isKind:
544+
of: Deployment
545+
- documentIndex: 0
546+
equal:
547+
path: spec.replicas
548+
value: 5
549+
550+
- it: should not render resources when not specified
551+
set:
552+
otel:
553+
enabled: true
554+
image:
555+
repository: hyperdx/hyperdx-otel-collector
556+
tag: 2-beta
557+
asserts:
558+
- documentIndex: 0
559+
isKind:
560+
of: Deployment
561+
- documentIndex: 0
562+
isNull:
563+
path: spec.template.spec.containers[0].resources
564+
565+
- it: should render resources when specified
566+
set:
567+
otel:
568+
enabled: true
569+
image:
570+
repository: hyperdx/hyperdx-otel-collector
571+
tag: 2-beta
572+
resources:
573+
limits:
574+
memory: "512Mi"
575+
cpu: "500m"
576+
requests:
577+
memory: "256Mi"
578+
cpu: "250m"
579+
asserts:
580+
- documentIndex: 0
581+
isKind:
582+
of: Deployment
583+
- documentIndex: 0
584+
equal:
585+
path: spec.template.spec.containers[0].resources
586+
value:
587+
limits:
588+
memory: "512Mi"
589+
cpu: "500m"
590+
requests:
591+
memory: "256Mi"
592+
cpu: "250m"
593+
594+
- it: should render only limits when requests not specified
595+
set:
596+
otel:
597+
enabled: true
598+
image:
599+
repository: hyperdx/hyperdx-otel-collector
600+
tag: 2-beta
601+
resources:
602+
limits:
603+
memory: "1Gi"
604+
cpu: "1000m"
605+
asserts:
606+
- documentIndex: 0
607+
isKind:
608+
of: Deployment
609+
- documentIndex: 0
610+
equal:
611+
path: spec.template.spec.containers[0].resources
612+
value:
613+
limits:
614+
memory: "1Gi"
615+
cpu: "1000m"
616+
617+
- it: should render only requests when limits not specified
618+
set:
619+
otel:
620+
enabled: true
621+
image:
622+
repository: hyperdx/hyperdx-otel-collector
623+
tag: 2-beta
624+
resources:
625+
requests:
626+
memory: "128Mi"
627+
cpu: "100m"
628+
asserts:
629+
- documentIndex: 0
630+
isKind:
631+
of: Deployment
632+
- documentIndex: 0
633+
equal:
634+
path: spec.template.spec.containers[0].resources
635+
value:
636+
requests:
637+
memory: "128Mi"
638+
cpu: "100m"
639+
640+
- it: should render annotations when specified
641+
set:
642+
otel:
643+
enabled: true
644+
image:
645+
repository: hyperdx/hyperdx-otel-collector
646+
tag: 2-beta
647+
annotations:
648+
prometheus.io/scrape: "true"
649+
prometheus.io/port: "8888"
650+
prometheus.io/path: "/metrics"
651+
asserts:
652+
- documentIndex: 0
653+
isKind:
654+
of: Deployment
655+
- documentIndex: 0
656+
equal:
657+
path: spec.template.metadata.annotations
658+
value:
659+
prometheus.io/scrape: "true"
660+
prometheus.io/port: "8888"
661+
prometheus.io/path: "/metrics"
662+
663+
- it: should render multiple annotations correctly
664+
set:
665+
otel:
666+
enabled: true
667+
image:
668+
repository: hyperdx/hyperdx-otel-collector
669+
tag: 2-beta
670+
annotations:
671+
prometheus.io/scrape: "true"
672+
prometheus.io/port: "8888"
673+
checksum/config: "abcdef1234567890"
674+
deployment.kubernetes.io/revision: "1"
675+
sidecar.istio.io/inject: "false"
676+
asserts:
677+
- documentIndex: 0
678+
isKind:
679+
of: Deployment
680+
- documentIndex: 0
681+
isSubset:
682+
path: spec.template.metadata.annotations
683+
content:
684+
prometheus.io/scrape: "true"
685+
prometheus.io/port: "8888"
686+
checksum/config: "abcdef1234567890"
687+
deployment.kubernetes.io/revision: "1"
688+
sidecar.istio.io/inject: "false"

charts/hdx-oss-v2/values.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ hyperdx:
2929
# Endpoint to send hyperdx logs/traces/metrics to.Defaults to the chart's otel collector endpoint.
3030
otelExporterEndpoint: http://{{ include "hdx-oss.fullname" . }}-otel-collector:{{ .Values.otel.httpPort }}
3131
mongoUri: mongodb://{{ include "hdx-oss.fullname" . }}-mongodb:{{ .Values.mongodb.port }}/hyperdx
32-
32+
3333
# Pod-level annotations (applied to the deployment pods)
3434
annotations: {}
3535
# myAnnotation: "myValue"
36-
37-
# Pod-level labels (applied to the deployment pods)
36+
37+
# Pod-level labels (applied to the deployment pods)
3838
labels: {}
3939
# myLabel: "myValue"
4040
env: []
@@ -238,7 +238,7 @@ clickhouse:
238238
# operator: "Equal"
239239
# value: "value1"
240240
# effect: "NoSchedule"
241-
241+
242242
# Service configuration
243243
service:
244244
type: ClusterIP # Use ClusterIP for security. For external access, use ingress with proper TLS and authentication
@@ -275,6 +275,18 @@ otel:
275275
repository: docker.hyperdx.io/hyperdx/hyperdx-otel-collector
276276
tag:
277277
pullPolicy: IfNotPresent
278+
replicas: 1
279+
resources: {}
280+
# Example:
281+
# requests:
282+
# memory: "127Mi"
283+
# cpu: "100m"
284+
# limits:
285+
# memory: "256Mi"
286+
# cpu: "200m"
287+
# Pod-level annotations (applied to the deployment pods)
288+
annotations: {}
289+
# myAnnotation: "myValue"
278290
# Add nodeSelector and tolerations for otel-collector service
279291
nodeSelector: {}
280292
# Example:

0 commit comments

Comments
 (0)