blob: 7696d90e65bd65c644f3dd03d6d47c7b57dcf8c8 [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 Tirloni59219b62024-04-09 14:50:25 -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 Tirloni59219b62024-04-09 14:50:25 -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:
Mohammed Naser7d1623e2024-06-17 09:12:39 -040022{{- if not .Values.read.autoscaling.enabled }}
Mohammed Naser65cda132024-05-02 14:34:08 -040023 {{- if eq .Values.deploymentMode "SingleBinary" }}
24 replicas: 0
25 {{- else }}
Mohammed Naser7d1623e2024-06-17 09:12:39 -040026 replicas: {{ .Values.read.replicas }}
Mohammed Naser65cda132024-05-02 14:34:08 -040027 {{- end }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -030028{{- end }}
29 podManagementPolicy: {{ .Values.read.podManagementPolicy }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000030 updateStrategy:
31 rollingUpdate:
32 partition: 0
33 serviceName: {{ printf "%s-headless" (include "loki.readFullname" .) }}
34 revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
35 {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.read.persistence.enableStatefulSetAutoDeletePVC) }}
36 {{/*
37 Data on the read nodes is easy to replace, so we want to always delete PVCs to make
38 operation easier, and will rely on re-fetching data when needed.
39 */}}
40 persistentVolumeClaimRetentionPolicy:
41 whenDeleted: Delete
42 whenScaled: Delete
43 {{- end }}
44 selector:
45 matchLabels:
46 {{- include "loki.readSelectorLabels" . | nindent 6 }}
47 template:
48 metadata:
49 annotations:
Giovanni Tirloni59219b62024-04-09 14:50:25 -030050 checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000051 {{- with .Values.loki.podAnnotations }}
52 {{- toYaml . | nindent 8 }}
53 {{- end }}
54 {{- with .Values.read.podAnnotations }}
55 {{- toYaml . | nindent 8 }}
56 {{- end }}
57 labels:
58 app.kubernetes.io/part-of: memberlist
59 {{- include "loki.readSelectorLabels" . | nindent 8 }}
60 {{- with .Values.loki.podLabels }}
61 {{- toYaml . | nindent 8 }}
62 {{- end }}
63 {{- with .Values.read.podLabels }}
64 {{- toYaml . | nindent 8 }}
65 {{- end }}
66 {{- with .Values.read.selectorLabels }}
67 {{- tpl (toYaml .) $ | nindent 8 }}
68 {{- end }}
69 spec:
70 serviceAccountName: {{ include "loki.serviceAccountName" . }}
71 automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
72 {{ include "loki.enableServiceLinks" . }}
73 {{- with .Values.imagePullSecrets }}
74 imagePullSecrets:
75 {{- toYaml . | nindent 8 }}
76 {{- end }}
77 {{- include "loki.readPriorityClassName" . | nindent 6 }}
78 securityContext:
79 {{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
80 terminationGracePeriodSeconds: {{ .Values.read.terminationGracePeriodSeconds }}
81 containers:
82 - name: loki
83 image: {{ include "loki.image" . }}
84 imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
85 args:
86 - -config.file=/etc/loki/config/config.yaml
87 - -target={{ .Values.read.targetModule }}
88 {{- with .Values.read.extraArgs }}
89 {{- toYaml . | nindent 12 }}
90 {{- end }}
91 ports:
92 - name: http-metrics
Giovanni Tirloni59219b62024-04-09 14:50:25 -030093 containerPort: {{ .Values.loki.server.http_listen_port }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000094 protocol: TCP
95 - name: grpc
Giovanni Tirloni59219b62024-04-09 14:50:25 -030096 containerPort: {{ .Values.loki.server.grpc_listen_port }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000097 protocol: TCP
98 - name: http-memberlist
99 containerPort: 7946
100 protocol: TCP
101 {{- with .Values.read.extraEnv }}
102 env:
103 {{- toYaml . | nindent 12 }}
104 {{- end }}
105 {{- with .Values.read.extraEnvFrom }}
106 envFrom:
107 {{- toYaml . | nindent 12 }}
108 {{- end }}
109 securityContext:
110 {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
111 readinessProbe:
112 {{- toYaml .Values.loki.readinessProbe | nindent 12 }}
113 {{- with .Values.read.lifecycle }}
114 lifecycle:
115 {{- toYaml . | nindent 12 }}
116 {{- end }}
117 volumeMounts:
118 - name: config
119 mountPath: /etc/loki/config
120 - name: runtime-config
121 mountPath: /etc/loki/runtime-config
122 - name: tmp
123 mountPath: /tmp
124 - name: data
125 mountPath: /var/loki
126 {{- if .Values.enterprise.enabled }}
127 - name: license
128 mountPath: /etc/loki/license
129 {{- end}}
130 {{- with .Values.read.extraVolumeMounts }}
131 {{- toYaml . | nindent 12 }}
132 {{- end }}
133 resources:
134 {{- toYaml .Values.read.resources | nindent 12 }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300135 {{- with .Values.read.extraContainers }}
136 {{- toYaml . | nindent 8}}
137 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000138 {{- with .Values.read.affinity }}
139 affinity:
Mohammed Naser65cda132024-05-02 14:34:08 -0400140 {{- toYaml . | nindent 8 }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000141 {{- end }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300142 {{- with .Values.read.dnsConfig }}
143 dnsConfig:
144 {{- tpl . $ | nindent 8 }}
145 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000146 {{- with .Values.read.nodeSelector }}
147 nodeSelector:
148 {{- toYaml . | nindent 8 }}
149 {{- end }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300150 {{- with .Values.read.topologySpreadConstraints }}
151 topologySpreadConstraints:
152 {{- toYaml . | nindent 8 }}
153 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000154 {{- with .Values.read.tolerations }}
155 tolerations:
156 {{- toYaml . | nindent 8 }}
157 {{- end }}
158 volumes:
159 - name: tmp
160 emptyDir: {}
161 - name: config
Mohammed Naser65cda132024-05-02 14:34:08 -0400162 {{- include "loki.configVolume" . | nindent 10 }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000163 - name: runtime-config
164 configMap:
165 name: {{ template "loki.name" . }}-runtime
166 {{- if .Values.enterprise.enabled }}
167 - name: license
168 secret:
169 {{- if .Values.enterprise.useExternalLicense }}
170 secretName: {{ .Values.enterprise.externalLicenseName }}
171 {{- else }}
172 secretName: enterprise-logs-license
173 {{- end }}
174 {{- end }}
175 {{- with .Values.read.extraVolumes }}
176 {{- toYaml . | nindent 8 }}
177 {{- end }}
178 volumeClaimTemplates:
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300179 - apiVersion: v1
180 kind: PersistentVolumeClaim
181 metadata:
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000182 name: data
Mohammed Naser7d1623e2024-06-17 09:12:39 -0400183 {{- with .Values.read.persistence.annotations }}
184 annotations:
185 {{- toYaml . | nindent 10 }}
186 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000187 spec:
188 accessModes:
189 - ReadWriteOnce
190 {{- with .Values.read.persistence.storageClass }}
191 storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
192 {{- end }}
193 resources:
194 requests:
195 storage: {{ .Values.read.persistence.size | quote }}
196 {{- with .Values.read.persistence.selector }}
197 selector:
198 {{- toYaml . | nindent 10 }}
199 {{- end }}
200{{- end }}