deployment.yaml 6.1 KB

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