statefulset-ruler.yaml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. {{- if and (eq .Values.ruler.kind "StatefulSet") .Values.ruler.enabled }}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ include "loki.rulerFullname" . }}
  6. labels:
  7. {{- include "loki.rulerLabels" . | nindent 4 }}
  8. app.kubernetes.io/part-of: memberlist
  9. {{- with .Values.loki.annotations }}
  10. annotations:
  11. {{- toYaml . | nindent 4 }}
  12. {{- end }}
  13. spec:
  14. replicas: {{ .Values.ruler.replicas }}
  15. revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
  16. serviceName: {{ include "loki.rulerFullname" . }}
  17. selector:
  18. matchLabels:
  19. {{- include "loki.rulerSelectorLabels" . | nindent 6 }}
  20. template:
  21. metadata:
  22. annotations:
  23. {{- include "loki.config.checksum" . | nindent 8 }}
  24. {{- with .Values.loki.podAnnotations }}
  25. {{- toYaml . | nindent 8 }}
  26. {{- end }}
  27. {{- with .Values.ruler.podAnnotations }}
  28. {{- toYaml . | nindent 8 }}
  29. {{- end }}
  30. labels:
  31. {{- include "loki.rulerSelectorLabels" . | nindent 8 }}
  32. app.kubernetes.io/part-of: memberlist
  33. {{- with .Values.loki.podLabels }}
  34. {{- toYaml . | nindent 8 }}
  35. {{- end }}
  36. {{- with .Values.ruler.podLabels }}
  37. {{- toYaml . | nindent 8 }}
  38. {{- end }}
  39. spec:
  40. serviceAccountName: {{ include "loki.serviceAccountName" . }}
  41. {{- with .Values.imagePullSecrets }}
  42. imagePullSecrets:
  43. {{- toYaml . | nindent 8 }}
  44. {{- end }}
  45. {{- with .Values.ruler.hostAliases }}
  46. hostAliases:
  47. {{- toYaml . | nindent 8 }}
  48. {{- end }}
  49. {{- include "loki.rulerPriorityClassName" . | nindent 6 }}
  50. securityContext:
  51. {{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
  52. terminationGracePeriodSeconds: {{ .Values.ruler.terminationGracePeriodSeconds }}
  53. {{- with .Values.ruler.initContainers }}
  54. initContainers:
  55. {{- toYaml . | nindent 8 }}
  56. {{- end }}
  57. containers:
  58. - name: ruler
  59. image: {{ include "loki.rulerImage" . }}
  60. imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
  61. args:
  62. - -config.file=/etc/loki/config/config.yaml
  63. - -target=ruler
  64. {{- with .Values.ruler.extraArgs }}
  65. {{- toYaml . | nindent 12 }}
  66. {{- end }}
  67. ports:
  68. - name: http
  69. containerPort: 3100
  70. protocol: TCP
  71. - name: grpc
  72. containerPort: 9095
  73. protocol: TCP
  74. - name: http-memberlist
  75. containerPort: 7946
  76. protocol: TCP
  77. {{- with .Values.ruler.extraEnv }}
  78. env:
  79. {{- toYaml . | nindent 12 }}
  80. {{- end }}
  81. {{- with .Values.ruler.extraEnvFrom }}
  82. envFrom:
  83. {{- toYaml . | nindent 12 }}
  84. {{- end }}
  85. securityContext:
  86. {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
  87. readinessProbe:
  88. {{- toYaml .Values.loki.readinessProbe | nindent 12 }}
  89. livenessProbe:
  90. {{- toYaml .Values.loki.livenessProbe | nindent 12 }}
  91. volumeMounts:
  92. - name: config
  93. mountPath: /etc/loki/config
  94. - name: runtime-config
  95. mountPath: /var/{{ include "loki.name" . }}-runtime
  96. - name: data
  97. mountPath: /var/loki
  98. - name: tmp
  99. mountPath: /tmp/loki
  100. {{- range $dir, $_ := .Values.ruler.directories }}
  101. - name: {{ include "loki.rulerRulesDirName" $dir }}
  102. mountPath: /etc/loki/rules/{{ $dir }}
  103. {{- end }}
  104. {{- with .Values.ruler.extraVolumeMounts }}
  105. {{- toYaml . | nindent 12 }}
  106. {{- end }}
  107. resources:
  108. {{- toYaml .Values.ruler.resources | nindent 12 }}
  109. {{- with .Values.ruler.extraContainers }}
  110. {{- toYaml . | nindent 8}}
  111. {{- end }}
  112. {{- with .Values.ruler.affinity }}
  113. affinity:
  114. {{- tpl . $ | nindent 8 }}
  115. {{- end }}
  116. {{- with .Values.ruler.nodeSelector }}
  117. nodeSelector:
  118. {{- toYaml . | nindent 8 }}
  119. {{- end }}
  120. {{- with .Values.ruler.tolerations }}
  121. tolerations:
  122. {{- toYaml . | nindent 8 }}
  123. {{- end }}
  124. {{- with .Values.ruler.dnsConfig }}
  125. dnsConfig:
  126. {{- toYaml . | nindent 8 }}
  127. {{- end }}
  128. volumes:
  129. - name: config
  130. {{- if .Values.loki.existingSecretForConfig }}
  131. secret:
  132. secretName: {{ .Values.loki.existingSecretForConfig }}
  133. {{- else if .Values.loki.configAsSecret }}
  134. secret:
  135. secretName: {{ include "loki.fullname" . }}-config
  136. {{- else }}
  137. configMap:
  138. name: {{ include "loki.fullname" . }}
  139. {{- end }}
  140. - name: runtime-config
  141. configMap:
  142. name: {{ template "loki.fullname" . }}-runtime
  143. {{- range $dir, $_ := .Values.ruler.directories }}
  144. - name: {{ include "loki.rulerRulesDirName" $dir }}
  145. configMap:
  146. name: {{ include "loki.rulerFullname" $ }}-{{ include "loki.rulerRulesDirName" $dir }}
  147. {{- end }}
  148. - name: tmp
  149. emptyDir: {}
  150. {{- with .Values.ruler.extraVolumes }}
  151. {{- toYaml . | nindent 8 }}
  152. {{- end }}
  153. {{- if not .Values.ruler.persistence.enabled }}
  154. - name: data
  155. emptyDir: {}
  156. {{- else }}
  157. volumeClaimTemplates:
  158. - metadata:
  159. name: data
  160. {{- with .Values.ruler.persistence.annotations }}
  161. annotations:
  162. {{- . | toYaml | nindent 10 }}
  163. {{- end }}
  164. spec:
  165. accessModes:
  166. - ReadWriteOnce
  167. {{- with .Values.ruler.persistence.storageClass }}
  168. storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
  169. {{- end }}
  170. resources:
  171. requests:
  172. storage: {{ .Values.ruler.persistence.size | quote }}
  173. {{- end }}
  174. {{- end }}