blob: 6efa0ad5594ca1c14409b9cfe5e97a6e339548c4 [file] [log] [blame]
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +00001{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
2{{- if and $isSimpleScalable (.Values.read.legacyReadTarget ) }}
3---
4apiVersion: apps/v1
5kind: StatefulSet
6metadata:
7 name: {{ include "loki.readFullname" . }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -03008 namespace: {{ $.Release.Namespace }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +00009 labels:
10 app.kubernetes.io/part-of: memberlist
11 {{- include "loki.readLabels" . | nindent 4 }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030012 {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.read.annotations))}}
13 annotations:
14 {{- with .Values.loki.annotations }}
15 {{- toYaml . | nindent 4 }}
16 {{- end }}
17 {{- with .Values.read.annotations }}
18 {{- toYaml . | nindent 4 }}
19 {{- end }}
20 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000021spec:
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030022{{- if not .Values.read.autoscaling.enabled }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000023 replicas: {{ .Values.read.replicas }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030024{{- end }}
25 podManagementPolicy: {{ .Values.read.podManagementPolicy }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000026 updateStrategy:
27 rollingUpdate:
28 partition: 0
29 serviceName: {{ printf "%s-headless" (include "loki.readFullname" .) }}
30 revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
31 {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.read.persistence.enableStatefulSetAutoDeletePVC) }}
32 {{/*
33 Data on the read nodes is easy to replace, so we want to always delete PVCs to make
34 operation easier, and will rely on re-fetching data when needed.
35 */}}
36 persistentVolumeClaimRetentionPolicy:
37 whenDeleted: Delete
38 whenScaled: Delete
39 {{- end }}
40 selector:
41 matchLabels:
42 {{- include "loki.readSelectorLabels" . | nindent 6 }}
43 template:
44 metadata:
45 annotations:
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030046 checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000047 {{- with .Values.loki.podAnnotations }}
48 {{- toYaml . | nindent 8 }}
49 {{- end }}
50 {{- with .Values.read.podAnnotations }}
51 {{- toYaml . | nindent 8 }}
52 {{- end }}
53 labels:
54 app.kubernetes.io/part-of: memberlist
55 {{- include "loki.readSelectorLabels" . | nindent 8 }}
56 {{- with .Values.loki.podLabels }}
57 {{- toYaml . | nindent 8 }}
58 {{- end }}
59 {{- with .Values.read.podLabels }}
60 {{- toYaml . | nindent 8 }}
61 {{- end }}
62 {{- with .Values.read.selectorLabels }}
63 {{- tpl (toYaml .) $ | nindent 8 }}
64 {{- end }}
65 spec:
66 serviceAccountName: {{ include "loki.serviceAccountName" . }}
67 automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
68 {{ include "loki.enableServiceLinks" . }}
69 {{- with .Values.imagePullSecrets }}
70 imagePullSecrets:
71 {{- toYaml . | nindent 8 }}
72 {{- end }}
73 {{- include "loki.readPriorityClassName" . | nindent 6 }}
74 securityContext:
75 {{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
76 terminationGracePeriodSeconds: {{ .Values.read.terminationGracePeriodSeconds }}
77 containers:
78 - name: loki
79 image: {{ include "loki.image" . }}
80 imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
81 args:
82 - -config.file=/etc/loki/config/config.yaml
83 - -target={{ .Values.read.targetModule }}
84 {{- with .Values.read.extraArgs }}
85 {{- toYaml . | nindent 12 }}
86 {{- end }}
87 ports:
88 - name: http-metrics
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030089 containerPort: {{ .Values.loki.server.http_listen_port }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000090 protocol: TCP
91 - name: grpc
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030092 containerPort: {{ .Values.loki.server.grpc_listen_port }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000093 protocol: TCP
94 - name: http-memberlist
95 containerPort: 7946
96 protocol: TCP
97 {{- with .Values.read.extraEnv }}
98 env:
99 {{- toYaml . | nindent 12 }}
100 {{- end }}
101 {{- with .Values.read.extraEnvFrom }}
102 envFrom:
103 {{- toYaml . | nindent 12 }}
104 {{- end }}
105 securityContext:
106 {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
107 readinessProbe:
108 {{- toYaml .Values.loki.readinessProbe | nindent 12 }}
109 {{- with .Values.read.lifecycle }}
110 lifecycle:
111 {{- toYaml . | nindent 12 }}
112 {{- end }}
113 volumeMounts:
114 - name: config
115 mountPath: /etc/loki/config
116 - name: runtime-config
117 mountPath: /etc/loki/runtime-config
118 - name: tmp
119 mountPath: /tmp
120 - name: data
121 mountPath: /var/loki
122 {{- if .Values.enterprise.enabled }}
123 - name: license
124 mountPath: /etc/loki/license
125 {{- end}}
126 {{- with .Values.read.extraVolumeMounts }}
127 {{- toYaml . | nindent 12 }}
128 {{- end }}
129 resources:
130 {{- toYaml .Values.read.resources | nindent 12 }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -0300131 {{- with .Values.read.extraContainers }}
132 {{- toYaml . | nindent 8}}
133 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000134 {{- with .Values.read.affinity }}
135 affinity:
136 {{- tpl . $ | nindent 8 }}
137 {{- end }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -0300138 {{- with .Values.read.dnsConfig }}
139 dnsConfig:
140 {{- tpl . $ | nindent 8 }}
141 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000142 {{- with .Values.read.nodeSelector }}
143 nodeSelector:
144 {{- toYaml . | nindent 8 }}
145 {{- end }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -0300146 {{- with .Values.read.topologySpreadConstraints }}
147 topologySpreadConstraints:
148 {{- toYaml . | nindent 8 }}
149 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000150 {{- with .Values.read.tolerations }}
151 tolerations:
152 {{- toYaml . | nindent 8 }}
153 {{- end }}
154 volumes:
155 - name: tmp
156 emptyDir: {}
157 - name: config
158 {{- if .Values.loki.existingSecretForConfig }}
159 secret:
160 secretName: {{ .Values.loki.existingSecretForConfig }}
161 {{- else }}
162 configMap:
163 name: {{ include "loki.name" . }}
164 {{- end }}
165 - name: runtime-config
166 configMap:
167 name: {{ template "loki.name" . }}-runtime
168 {{- if .Values.enterprise.enabled }}
169 - name: license
170 secret:
171 {{- if .Values.enterprise.useExternalLicense }}
172 secretName: {{ .Values.enterprise.externalLicenseName }}
173 {{- else }}
174 secretName: enterprise-logs-license
175 {{- end }}
176 {{- end }}
177 {{- with .Values.read.extraVolumes }}
178 {{- toYaml . | nindent 8 }}
179 {{- end }}
180 volumeClaimTemplates:
Giovanni Tirloni52306ad2024-04-12 15:35:05 -0300181 - apiVersion: v1
182 kind: PersistentVolumeClaim
183 metadata:
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000184 name: data
185 spec:
186 accessModes:
187 - ReadWriteOnce
188 {{- with .Values.read.persistence.storageClass }}
189 storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
190 {{- end }}
191 resources:
192 requests:
193 storage: {{ .Values.read.persistence.size | quote }}
194 {{- with .Values.read.persistence.selector }}
195 selector:
196 {{- toYaml . | nindent 10 }}
197 {{- end }}
198{{- end }}