Skip to content

Commit

Permalink
feat(deploy/otc): ensure backward compatibility for tpl change
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Rosiek <drosiek@sumologic.com>
  • Loading branch information
Dominik Rosiek authored and sumo-drosiek committed Sep 6, 2021
1 parent bff5b36 commit 40ece1e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 16 deletions.
9 changes: 8 additions & 1 deletion deploy/helm/sumologic/conf/traces/traces.otelagent.conf.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
{{ tpl (toYaml .Values.otelagent.config | replace ": '{{" ": {{" | replace "}}'" "}}") . | nindent 2 }}
{{- $yamlFile := toYaml $.Values.otelagent.config }}

{{- $otelcolService := include "sumologic.metadata.name.otelcol.service" . }}
{{- $collectorAddress := printf "%s.%s" $otelcolService .Release.Namespace }}

{{- $yamlFile := replace "exporters.otlp.endpoint.replace" $collectorAddress $yamlFile }}

{{ tpl ($yamlFile | replace ": '{{" ": {{" | replace "}}'" "}}") . | nindent 2 }}
28 changes: 27 additions & 1 deletion deploy/helm/sumologic/conf/traces/traces.otelcol.conf.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
{{- tpl (toYaml .Values.otelcol.config | replace ": '{{" ": {{" | replace "}}'" "}}") . | nindent 2 }}
{{- $yamlFile := toYaml $.Values.otelcol.config }}
{{- $_collector := .Values.sumologic.collectorName | default .Values.sumologic.clusterName | quote }}
{{- $sourceName := .Values.fluentd.logs.containers.sourceName | quote }}
{{- $sourceCategory := .Values.fluentd.logs.containers.sourceCategory | quote }}
{{- $sourceCategoryPrefix := .Values.fluentd.logs.containers.sourceCategoryPrefix | quote }}
{{- $sourceCategoryReplaceDash := .Values.fluentd.logs.containers.sourceCategoryReplaceDash | quote }}
{{- $excludeNamespaceRegex := .Values.fluentd.logs.containers.excludeNamespaceRegex | quote }}
{{ if eq .Values.sumologic.collectionMonitoring false }}
{{- $excludeNamespaceRegex = printf "%s|%s" .Release.Namespace .Values.fluentd.logs.containers.excludeNamespaceRegex | quote }}
{{- end }}
{{- $excludePodRegex := .Values.fluentd.logs.containers.excludePodRegex | quote }}
{{- $excludeContainerRegex := .Values.fluentd.logs.containers.excludeContainerRegex | quote }}
{{- $excludeHostRegex := .Values.fluentd.logs.containers.excludeHostRegex | quote }}
{{- $clusterName := include "sumologic.clusterNameReplaceSpaceWithDash" . }}

{{- $yamlFile := replace "processors.source.collector.replace" $_collector $yamlFile }}
{{- $yamlFile := replace "processors.source.name.replace" $sourceName $yamlFile }}
{{- $yamlFile := replace "processors.source.category.replace" $sourceCategory $yamlFile }}
{{- $yamlFile := replace "processors.source.category_prefix.replace" $sourceCategoryPrefix $yamlFile }}
{{- $yamlFile := replace "processors.source.category_replace_dash.replace" $sourceCategoryReplaceDash $yamlFile }}
{{- $yamlFile := replace "processors.source.exclude_namespace_regex.replace" $excludeNamespaceRegex $yamlFile }}
{{- $yamlFile := replace "processors.source.exclude_pod_regex.replace" $excludePodRegex $yamlFile }}
{{- $yamlFile := replace "processors.source.exclude_container_regex.replace" $excludeContainerRegex $yamlFile }}
{{- $yamlFile := replace "processors.source.exclude_host_regex.replace" $excludeHostRegex $yamlFile }}
{{- $yamlFile := replace "processors.resource.cluster.replace" $clusterName $yamlFile }}

