deployment-ruler.yaml 5.7 KB

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