daemonset.yaml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. ---
  2. apiVersion: apps/v1
  3. kind: DaemonSet
  4. metadata:
  5. name: {{ template "filebeat.fullname" . }}
  6. labels:
  7. app: "{{ template "filebeat.fullname" . }}"
  8. chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  9. heritage: {{ .Release.Service | quote }}
  10. release: {{ .Release.Name | quote }}
  11. {{- range $key, $value := .Values.labels }}
  12. {{ $key }}: {{ $value | quote }}
  13. {{- end }}
  14. spec:
  15. selector:
  16. matchLabels:
  17. app: "{{ template "filebeat.fullname" . }}"
  18. release: {{ .Release.Name | quote }}
  19. updateStrategy:
  20. type: {{ .Values.updateStrategy }}
  21. template:
  22. metadata:
  23. annotations:
  24. {{- range $key, $value := .Values.podAnnotations }}
  25. {{ $key }}: {{ $value | quote }}
  26. {{- end }}
  27. {{/* This forces a restart if the configmap has changed */}}
  28. {{- if .Values.filebeatConfig }}
  29. configChecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
  30. {{- end }}
  31. name: "{{ template "filebeat.fullname" . }}"
  32. labels:
  33. app: "{{ template "filebeat.fullname" . }}"
  34. chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  35. heritage: {{ .Release.Service | quote }}
  36. release: {{ .Release.Name | quote }}
  37. {{- range $key, $value := .Values.labels }}
  38. {{ $key }}: {{ $value | quote }}
  39. {{- end }}
  40. spec:
  41. {{- with .Values.tolerations }}
  42. tolerations: {{ toYaml . | nindent 6 }}
  43. {{- end }}
  44. {{- with .Values.nodeSelector }}
  45. nodeSelector: {{ toYaml . | nindent 8 }}
  46. {{- end }}
  47. {{- if .Values.priorityClassName }}
  48. priorityClassName: {{ .Values.priorityClassName }}
  49. {{- end }}
  50. {{- with .Values.affinity }}
  51. affinity: {{ toYaml . | nindent 8 -}}
  52. {{- end }}
  53. serviceAccountName: {{ template "filebeat.serviceAccount" . }}
  54. terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
  55. {{- if .Values.hostNetworking }}
  56. hostNetwork: true
  57. dnsPolicy: ClusterFirstWithHostNet
  58. {{- end }}
  59. volumes:
  60. {{- range .Values.secretMounts }}
  61. - name: {{ .name }}
  62. secret:
  63. secretName: {{ .secretName }}
  64. {{- end }}
  65. {{- if .Values.filebeatConfig }}
  66. - name: filebeat-config
  67. configMap:
  68. defaultMode: 0600
  69. name: {{ template "filebeat.fullname" . }}-config
  70. {{- end }}
  71. - name: data
  72. hostPath:
  73. path: {{ .Values.hostPathRoot }}/{{ template "filebeat.fullname" . }}-{{ .Release.Namespace }}-data
  74. type: DirectoryOrCreate
  75. - name: varlibdockercontainers
  76. hostPath:
  77. path: /var/lib/docker/containers
  78. - name: varlog
  79. hostPath:
  80. path: /var/log
  81. - name: varrundockersock
  82. hostPath:
  83. path: /var/run/docker.sock
  84. {{- if .Values.extraVolumes }}
  85. {{ toYaml .Values.extraVolumes | indent 6 }}
  86. {{- end }}
  87. {{- if .Values.imagePullSecrets }}
  88. imagePullSecrets:
  89. {{ toYaml .Values.imagePullSecrets | indent 8 }}
  90. {{- end }}
  91. {{- if .Values.extraInitContainers }}
  92. initContainers:
  93. # All the other beats accept a string here while
  94. # filebeat accepts a valid yaml array. We're keeping
  95. # this as a backwards compatible change, while adding
  96. # also a way to pass a string as other templates to
  97. # make these implementations consistent.
  98. # https://github.com/elastic/helm-charts/issues/490
  99. {{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
  100. {{ tpl .Values.extraInitContainers . | indent 8 }}
  101. {{- else }}
  102. {{ toYaml .Values.extraInitContainers | indent 8 }}
  103. {{- end }}
  104. {{- end }}
  105. containers:
  106. - name: "filebeat"
  107. image: "{{ .Values.image }}:{{ .Values.imageTag }}"
  108. imagePullPolicy: "{{ .Values.imagePullPolicy }}"
  109. args:
  110. - "-e"
  111. - "-E"
  112. - "http.enabled=true"
  113. livenessProbe:
  114. {{ toYaml .Values.livenessProbe | indent 10 }}
  115. readinessProbe:
  116. {{ toYaml .Values.readinessProbe | indent 10 }}
  117. resources:
  118. {{ toYaml .Values.resources | indent 10 }}
  119. env:
  120. - name: POD_NAMESPACE
  121. valueFrom:
  122. fieldRef:
  123. fieldPath: metadata.namespace
  124. - name: NODE_NAME
  125. valueFrom:
  126. fieldRef:
  127. fieldPath: spec.nodeName
  128. {{- if .Values.extraEnvs }}
  129. {{ toYaml .Values.extraEnvs | indent 8 }}
  130. {{- end }}
  131. {{- if .Values.envFrom }}
  132. envFrom:
  133. {{ toYaml .Values.envFrom | indent 10 }}
  134. {{- end }}
  135. {{- if .Values.podSecurityContext }}
  136. securityContext:
  137. {{ toYaml .Values.podSecurityContext | indent 10 }}
  138. {{- end }}
  139. volumeMounts:
  140. {{- range .Values.secretMounts }}
  141. - name: {{ .name }}
  142. mountPath: {{ .path }}
  143. {{- if .subPath }}
  144. subPath: {{ .subPath }}
  145. {{- end }}
  146. {{- end }}
  147. {{- range $path, $config := .Values.filebeatConfig }}
  148. - name: filebeat-config
  149. mountPath: /usr/share/filebeat/{{ $path }}
  150. readOnly: true
  151. subPath: {{ $path }}
  152. {{- end }}
  153. - name: data
  154. mountPath: /usr/share/filebeat/data
  155. - name: varlibdockercontainers
  156. mountPath: /var/lib/docker/containers
  157. readOnly: true
  158. - name: varlog
  159. mountPath: /var/log
  160. readOnly: true
  161. # Necessary when using autodiscovery; avoid mounting it otherwise
  162. # See: https://www.elastic.co/guide/en/beats/filebeat/7.8/configuration-autodiscover.html
  163. - name: varrundockersock
  164. mountPath: /var/run/docker.sock
  165. readOnly: true
  166. {{- if .Values.extraVolumeMounts }}
  167. {{ toYaml .Values.extraVolumeMounts | indent 8 }}
  168. {{- end }}
  169. {{- if .Values.extraContainers }}
  170. {{ tpl .Values.extraContainers . | indent 6 }}
  171. {{- end }}