diff --git a/.changeset/PR-80.md b/.changeset/PR-80.md new file mode 100644 index 0000000..bb1035c --- /dev/null +++ b/.changeset/PR-80.md @@ -0,0 +1,5 @@ +--- +"helm-charts": patch +--- + +feat: support set replica and resources for otel-collector diff --git a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml index f527512..1fd743a 100644 --- a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml +++ b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml @@ -7,7 +7,7 @@ metadata: {{- include "hdx-oss.labels" . | nindent 4 }} app: otel-collector spec: - replicas: 1 + replicas: {{ .Values.otel.replicas | default 1 }} selector: matchLabels: {{- include "hdx-oss.selectorLabels" . | nindent 6 }} @@ -17,6 +17,12 @@ spec: labels: {{- include "hdx-oss.selectorLabels" . | nindent 8 }} app: otel-collector + annotations: + {{- if .Values.otel.annotations }} + {{- with .Values.otel.annotations }} + {{- toYaml . | nindent 8 }} + {{- end -}} + {{- end }} spec: {{- if .Values.otel.nodeSelector }} nodeSelector: @@ -36,6 +42,10 @@ spec: - containerPort: {{ .Values.otel.grpcPort }} - containerPort: {{ .Values.otel.httpPort }} - containerPort: {{ .Values.otel.healthPort }} + {{- if .Values.otel.resources }} + resources: + {{- toYaml .Values.otel.resources | nindent 12 }} + {{- end }} env: - name: CLICKHOUSE_ENDPOINT value: "{{ .Values.otel.clickhouseEndpoint | default (printf "tcp://%s-clickhouse:%v?dial_timeout=10s" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}" diff --git a/charts/hdx-oss-v2/tests/otel-collector_test.yaml b/charts/hdx-oss-v2/tests/otel-collector_test.yaml index 3ed2d31..a85febf 100644 --- a/charts/hdx-oss-v2/tests/otel-collector_test.yaml +++ b/charts/hdx-oss-v2/tests/otel-collector_test.yaml @@ -23,7 +23,7 @@ tests: - documentIndex: 1 isKind: of: Service - + - it: should not render otel collector when disabled set: otel: @@ -513,3 +513,176 @@ tests: path: spec.template.spec.containers[0].env content: name: CUSTOM_VAR + + - it: should use default replica count 1 when not specified + set: + otel: + enabled: true + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.replicas + value: 1 + + - it: should use custom replica count when specified + set: + otel: + enabled: true + replicas: 5 + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.replicas + value: 5 + + - it: should not render resources when not specified + set: + otel: + enabled: true + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].resources + + - it: should render resources when specified + set: + otel: + enabled: true + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "250m" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].resources + value: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "250m" + + - it: should render only limits when requests not specified + set: + otel: + enabled: true + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + resources: + limits: + memory: "1Gi" + cpu: "1000m" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].resources + value: + limits: + memory: "1Gi" + cpu: "1000m" + + - it: should render only requests when limits not specified + set: + otel: + enabled: true + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + resources: + requests: + memory: "128Mi" + cpu: "100m" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].resources + value: + requests: + memory: "128Mi" + cpu: "100m" + + - it: should render annotations when specified + set: + otel: + enabled: true + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8888" + prometheus.io/path: "/metrics" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.metadata.annotations + value: + prometheus.io/scrape: "true" + prometheus.io/port: "8888" + prometheus.io/path: "/metrics" + + - it: should render multiple annotations correctly + set: + otel: + enabled: true + image: + repository: hyperdx/hyperdx-otel-collector + tag: 2-beta + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8888" + checksum/config: "abcdef1234567890" + deployment.kubernetes.io/revision: "1" + sidecar.istio.io/inject: "false" + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isSubset: + path: spec.template.metadata.annotations + content: + prometheus.io/scrape: "true" + prometheus.io/port: "8888" + checksum/config: "abcdef1234567890" + deployment.kubernetes.io/revision: "1" + sidecar.istio.io/inject: "false" diff --git a/charts/hdx-oss-v2/values.yaml b/charts/hdx-oss-v2/values.yaml index c2c9858..f09e51d 100644 --- a/charts/hdx-oss-v2/values.yaml +++ b/charts/hdx-oss-v2/values.yaml @@ -29,12 +29,12 @@ hyperdx: # Endpoint to send hyperdx logs/traces/metrics to.Defaults to the chart's otel collector endpoint. otelExporterEndpoint: http://{{ include "hdx-oss.fullname" . }}-otel-collector:{{ .Values.otel.httpPort }} mongoUri: mongodb://{{ include "hdx-oss.fullname" . }}-mongodb:{{ .Values.mongodb.port }}/hyperdx - + # Pod-level annotations (applied to the deployment pods) annotations: {} # myAnnotation: "myValue" - - # Pod-level labels (applied to the deployment pods) + + # Pod-level labels (applied to the deployment pods) labels: {} # myLabel: "myValue" env: [] @@ -238,7 +238,7 @@ clickhouse: # operator: "Equal" # value: "value1" # effect: "NoSchedule" - + # Service configuration service: type: ClusterIP # Use ClusterIP for security. For external access, use ingress with proper TLS and authentication @@ -275,6 +275,18 @@ otel: repository: docker.hyperdx.io/hyperdx/hyperdx-otel-collector tag: pullPolicy: IfNotPresent + replicas: 1 + resources: {} + # Example: + # requests: + # memory: "127Mi" + # cpu: "100m" + # limits: + # memory: "256Mi" + # cpu: "200m" + # Pod-level annotations (applied to the deployment pods) + annotations: {} + # myAnnotation: "myValue" # Add nodeSelector and tolerations for otel-collector service nodeSelector: {} # Example: