-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathdaemonset.yaml
362 lines (361 loc) · 13.2 KB
/
daemonset.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
{{- if .Values.otelAgent.enabled }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ template "splunk-otel-collector.fullname" . }}-agent
labels:
{{- include "splunk-otel-collector.commonLabels" . | nindent 4 }}
app: {{ template "splunk-otel-collector.name" . }}
chart: {{ template "splunk-otel-collector.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if and (eq (include "splunk-otel-collector.logsEnabled" .) "true") .Values.fluentd.enabled }}
engine: fluentd
{{- end }}
{{- if .Values.otelAgent.annotations }}
annotations:
{{- toYaml .Values.otelAgent.annotations | nindent 4 }}
{{- end }}
spec:
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
app: {{ template "splunk-otel-collector.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "splunk-otel-collector.name" . }}
release: {{ .Release.Name }}
{{- if .Values.otelAgent.podLabels }}
{{- toYaml .Values.otelAgent.podLabels | nindent 8 }}
{{- end }}
annotations:
checksum/config: {{ print (include (print $.Template.BasePath "/configmap-fluentd.yaml") .) (include (print $.Template.BasePath "/configmap-otel-agent.yaml") .) | sha256sum }}
{{- if .Values.otelAgent.podAnnotations }}
{{- toYaml .Values.otelAgent.podAnnotations | nindent 8 }}
{{- end }}
{{- if .Values.autodetect.istio }}
sidecar.istio.io/inject: "false"
{{- end }}
spec:
{{- if not .Values.isWindows }}
hostNetwork: true
{{- end }}
dnsPolicy: ClusterFirstWithHostNet
serviceAccountName: {{ template "splunk-otel-collector.serviceAccountName" . }}
nodeSelector:
{{- if .Values.nodeSelector }}
{{ toYaml .Values.nodeSelector | nindent 8 }}
{{- else }}
kubernetes.io/os: {{ .Values.isWindows | ternary "windows" "linux" }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | nindent 8 }}
{{- end }}
{{- if and (eq (include "splunk-otel-collector.logsEnabled" .) "true") .Values.fluentd.enabled }}
initContainers:
- name: prepare-fluentd-config
image: {{ .Values.image.fluentd.initContainer.image }}
imagePullPolicy: {{ .Values.image.fluentd.initContainer.pullPolicy }}
command: [ "sh", "-c"]
args:
- if [ -z "${LOG_FORMAT_TYPE}" ]; then
if [ "$(ls {{ .Values.fluentd.config.containers.pathDest }}/*/*json.log 2>/dev/null | wc -l)" != "0" ]; then
export LOG_FORMAT_TYPE=json;
else
export LOG_FORMAT_TYPE=cri;
fi;
fi;
cp /fluentd/etc/common/* /fluentd/etc/${LOG_FORMAT_TYPE}/* /fluentd/etc/
env:
- name: LOG_FORMAT_TYPE
value: "{{ .Values.fluentd.config.containers.logFormatType }}"
volumeMounts:
- name: varlogdest
mountPath: {{ .Values.fluentd.config.containers.pathDest }}
readOnly: true
- name: fluentd-config
mountPath: /fluentd/etc
- name: fluentd-config-common
mountPath: /fluentd/etc/common
- name: fluentd-config-json
mountPath: /fluentd/etc/json
- name: fluentd-config-cri
mountPath: /fluentd/etc/cri
{{- end }}
containers:
{{- if and (eq (include "splunk-otel-collector.logsEnabled" .) "true") .Values.fluentd.enabled }}
- name: fluentd
image: {{ template "splunk-otel-collector.image.fluentd" . }}
imagePullPolicy: {{ .Values.image.fluentd.pullPolicy }}
{{- if .Values.fluentd.securityContext }}
securityContext:
{{ toYaml .Values.fluentd.securityContext | nindent 10 }}
{{- end }}
env:
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- with .Values.fluentd.extraEnvs }}
{{- . | toYaml | nindent 10 }}
{{- end }}
resources:
{{- toYaml .Values.fluentd.resources | nindent 10 }}
volumeMounts:
- name: varlog
mountPath: {{ .Values.fluentd.config.containers.path }}
- name: varlogdest
mountPath: {{ .Values.fluentd.config.containers.pathDest }}
readOnly: true
- name: journallogpath
mountPath: {{ .Values.fluentd.config.journalLogPath | quote }}
readOnly: true
- name: fluentd-config
mountPath: /fluentd/etc
- name: secrets
mountPath: /fluentd/etc/splunk
readOnly: true
{{- end }}
- name: otel-collector
command:
{{- if .Values.isWindows }}
- powershell.exe
- -command
- .\otelcol.exe
- --config=C:\\conf\relay.yaml
{{- else }}
- /otelcol
- --config=/conf/relay.yaml
{{- end }}
- --metrics-addr=0.0.0.0:8889
{{- range .Values.otelAgent.extraArgs }}
- {{ . }}
{{- end }}
ports:
{{- range $key, $port := .Values.otelAgent.ports }}
{{- if eq true (and (eq (include "splunk-otel-collector.metricsEnabled" $) "true") (has "metrics" $port.enabled_for)) (and (eq (include "splunk-otel-collector.o11yTracesEnabled" $) "true") (has "traces" $port.enabled_for)) (and (eq (include "splunk-otel-collector.logsEnabled" $) "true") (has "logs" $port.enabled_for)) }}
- name: {{ $key }}
{{- omit $port "enabled_for" | toYaml | trim | nindent 10 }}
{{- end }}
{{- end }}
image: {{ template "splunk-otel-collector.image.otelcol" . }}
imagePullPolicy: {{ .Values.image.otelcol.pullPolicy }}
{{- if .Values.otelAgent.securityContext }}
securityContext:
{{ toYaml .Values.otelAgent.securityContext | nindent 10 }}
{{- end }}
env:
- name: SPLUNK_MEMORY_TOTAL_MIB
value: "{{ include "splunk-otel-collector.convertMemToMib" .Values.otelAgent.resources.limits.memory }}"
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: K8S_NODE_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
- name: K8S_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- if (eq (include "splunk-otel-collector.splunkO11yEnabled" .) "true") }}
- name: SPLUNK_O11Y_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "splunk-otel-collector.secret" . }}
key: splunk_o11y_access_token
{{- end }}
{{- if (eq (include "splunk-otel-collector.splunkPlatformEnabled" .) "true") }}
- name: SPLUNK_PLATFORM_HEC_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "splunk-otel-collector.secret" . }}
key: splunk_platform_hec_token
{{- end }}
{{- if eq (include "splunk-otel-collector.metricsEnabled" .) "true" }}
# Env variables for host metrics receiver
- name: HOST_PROC
value: {{ .Values.isWindows | ternary "C:\\hostfs\\proc" "/hostfs/proc" }}
- name: HOST_SYS
value: {{ .Values.isWindows | ternary "C:\\hostfs\\sys" "/hostfs/sys" }}
- name: HOST_ETC
value: {{ .Values.isWindows | ternary "C:\\hostfs\\etc" "/hostfs/etc" }}
- name: HOST_VAR
value: {{ .Values.isWindows | ternary "C:\\hostfs\\var" "/hostfs/var" }}
- name: HOST_RUN
value: {{ .Values.isWindows | ternary "C:\\hostfs\\run" "/hostfs/run" }}
- name: HOST_DEV
value: {{ .Values.isWindows | ternary "C:\\hostfs\\dev" "/hostfs/dev" }}
{{- end }}
{{- with .Values.otelAgent.extraEnvs }}
{{- . | toYaml | nindent 10 }}
{{- end }}
readinessProbe:
{{- if .Values.readinessProbe.initialDelaySeconds }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
{{- end }}
httpGet:
path: /
port: 13133
livenessProbe:
{{- if .Values.livenessProbe.initialDelaySeconds }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
{{- end }}
httpGet:
path: /
port: 13133
resources:
{{- toYaml .Values.otelAgent.resources | nindent 10 }}
volumeMounts:
- mountPath: {{ .Values.isWindows | ternary "C:\\conf" "/conf" }}
name: otel-configmap
{{- if eq (include "splunk-otel-collector.metricsEnabled" $) "true" }}
{{- if .Values.isWindows }}
- mountPath: "C:\\hostfs"
name: hostfs
readOnly: true
{{- else }}
- mountPath: /hostfs/dev
name: host-dev
readOnly: true
- mountPath: /hostfs/etc
name: host-etc
readOnly: true
- mountPath: /hostfs/proc
name: host-proc
readOnly: true
- mountPath: /hostfs/run/udev/data
name: host-run-udev-data
readOnly: true
- mountPath: /hostfs/sys
name: host-sys
readOnly: true
- mountPath: /hostfs/var/run/utmp
name: host-var-run-utmp
readOnly: true
{{- end }}
{{- end }}
{{- if and (eq (include "splunk-otel-collector.logsEnabled" $) "true") .Values.logsCollection.enabled }}
- name: varlog
mountPath: /var/log
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: checkpoint
mountPath: {{ .Values.logsCollection.checkpointPath }}
{{- end }}
{{- if .Values.otelAgent.extraVolumeMounts }}
{{- toYaml .Values.otelAgent.extraVolumeMounts | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
volumes:
{{- if (eq (include "splunk-otel-collector.logsEnabled" .) "true") }}
{{- if .Values.fluentd.enabled }}
- name: varlog
hostPath:
path: {{ .Values.fluentd.config.containers.path }}
- name: varlogdest
hostPath:
path: {{ .Values.fluentd.config.containers.pathDest }}
- name: journallogpath
hostPath:
path: {{ .Values.fluentd.config.journalLogPath | quote }}
- name: secrets
secret:
secretName: {{ template "splunk-otel-collector.secret" . }}
- name: fluentd-config
emptyDir: {}
- name: fluentd-config-common
configMap:
name: {{ template "splunk-otel-collector.fullname" . }}-fluentd
- name: fluentd-config-cri
configMap:
name: {{ template "splunk-otel-collector.fullname" . }}-fluentd-cri
- name: fluentd-config-json
configMap:
name: {{ template "splunk-otel-collector.fullname" . }}-fluentd-json
{{- end}}
{{- if .Values.logsCollection.enabled }}
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: checkpoint
hostPath:
path: {{ .Values.logsCollection.checkpointPath }}
type: DirectoryOrCreate
{{- end}}
{{- end}}
{{- if eq (include "splunk-otel-collector.metricsEnabled" $) "true" }}
{{- if .Values.isWindows }}
- name: hostfs
hostPath:
path: "C:\\"
{{- else }}
- name: host-dev
hostPath:
path: /dev
- name: host-etc
hostPath:
path: /etc
- name: host-proc
hostPath:
path: /proc
- name: host-run-udev-data
hostPath:
path: /run/udev/data
- name: host-sys
hostPath:
path: /sys
- name: host-var-run-utmp
hostPath:
path: /var/run/utmp
{{- end }}
{{- end }}
- name: otel-configmap
configMap:
name: {{ template "splunk-otel-collector.fullname" . }}-otel-agent
items:
- key: relay
path: relay.yaml
{{- if .Values.otelAgent.extraVolumes }}
{{- toYaml .Values.otelAgent.extraVolumes | nindent 6 }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- end }}