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