Skip to content

Commit 8ae443f

Browse files
committed
move configmap to helper template
1 parent 049dce1 commit 8ae443f

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

charts/opentelemetry-ebpf-instrumentation/examples/default/rendered/configmap.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ metadata:
1515
app.kubernetes.io/component: config
1616
data:
1717
ebpf-instrument-config.yml: |
18-
discovery:
19-
services:
20-
- k8s_namespace: .
21-
exclude_services:
22-
- exe_path: ".*ebpf-instrument.*|.*otelcol.*"
2318
attributes:
2419
kubernetes:
2520
enable: true
21+
discovery:
22+
exclude_services:
23+
- exe_path: .*ebpf-instrument.*|.*otelcol.*
24+
services:
25+
- k8s_namespace: .
2626
filter:
2727
network:
2828
k8s_dst_owner_name:

charts/opentelemetry-ebpf-instrumentation/examples/default/rendered/daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
template:
2424
metadata:
2525
annotations:
26-
checksum/config: 38494832e2d0254bc1eb17e86788cec59c5f5c607cc486a44dc90fa20517c46d
26+
checksum/config: 2ddd12b5cac5f3eab28d8bc500cb3db81df076a39a5143c879aed1772dfdc4ee
2727
labels:
2828
helm.sh/chart: opentelemetry-ebpf-instrumentation-0.1.0
2929
app.kubernetes.io/name: opentelemetry-ebpf-instrumentation

charts/opentelemetry-ebpf-instrumentation/templates/_helpers.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,22 @@ app.kubernetes.io/instance: {{ .Release.Name }}
133133
{{ toYaml . }}
134134
{{- end }}
135135
{{- end }}
136+
137+
{{/*
138+
Generate the configmap data based on preset and configuration values
139+
*/}}
140+
{{- define "obi.configData" -}}
141+
{{- $config := deepCopy .Values.config.data }}
142+
{{- if eq .Values.preset "network" }}
143+
{{- if not .Values.config.data.network }}
144+
{{- $_ := set $config "network" (dict "enable" true) }}
145+
{{- end }}
146+
{{- end }}
147+
{{- if eq .Values.preset "application" }}
148+
{{- if not .Values.config.data.discovery }}
149+
{{- $discovery := dict "services" (list (dict "k8s_namespace" ".")) "exclude_services" (list (dict "exe_path" ".*ebpf-instrument.*|.*otelcol.*")) }}
150+
{{- $_ := set $config "discovery" $discovery }}
151+
{{- end }}
152+
{{- end }}
153+
{{- toYaml $config }}
154+
{{- end }}

charts/opentelemetry-ebpf-instrumentation/templates/configmap.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,5 @@ metadata:
1818
{{- end }}
1919
data:
2020
ebpf-instrument-config.yml: |
21-
{{- if eq .Values.preset "network" }}
22-
{{- if not .Values.config.data.network }}
23-
network:
24-
enable: true
25-
{{- end }}
26-
{{- end }}
27-
{{- if eq .Values.preset "application" }}
28-
{{- if not .Values.config.data.discovery }}
29-
discovery:
30-
services:
31-
- k8s_namespace: .
32-
exclude_services:
33-
- exe_path: ".*ebpf-instrument.*|.*otelcol.*"
34-
{{- end }}
35-
{{- end }}
36-
{{- toYaml .Values.config.data | nindent 4}}
21+
{{- include "obi.configData" . | nindent 4 }}
3722
{{- end }}

0 commit comments

Comments
 (0)