statefulset.yaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. ---
  2. apiVersion: {{ template "logstash.statefulset.apiVersion" . }}
  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.secrets }}
  59. secretschecksum: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum | trunc 63 }}
  60. {{- end }}
  61. spec:
  62. {{- if .Values.schedulerName }}
  63. schedulerName: "{{ .Values.schedulerName }}"
  64. {{- end }}
  65. securityContext:
  66. {{ toYaml .Values.podSecurityContext | indent 8 }}
  67. {{- if .Values.rbac.create }}
  68. serviceAccountName: "{{ template "logstash.fullname" . }}"
  69. {{- else if not (eq .Values.rbac.serviceAccountName "") }}
  70. serviceAccountName: {{ .Values.rbac.serviceAccountName | quote }}
  71. {{- end }}
  72. {{- with .Values.tolerations }}
  73. tolerations:
  74. {{ toYaml . | indent 6 }}
  75. {{- end }}
  76. {{- with .Values.nodeSelector }}
  77. nodeSelector:
  78. {{ toYaml . | indent 8 }}
  79. {{- end }}
  80. {{- if or (eq .Values.antiAffinity "hard") (eq .Values.antiAffinity "soft") .Values.nodeAffinity }}
  81. {{- if .Values.priorityClassName }}
  82. priorityClassName: {{ .Values.priorityClassName }}
  83. {{- end }}
  84. affinity:
  85. {{- end }}
  86. {{- if eq .Values.antiAffinity "hard" }}
  87. podAntiAffinity:
  88. requiredDuringSchedulingIgnoredDuringExecution:
  89. - labelSelector:
  90. matchExpressions:
  91. - key: app
  92. operator: In
  93. values:
  94. - "{{ template "logstash.fullname" .}}"
  95. topologyKey: {{ .Values.antiAffinityTopologyKey }}
  96. {{- else if eq .Values.antiAffinity "soft" }}
  97. podAntiAffinity:
  98. preferredDuringSchedulingIgnoredDuringExecution:
  99. - weight: 1
  100. podAffinityTerm:
  101. topologyKey: {{ .Values.antiAffinityTopologyKey }}
  102. labelSelector:
  103. matchExpressions:
  104. - key: app
  105. operator: In
  106. values:
  107. - "{{ template "logstash.fullname" . }}"
  108. {{- end }}
  109. {{- with .Values.nodeAffinity }}
  110. nodeAffinity:
  111. {{ toYaml . | indent 10 }}
  112. {{- end }}
  113. terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
  114. volumes:
  115. {{- range .Values.secretMounts }}
  116. - name: {{ .name }}
  117. secret:
  118. secretName: {{ .secretName }}
  119. {{- end }}
  120. {{- if .Values.logstashConfig }}
  121. - name: logstashconfig
  122. configMap:
  123. name: {{ template "logstash.fullname" . }}-config
  124. {{- end }}
  125. {{- if .Values.logstashPipeline }}
  126. - name: logstashpipeline
  127. configMap:
  128. name: {{ template "logstash.fullname" . }}-pipeline
  129. {{- end }}
  130. {{- if .Values.extraVolumes }}
  131. {{ tpl .Values.extraVolumes . | indent 8 }}
  132. {{- end }}
  133. {{- if .Values.imagePullSecrets }}
  134. imagePullSecrets:
  135. {{ toYaml .Values.imagePullSecrets | indent 8 }}
  136. {{- end }}
  137. {{- if .Values.extraInitContainers }}
  138. initContainers:
  139. {{ tpl .Values.extraInitContainers . | indent 6 }}
  140. {{- end }}
  141. containers:
  142. - name: "{{ template "logstash.name" . }}"
  143. securityContext:
  144. {{ toYaml .Values.securityContext | indent 10 }}
  145. image: "{{ .Values.image }}:{{ .Values.imageTag }}"
  146. imagePullPolicy: "{{ .Values.imagePullPolicy }}"
  147. livenessProbe:
  148. {{ toYaml .Values.livenessProbe | indent 10 }}
  149. readinessProbe:
  150. {{ toYaml .Values.readinessProbe | indent 10 }}
  151. ports:
  152. - name: http
  153. containerPort: {{ .Values.httpPort }}
  154. {{- if .Values.extraPorts }}
  155. {{- toYaml .Values.extraPorts | nindent 8 }}
  156. {{- end }}
  157. resources:
  158. {{ toYaml .Values.resources | indent 10 }}
  159. env:
  160. - name: LS_JAVA_OPTS
  161. value: "{{ .Values.logstashJavaOpts }}"
  162. {{- if .Values.extraEnvs }}
  163. {{ toYaml .Values.extraEnvs | indent 10 }}
  164. {{- end }}
  165. {{- if .Values.envFrom }}
  166. envFrom:
  167. {{ toYaml .Values.envFrom | indent 10 }}
  168. {{- end }}
  169. volumeMounts:
  170. {{- if .Values.persistence.enabled }}
  171. - name: "{{ template "logstash.fullname" . }}"
  172. mountPath: /usr/share/logstash/data
  173. {{- end }}
  174. {{- range .Values.secretMounts }}
  175. - name: {{ .name }}
  176. mountPath: {{ .path }}
  177. {{- if .subPath }}
  178. subPath: {{ .subPath }}
  179. {{- end }}
  180. {{- end }}
  181. {{- range $path, $config := .Values.logstashConfig }}
  182. - name: logstashconfig
  183. mountPath: /usr/share/logstash/config/{{ $path }}
  184. subPath: {{ $path }}
  185. {{- end -}}
  186. {{- range $path, $config := .Values.logstashPipeline }}
  187. - name: logstashpipeline
  188. mountPath: /usr/share/logstash/pipeline/{{ $path }}
  189. subPath: {{ $path }}
  190. {{- end -}}
  191. {{- if .Values.extraVolumeMounts }}
  192. {{ tpl .Values.extraVolumeMounts . | indent 10 }}
  193. {{- end }}
  194. {{- if .Values.lifecycle }}
  195. lifecycle:
  196. {{ toYaml .Values.lifecycle | indent 10 }}
  197. {{- end }}
  198. {{- if .Values.extraContainers }}
  199. {{ tpl .Values.extraContainers . | indent 6 }}
  200. {{- end }}