daemonset.yaml 7.7 KB

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