{{- tpl ($yamlFile | replace ": '{{" ": {{" | replace "}}'" "}}") . | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ spec:
{{- if .Values.fluentd.pvcLabels }}
labels:
{{ toYaml .Values.fluentd.pvcLabels | indent 8 }}
{{- end }}
{{- end }}
spec:
accessModes: [{{ .Values.fluentd.persistence.accessMode }}]
storageClassName: {{ .Values.fluentd.persistence.storageClass }}
Expand Down
22 changes: 11 additions & 11 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,7 @@ otelagent:
health_check: {}
exporters:
otlp:
endpoint: "{{ $.defaultCollectorName }}:4317"
endpoint: "exporters.otlp.endpoint.replace:4317"
insecure: true
service:
extensions: [health_check]
Expand Down Expand Up @@ -2487,15 +2487,15 @@ otelcol:
key: "*"
## Source processor adds Sumo Logic related metadata
source:
collector: '{{ .Values.sumologic.collectorName | default .Values.sumologic.clusterName | quote }}'
source_name: '{{ .Values.fluentd.logs.containers.sourceName | quote }}'
source_category: '{{ .Values.fluentd.logs.containers.sourceCategory | quote }}'
source_category_prefix: '{{ .Values.fluentd.logs.containers.sourceCategoryPrefix | quote }}'
source_category_replace_dash: '{{ .Values.fluentd.logs.containers.sourceCategoryReplaceDash | quote }}'
exclude_namespace_regex: '{{ include "fluentd.excludeNamespaces" . }}'
exclude_pod_regex: '{{ .Values.fluentd.logs.containers.excludePodRegex | quote }}'
exclude_container_regex: '{{ .Values.fluentd.logs.containers.excludeContainerRegex | quote }}'
exclude_host_regex: '{{ .Values.fluentd.logs.containers.excludeHostRegex | quote }}'
collector: "processors.source.collector.replace"
source_name: "processors.source.name.replace"
source_category: "processors.source.category.replace"
source_category_prefix: "processors.source.category_prefix.replace"
source_category_replace_dash: "processors.source.category_replace_dash.replace"
exclude_namespace_regex: "processors.source.exclude_namespace_regex.replace"
exclude_pod_regex: "processors.source.exclude_pod_regex.replace"
exclude_container_regex: "processors.source.exclude_container_regex.replace"
exclude_host_regex: "processors.source.exclude_host_regex.replace"
annotation_prefix: "k8s.pod.annotation."
pod_template_hash_key: "k8s.pod.label.pod-template-hash"
pod_name_key: "k8s.pod.pod_name"
Expand All @@ -2508,7 +2508,7 @@ otelcol:
resource:
attributes:
- key: k8s.cluster.name
value: '{{ include "otelcol.k8s.cluster.name" . }}'
value: "processors.resource.cluster.replace"
action: upsert

## The memory_limiter processor is used to prevent out of memory situations on the collector.
Expand Down
3 changes: 2 additions & 1 deletion tests/tracing/static/collection-monitoring-false.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ metadata:
heritage: "Helm"
data:
traces.otelcol.conf.yaml: |
exporters:
otlphttp:
compression: gzip
Expand Down Expand Up @@ -71,7 +72,7 @@ data:
attributes:
- action: upsert
key: k8s.cluster.name
value: "kubernetes"
value: kubernetes
source:
annotation_prefix: k8s.pod.annotation.
collector: "kubernetes"
Expand Down
3 changes: 2 additions & 1 deletion tests/tracing/static/simple.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ metadata:
heritage: "Helm"
data:
traces.otelcol.conf.yaml: |
exporters:
otlphttp:
compression: gzip
Expand Down Expand Up @@ -71,7 +72,7 @@ data:
attributes:
- action: upsert
key: k8s.cluster.name
value: "kubernetes"
value: kubernetes
source:
annotation_prefix: k8s.pod.annotation.
collector: "kubernetes"
Expand Down

0 comments on commit 40ece1e

Please sign in to comment.