blob: 7bd2b9813f6093699d0aaa6bd072fafd7fec4b3a [file] [log] [blame]
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +00001{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
2{{- if $isSingleBinary }}
3---
4apiVersion: apps/v1
5kind: StatefulSet
6metadata:
7 name: {{ include "loki.singleBinaryFullname" . }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -03008 namespace: {{ $.Release.Namespace }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +00009 labels:
10 {{- include "loki.singleBinaryLabels" . | nindent 4 }}
11 app.kubernetes.io/part-of: memberlist
Giovanni Tirloni59219b62024-04-09 14:50:25 -030012 {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.singleBinary.annotations))}}
13 annotations:
14 {{- with .Values.loki.annotations }}
15 {{- toYaml . | nindent 4 }}
16 {{- end }}
17 {{- with .Values.singleBinary.annotations }}
18 {{- toYaml . | nindent 4 }}
19 {{- end }}
20 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000021spec:
22 replicas: {{ include "loki.singleBinaryReplicas" . }}
23 podManagementPolicy: Parallel
24 updateStrategy:
25 rollingUpdate:
26 partition: 0
27 serviceName: {{ include "loki.singleBinaryFullname" . }}-headless
28 revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -030029 {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.singleBinary.persistence.enableStatefulSetAutoDeletePVC) (.Values.singleBinary.persistence.enabled) }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000030 {{/*
31 Data on the singleBinary nodes is easy to replace, so we want to always delete PVCs to make
32 operation easier, and will rely on re-fetching data when needed.
33 */}}
34 persistentVolumeClaimRetentionPolicy:
35 whenDeleted: Delete
36 whenScaled: Delete
37 {{- end }}
38 selector:
39 matchLabels:
40 {{- include "loki.singleBinarySelectorLabels" . | nindent 6 }}
41 template:
42 metadata:
43 annotations:
Giovanni Tirloni59219b62024-04-09 14:50:25 -030044 checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000045 {{- with .Values.loki.podAnnotations }}
46 {{- toYaml . | nindent 8 }}
47 {{- end }}
48 {{- with .Values.singleBinary.podAnnotations }}
49 {{- toYaml . | nindent 8 }}
50 {{- end }}
51 labels:
52 {{- include "loki.singleBinarySelectorLabels" . | nindent 8 }}
53 {{- with .Values.loki.podLabels }}
54 {{- toYaml . | nindent 8 }}
55 {{- end }}
56 {{- with .Values.singleBinary.podLabels }}
57 {{- toYaml . | nindent 8 }}
58 {{- end }}
59 {{- with .Values.singleBinary.selectorLabels }}
60 {{- tpl (toYaml .) $ | nindent 8 }}
61 {{- end }}
62 app.kubernetes.io/part-of: memberlist
63 spec:
64 serviceAccountName: {{ include "loki.serviceAccountName" . }}
65 automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
66 {{ include "loki.enableServiceLinks" . }}
67 {{- with .Values.imagePullSecrets }}
68 imagePullSecrets:
69 {{- toYaml . | nindent 8 }}
70 {{- end }}
71 {{- include "loki.singleBinaryPriorityClassName" . | nindent 6 }}
72 securityContext:
73 {{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
74 terminationGracePeriodSeconds: {{ .Values.singleBinary.terminationGracePeriodSeconds }}
75 {{- if .Values.singleBinary.initContainers }}
76 initContainers:
77 {{- with .Values.singleBinary.initContainers }}
78 {{- toYaml . | nindent 8 }}
79 {{- end }}
80 {{- end }}
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.singleBinary.targetModule }}
88 {{- with .Values.singleBinary.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.singleBinary.extraEnv }}
102 env:
103 {{- toYaml . | nindent 12 }}
104 {{- end }}
105 {{- with .Values.singleBinary.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 volumeMounts:
114 - name: tmp
115 mountPath: /tmp
116 - name: config
117 mountPath: /etc/loki/config
118 - name: runtime-config
119 mountPath: /etc/loki/runtime-config
120 {{- if .Values.singleBinary.persistence.enabled }}
121 - name: storage
122 mountPath: /var/loki
123 {{- end }}
124 {{- if .Values.enterprise.enabled }}
125 - name: license
126 mountPath: /etc/loki/license
127 {{- end }}
128 {{- with .Values.singleBinary.extraVolumeMounts }}
129 {{- toYaml . | nindent 12 }}
130 {{- end }}
131 resources:
132 {{- toYaml .Values.singleBinary.resources | nindent 12 }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300133 {{- with .Values.singleBinary.extraContainers }}
134 {{- toYaml . | nindent 8 }}
135 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000136 {{- with .Values.singleBinary.affinity }}
137 affinity:
Mohammed Naser65cda132024-05-02 14:34:08 -0400138 {{- toYaml . | nindent 8 }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000139 {{- end }}
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300140 {{- with .Values.singleBinary.dnsConfig }}
141 dnsConfig:
142 {{- tpl . $ | nindent 8 }}
143 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000144 {{- with .Values.singleBinary.nodeSelector }}
145 nodeSelector:
146 {{- toYaml . | nindent 8 }}
147 {{- end }}
148 {{- with .Values.singleBinary.tolerations }}
149 tolerations:
150 {{- toYaml . | nindent 8 }}
151 {{- end }}
152 volumes:
153 - name: tmp
154 emptyDir: {}
155 - name: config
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300156 {{- include "loki.configVolume" . | nindent 10 }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000157 - name: runtime-config
158 configMap:
159 name: {{ template "loki.name" . }}-runtime
160 {{- if .Values.enterprise.enabled }}
161 - name: license
162 secret:
163 {{- if .Values.enterprise.useExternalLicense }}
164 secretName: {{ .Values.enterprise.externalLicenseName }}
165 {{- else }}
166 secretName: enterprise-logs-license
167 {{- end }}
168 {{- end }}
169 {{- with .Values.singleBinary.extraVolumes }}
170 {{- toYaml . | nindent 8 }}
171 {{- end }}
172 {{- if .Values.singleBinary.persistence.enabled }}
173 volumeClaimTemplates:
Giovanni Tirloni59219b62024-04-09 14:50:25 -0300174 - apiVersion: v1
175 kind: PersistentVolumeClaim
176 metadata:
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000177 name: storage
Mohammed Naser7d1623e2024-06-17 09:12:39 -0400178 {{- with .Values.singleBinary.persistence.annotations }}
179 annotations:
180 {{- toYaml . | nindent 10 }}
181 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +0000182 spec:
183 accessModes:
184 - ReadWriteOnce
185 {{- with .Values.singleBinary.persistence.storageClass }}
186 storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
187 {{- end }}
188 resources:
189 requests:
190 storage: {{ .Values.singleBinary.persistence.size | quote }}
191 {{- with .Values.singleBinary.persistence.selector }}
192 selector:
193 {{- toYaml . | nindent 10 }}
194 {{- end }}
195 {{- end }}
196{{- end }}