statefulset.yaml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. ---
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ template "logstash.fullname" . }}
  6. labels:
  7. app: "{{ template "logstash.fullname" . }}"
  8. chart: "{{ .Chart.Name }}"
  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. serviceName: {{ template "logstash.fullname" . }}-headless
  16. selector:
  17. matchLabels:
  18. app: "{{ template "logstash.fullname" . }}"
  19. release: {{ .Release.Name | quote }}
  20. replicas: {{ .Values.replicas }}
  21. podManagementPolicy: {{ .Values.podManagementPolicy }}
  22. updateStrategy:
  23. type: {{ .Values.updateStrategy }}
  24. {{- if .Values.persistence.enabled }}
  25. volumeClaimTemplates:
  26. - metadata:
  27. name: {{ template "logstash.fullname" . }}
  28. {{- with .Values.persistence.annotations }}
  29. annotations:
  30. {{ toYaml . | indent 8 }}
  31. {{- end }}
  32. spec:
  33. {{ toYaml .Values.volumeClaimTemplate | indent 6 }}
  34. {{- end }}
  35. template:
  36. metadata:
  37. name: "{{ template "logstash.fullname" . }}"
  38. labels:
  39. app: "{{ template "logstash.fullname" . }}"
  40. chart: "{{ .Chart.Name }}"
  41. heritage: {{ .Release.Service | quote }}
  42. release: {{ .Release.Name | quote }}
  43. {{- range $key, $value := .Values.labels }}
  44. {{ $key }}: {{ $value | quote }}
  45. {{- end }}
  46. annotations:
  47. {{- range $key, $value := .Values.podAnnotations }}
  48. {{ $key }}: {{ $value | quote }}
  49. {{- end }}
  50. {{- /* This forces a restart if the configmap has changed */}}
  51. {{- if .Values.logstashConfig }}
  52. configchecksum: {{ include (print .Template.BasePath "/configmap-config.yaml") . | sha256sum | trunc 63 }}
  53. {{- end }}
  54. {{- /* This forces a restart if the configmap has changed */}}
  55. {{- if .Values.logstashPipeline }}
  56. pipelinechecksum: {{ include (print .Template.BasePath "/configmap-pipeline.yaml") . | sha256sum | trunc 63 }}
  57. {{- end }}
  58. {{- if .Values.logstashPattern }}
  59. patternchecksum: {{ include (print .Template.BasePath "/configmap-pattern.yaml") . | sha256sum | trunc 63 }}
  60. {{- end }}
  61. {{- if .Values.secrets }}
  62. secretschecksum: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum | trunc 63 }}
  63. {{- end }}
  64. spec:
  65. {{- if .Values.schedulerName }}
  66. schedulerName: "{{ .Values.schedulerName }}"
  67. {{- end }}
  68. securityContext:
  69. {{ toYaml .Values.podSecurityContext | indent 8 }}
  70. {{- if or .Values.rbac.create .Values.rbac.serviceAccountName }}
  71. serviceAccountName: "{{ template "logstash.serviceAccount" . }}"
  72. {{- end }}
  73. {{- with .Values.tolerations }}
  74. tolerations:
  75. {{ toYaml . | indent 6 }}
  76. {{- end }}
  77. {{- with .Values.nodeSelector }}
  78. nodeSelector:
  79. {{ toYaml . | indent 8 }}
  80. {{- end }}
  81. {{- if or (eq .Values.antiAffinity "hard") (eq .Values.antiAffinity "soft") .Values.nodeAffinity .Values.podAffinity }}
  82. {{- if .Values.priorityClassName }}
  83. priorityClassName: {{ .Values.priorityClassName }}
  84. {{- end }}
  85. affinity:
  86. {{- end }}
  87. {{- if eq .Values.antiAffinity "hard" }}
  88. podAntiAffinity:
  89. requiredDuringSchedulingIgnoredDuringExecution:
  90. - labelSelector:
  91. matchExpressions:
  92. - key: app
  93. operator: In
  94. values:
  95. - "{{ template "logstash.fullname" .}}"
  96. topologyKey: {{ .Values.antiAffinityTopologyKey }}
  97. {{- else if eq .Values.antiAffinity "soft" }}
  98. podAntiAffinity:
  99. preferredDuringSchedulingIgnoredDuringExecution:
  100. - weight: 1
  101. podAffinityTerm:
  102. topologyKey: {{ .Values.antiAffinityTopologyKey }}
  103. labelSelector:
  104. matchExpressions:
  105. - key: app
  106. operator: In
  107. values:
  108. - "{{ template "logstash.fullname" . }}"
  109. {{- end }}
  110. {{- with .Values.nodeAffinity }}
  111. nodeAffinity:
  112. {{ toYaml . | indent 10 }}
  113. {{- end }}
  114. {{- with .Values.podAffinity }}
  115. podAffinity:
  116. {{ toYaml . | indent 10 }}
  117. {{- end }}
  118. terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
  119. volumes:
  120. {{- range .Values.secretMounts }}
  121. - name: {{ .name }}
  122. secret:
  123. secretName: {{ .secretName }}
  124. {{- end }}
  125. {{- if .Values.logstashConfig }}
  126. - name: logstashconfig
  127. configMap:
  128. name: {{ template "logstash.fullname" . }}-config
  129. {{- end }}
  130. {{- if .Values.logstashPipeline }}
  131. - name: logstashpipeline
  132. configMap:
  133. name: {{ template "logstash.fullname" . }}-pipeline
  134. {{- end }}
  135. {{- if .Values.logstashPattern }}
  136. - name: logstashpattern
  137. configMap:
  138. name: {{ template "logstash.fullname" . }}-pattern
  139. {{- end }}
  140. {{- if .Values.extraVolumes }}
  141. {{- if eq "string" (printf "%T" .Values.extraVolumes) }}
  142. {{ tpl .Values.extraVolumes . | indent 8 }}
  143. {{- else }}
  144. {{ toYaml .Values.extraVolumes | indent 8 }}
  145. {{- end }}
  146. {{- end }}
  147. {{- if .Values.imagePullSecrets }}
  148. imagePullSecrets:
  149. {{ toYaml .Values.imagePullSecrets | indent 8 }}
  150. {{- end}}
  151. {{- if .Values.hostAliases }}
  152. hostAliases: {{ toYaml .Values.hostAliases | nindent 6 }}
  153. {{- end }}
  154. {{- if .Values.extraInitContainers }}
  155. initContainers:
  156. {{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
  157. {{ tpl .Values.extraInitContainers . | indent 6 }}
  158. {{- else }}
  159. {{ toYaml .Values.extraInitContainers | indent 6 }}
  160. {{- end }}
  161. {{- end }}
  162. containers:
  163. - name: "{{ template "logstash.name" . }}"
  164. securityContext:
  165. {{ toYaml .Values.securityContext | indent 10 }}
  166. image: "{{ .Values.image }}:{{ .Values.imageTag }}"
  167. imagePullPolicy: "{{ .Values.imagePullPolicy }}"
  168. livenessProbe:
  169. {{ toYaml .Values.livenessProbe | indent 10 }}
  170. readinessProbe:
  171. {{ toYaml .Values.readinessProbe | indent 10 }}
  172. ports:
  173. - name: http
  174. containerPort: {{ .Values.httpPort }}
  175. {{- if .Values.extraPorts }}
  176. {{- toYaml .Values.extraPorts | nindent 8 }}
  177. {{- end }}
  178. resources:
  179. {{ toYaml .Values.resources | indent 10 }}
  180. env:
  181. - name: LS_JAVA_OPTS
  182. value: "{{ .Values.logstashJavaOpts }}"
  183. {{- if .Values.extraEnvs }}
  184. {{ toYaml .Values.extraEnvs | indent 10 }}
  185. {{- end }}
  186. {{- if .Values.envFrom }}
  187. envFrom:
  188. {{ toYaml .Values.envFrom | indent 10 }}
  189. {{- end }}
  190. volumeMounts:
  191. {{- if .Values.persistence.enabled }}
  192. - name: "{{ template "logstash.fullname" . }}"
  193. mountPath: /usr/share/logstash/data
  194. {{- end }}
  195. {{- range .Values.secretMounts }}
  196. - name: {{ .name }}
  197. mountPath: {{ .path }}
  198. {{- if .subPath }}
  199. subPath: {{ .subPath }}
  200. {{- end }}
  201. {{- end }}
  202. {{- range $path, $config := .Values.logstashConfig }}
  203. - name: logstashconfig
  204. mountPath: /usr/share/logstash/config/{{ $path }}
  205. subPath: {{ $path }}
  206. {{- end -}}
  207. {{- range $path, $config := .Values.logstashPipeline }}
  208. - name: logstashpipeline
  209. mountPath: /usr/share/logstash/pipeline/{{ $path }}
  210. subPath: {{ $path }}
  211. {{- end -}}
  212. {{- if .Values.logstashPattern }}
  213. {{- $logstashPatternDir := .Values.logstashPatternDir -}}
  214. {{- range $path, $config := .Values.logstashPattern }}
  215. - name: logstashpattern
  216. mountPath: {{ $logstashPatternDir }}{{ $path }}
  217. subPath: {{ $path }}
  218. {{- end -}}
  219. {{- end -}}
  220. {{- if .Values.extraVolumeMounts }}
  221. {{- if eq "string" (printf "%T" .Values.extraVolumeMounts) }}
  222. {{ tpl .Values.extraVolumeMounts . | indent 10 }}
  223. {{- else }}
  224. {{ toYaml .Values.extraVolumeMounts | indent 10 }}
  225. {{- end }}
  226. {{- end }}
  227. {{- if .Values.lifecycle }}
  228. lifecycle:
  229. {{ toYaml .Values.lifecycle | indent 10 }}
  230. {{- end }}
  231. {{- if .Values.extraContainers }}
  232. {{- if eq "string" (printf "%T" .Values.extraContainers) }}
  233. {{ tpl .Values.extraContainers . | indent 6 }}
  234. {{- else }}
  235. {{ toYaml .Values.extraContainers | indent 6 }}
  236. {{- end }}
  237. {{- end }}